| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_navigation_observer.h" | 5 #include "chrome/browser/extensions/extension_navigation_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/extensions/extension_service.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "content/browser/tab_contents/navigation_controller.h" | 9 #include "content/browser/tab_contents/navigation_controller.h" |
| 10 #include "content/public/browser/navigation_entry.h" | 10 #include "content/public/browser/navigation_entry.h" |
| 11 #include "content/public/browser/notification_service.h" | 11 #include "content/public/browser/notification_service.h" |
| 12 | 12 |
| 13 using content::NavigationEntry; |
| 14 |
| 13 ExtensionNavigationObserver::ExtensionNavigationObserver(Profile* profile) | 15 ExtensionNavigationObserver::ExtensionNavigationObserver(Profile* profile) |
| 14 : profile_(profile) { | 16 : profile_(profile) { |
| 15 RegisterForNotifications(); | 17 RegisterForNotifications(); |
| 16 } | 18 } |
| 17 | 19 |
| 18 ExtensionNavigationObserver::~ExtensionNavigationObserver() {} | 20 ExtensionNavigationObserver::~ExtensionNavigationObserver() {} |
| 19 | 21 |
| 20 void ExtensionNavigationObserver::Observe( | 22 void ExtensionNavigationObserver::Observe( |
| 21 int type, | 23 int type, |
| 22 const content::NotificationSource& source, | 24 const content::NotificationSource& source, |
| (...skipping 16 matching lines...) Expand all Loading... |
| 39 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, | 41 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, |
| 40 content::NotificationService::AllSources()); | 42 content::NotificationService::AllSources()); |
| 41 } | 43 } |
| 42 | 44 |
| 43 void ExtensionNavigationObserver::PromptToEnableExtensionIfNecessary( | 45 void ExtensionNavigationObserver::PromptToEnableExtensionIfNecessary( |
| 44 NavigationController* nav_controller) { | 46 NavigationController* nav_controller) { |
| 45 // Bail out if we're already running a prompt. | 47 // Bail out if we're already running a prompt. |
| 46 if (!in_progress_prompt_extension_id_.empty()) | 48 if (!in_progress_prompt_extension_id_.empty()) |
| 47 return; | 49 return; |
| 48 | 50 |
| 49 content::NavigationEntry* nav_entry = nav_controller->GetActiveEntry(); | 51 NavigationEntry* nav_entry = nav_controller->GetActiveEntry(); |
| 50 if (!nav_entry) | 52 if (!nav_entry) |
| 51 return; | 53 return; |
| 52 | 54 |
| 53 ExtensionService* extension_service = profile_->GetExtensionService(); | 55 ExtensionService* extension_service = profile_->GetExtensionService(); |
| 54 const Extension* extension = | 56 const Extension* extension = |
| 55 extension_service->disabled_extensions()-> | 57 extension_service->disabled_extensions()-> |
| 56 GetExtensionOrAppByURL(ExtensionURLInfo(nav_entry->GetURL())); | 58 GetExtensionOrAppByURL(ExtensionURLInfo(nav_entry->GetURL())); |
| 57 if (!extension) | 59 if (!extension) |
| 58 return; | 60 return; |
| 59 | 61 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 in_progress_prompt_extension_id_ = ""; | 102 in_progress_prompt_extension_id_ = ""; |
| 101 in_progress_prompt_navigation_controller_ = NULL; | 103 in_progress_prompt_navigation_controller_ = NULL; |
| 102 extension_install_ui_.reset(); | 104 extension_install_ui_.reset(); |
| 103 | 105 |
| 104 std::string histogram_name = user_initiated ? | 106 std::string histogram_name = user_initiated ? |
| 105 "Extensions.Permissions_ReEnableCancel" : | 107 "Extensions.Permissions_ReEnableCancel" : |
| 106 "Extensions.Permissions_ReEnableAbort"; | 108 "Extensions.Permissions_ReEnableAbort"; |
| 107 ExtensionService::RecordPermissionMessagesHistogram( | 109 ExtensionService::RecordPermissionMessagesHistogram( |
| 108 extension, histogram_name.c_str()); | 110 extension, histogram_name.c_str()); |
| 109 } | 111 } |
| OLD | NEW |