Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(255)

Side by Side Diff: chrome/browser/extensions/extension_navigation_observer.cc

Issue 8342048: Make NotificationService an interface in the content namespace, and switch callers to use it. Mov... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/tab_contents/navigation_entry.h" 10 #include "content/browser/tab_contents/navigation_entry.h"
11 #include "content/common/notification_service.h" 11 #include "content/public/browser/notification_service.h"
12 12
13 ExtensionNavigationObserver::ExtensionNavigationObserver(Profile* profile) 13 ExtensionNavigationObserver::ExtensionNavigationObserver(Profile* profile)
14 : profile_(profile) { 14 : profile_(profile) {
15 RegisterForNotifications(); 15 RegisterForNotifications();
16 } 16 }
17 17
18 ExtensionNavigationObserver::~ExtensionNavigationObserver() {} 18 ExtensionNavigationObserver::~ExtensionNavigationObserver() {}
19 19
20 void ExtensionNavigationObserver::Observe( 20 void ExtensionNavigationObserver::Observe(
21 int type, 21 int type,
22 const content::NotificationSource& source, 22 const content::NotificationSource& source,
23 const content::NotificationDetails& details) { 23 const content::NotificationDetails& details) {
24 if (type != content::NOTIFICATION_NAV_ENTRY_COMMITTED) { 24 if (type != content::NOTIFICATION_NAV_ENTRY_COMMITTED) {
25 NOTREACHED(); 25 NOTREACHED();
26 return; 26 return;
27 } 27 }
28 28
29 NavigationController* controller = 29 NavigationController* controller =
30 content::Source<NavigationController>(source).ptr(); 30 content::Source<NavigationController>(source).ptr();
31 if (!profile_->IsSameProfile( 31 if (!profile_->IsSameProfile(
32 Profile::FromBrowserContext(controller->browser_context()))) 32 Profile::FromBrowserContext(controller->browser_context())))
33 return; 33 return;
34 34
35 PromptToEnableExtensionIfNecessary(controller); 35 PromptToEnableExtensionIfNecessary(controller);
36 } 36 }
37 37
38 void ExtensionNavigationObserver::RegisterForNotifications() { 38 void ExtensionNavigationObserver::RegisterForNotifications() {
39 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 39 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
40 NotificationService::AllSources()); 40 content::NotificationService::AllSources());
41 } 41 }
42 42
43 void ExtensionNavigationObserver::PromptToEnableExtensionIfNecessary( 43 void ExtensionNavigationObserver::PromptToEnableExtensionIfNecessary(
44 NavigationController* nav_controller) { 44 NavigationController* nav_controller) {
45 // Bail out if we're already running a prompt. 45 // Bail out if we're already running a prompt.
46 if (!in_progress_prompt_extension_id_.empty()) 46 if (!in_progress_prompt_extension_id_.empty())
47 return; 47 return;
48 48
49 NavigationEntry* nav_entry = nav_controller->GetActiveEntry(); 49 NavigationEntry* nav_entry = nav_controller->GetActiveEntry();
50 if (!nav_entry) 50 if (!nav_entry)
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 in_progress_prompt_extension_id_ = ""; 99 in_progress_prompt_extension_id_ = "";
100 in_progress_prompt_navigation_controller_ = NULL; 100 in_progress_prompt_navigation_controller_ = NULL;
101 extension_install_ui_.reset(); 101 extension_install_ui_.reset();
102 102
103 std::string histogram_name = user_initiated ? 103 std::string histogram_name = user_initiated ?
104 "Extensions.Permissions_ReEnableCancel" : 104 "Extensions.Permissions_ReEnableCancel" :
105 "Extensions.Permissions_ReEnableAbort"; 105 "Extensions.Permissions_ReEnableAbort";
106 ExtensionService::RecordPermissionMessagesHistogram( 106 ExtensionService::RecordPermissionMessagesHistogram(
107 extension, histogram_name.c_str()); 107 extension, histogram_name.c_str());
108 } 108 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_metrics_apitest.cc ('k') | chrome/browser/extensions/extension_omnibox_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698