OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/navigation_observer.h" | 5 #include "chrome/browser/extensions/navigation_observer.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "content/public/browser/navigation_controller.h" | 10 #include "content/public/browser/navigation_controller.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 void NavigationObserver::PromptToEnableExtensionIfNecessary( | 62 void NavigationObserver::PromptToEnableExtensionIfNecessary( |
63 NavigationController* nav_controller) { | 63 NavigationController* nav_controller) { |
64 // Bail out if we're already running a prompt. | 64 // Bail out if we're already running a prompt. |
65 if (!in_progress_prompt_extension_id_.empty()) | 65 if (!in_progress_prompt_extension_id_.empty()) |
66 return; | 66 return; |
67 | 67 |
68 NavigationEntry* nav_entry = nav_controller->GetVisibleEntry(); | 68 NavigationEntry* nav_entry = nav_controller->GetVisibleEntry(); |
69 if (!nav_entry) | 69 if (!nav_entry) |
70 return; | 70 return; |
71 | 71 |
72 const GURL& url = nav_entry->GetURL(); | 72 // With a disabled extension, the navigation is blocked, which results in |
| 73 // an error page and NavigationEntry with "about:blank" URL. In this case, |
| 74 // the virtual URL is the real URL the user navigated to, so if this is the |
| 75 // case, use it instead. |
| 76 const GURL& url = (nav_entry->GetPageType() == content::PAGE_TYPE_ERROR && |
| 77 nav_entry->GetURL() == url::kAboutBlankURL && |
| 78 nav_entry->GetVirtualURL().SchemeIs(kExtensionScheme)) |
| 79 ? nav_entry->GetVirtualURL() |
| 80 : nav_entry->GetURL(); |
| 81 |
73 // NOTE: We only consider chrome-extension:// urls, and deliberately don't | 82 // NOTE: We only consider chrome-extension:// urls, and deliberately don't |
74 // consider hosted app urls. This is because it's really annoying to visit the | 83 // consider hosted app urls. This is because it's really annoying to visit the |
75 // site associated with a hosted app (like calendar.google.com or | 84 // site associated with a hosted app (like calendar.google.com or |
76 // drive.google.com) and have it repeatedly prompt you to re-enable an item. | 85 // drive.google.com) and have it repeatedly prompt you to re-enable an item. |
77 // Visiting a chrome-extension:// url is a much stronger signal, and, without | 86 // Visiting a chrome-extension:// url is a much stronger signal, and, without |
78 // the item enabled, we won't show anything. | 87 // the item enabled, we won't show anything. |
79 // TODO(devlin): While true, I still wonder how useful this is. We should get | 88 // TODO(devlin): While true, I still wonder how useful this is. We should get |
80 // metrics. | 89 // metrics. |
81 if (!url.SchemeIs(kExtensionScheme)) | 90 if (!url.SchemeIs(kExtensionScheme)) |
82 return; | 91 return; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 in_progress_prompt_extension_id_ != extension->id()) { | 171 in_progress_prompt_extension_id_ != extension->id()) { |
163 return; | 172 return; |
164 } | 173 } |
165 | 174 |
166 in_progress_prompt_extension_id_ = std::string(); | 175 in_progress_prompt_extension_id_ = std::string(); |
167 in_progress_prompt_navigation_controller_ = nullptr; | 176 in_progress_prompt_navigation_controller_ = nullptr; |
168 extension_install_prompt_.reset(); | 177 extension_install_prompt_.reset(); |
169 } | 178 } |
170 | 179 |
171 } // namespace extensions | 180 } // namespace extensions |
OLD | NEW |