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

Side by Side Diff: chrome/browser/sync/sessions/notification_service_sessions_router.cc

Issue 645043003: Cleanup: Prevent usage of various extension headers when extensions support is not compiled in. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/sync/sessions/notification_service_sessions_router.h" 5 #include "chrome/browser/sync/sessions/notification_service_sessions_router.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chrome_notification_types.h" 8 #include "chrome/browser/chrome_notification_types.h"
9 #include "chrome/browser/extensions/tab_helper.h"
10 #include "chrome/browser/history/history_service.h" 9 #include "chrome/browser/history/history_service.h"
11 #include "chrome/browser/history/history_service_factory.h" 10 #include "chrome/browser/history/history_service_factory.h"
12 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/sync/glue/sync_start_util.h" 12 #include "chrome/browser/sync/glue/sync_start_util.h"
14 #include "chrome/browser/sync/glue/synced_tab_delegate.h" 13 #include "chrome/browser/sync/glue/synced_tab_delegate.h"
15 #include "chrome/browser/sync/sessions/sessions_util.h" 14 #include "chrome/browser/sync/sessions/sessions_util.h"
16 #include "chrome/browser/ui/browser.h" 15 #include "chrome/browser/ui/browser.h"
17 #include "content/public/browser/navigation_controller.h" 16 #include "content/public/browser/navigation_controller.h"
18 #include "content/public/browser/navigation_entry.h" 17 #include "content/public/browser/navigation_entry.h"
19 #include "content/public/browser/notification_details.h" 18 #include "content/public/browser/notification_details.h"
20 #include "content/public/browser/notification_service.h" 19 #include "content/public/browser/notification_service.h"
21 #include "content/public/browser/notification_source.h" 20 #include "content/public/browser/notification_source.h"
22 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
23 22
24 #if defined(ENABLE_MANAGED_USERS) 23 #if defined(ENABLE_MANAGED_USERS)
25 #include "chrome/browser/supervised_user/supervised_user_service.h" 24 #include "chrome/browser/supervised_user/supervised_user_service.h"
26 #include "chrome/browser/supervised_user/supervised_user_service_factory.h" 25 #include "chrome/browser/supervised_user/supervised_user_service_factory.h"
27 #endif 26 #endif
28 27
28 #if defined(ENABLE_EXTENSIONS)
29 #include "chrome/browser/extensions/tab_helper.h"
30 #endif
31
29 using content::NavigationController; 32 using content::NavigationController;
30 using content::WebContents; 33 using content::WebContents;
31 34
32 namespace browser_sync { 35 namespace browser_sync {
33 36
34 NotificationServiceSessionsRouter::NotificationServiceSessionsRouter( 37 NotificationServiceSessionsRouter::NotificationServiceSessionsRouter(
35 Profile* profile, const syncer::SyncableService::StartSyncFlare& flare) 38 Profile* profile, const syncer::SyncableService::StartSyncFlare& flare)
36 : handler_(NULL), 39 : handler_(NULL),
37 profile_(profile), 40 profile_(profile),
38 flare_(flare), 41 flare_(flare),
39 weak_ptr_factory_(this) { 42 weak_ptr_factory_(this) {
40
41 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED, 43 registrar_.Add(this, chrome::NOTIFICATION_TAB_PARENTED,
42 content::NotificationService::AllSources()); 44 content::NotificationService::AllSources());
43 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED, 45 registrar_.Add(this, content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
44 content::NotificationService::AllSources()); 46 content::NotificationService::AllSources());
45 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED, 47 registrar_.Add(this, content::NOTIFICATION_NAV_LIST_PRUNED,
46 content::NotificationService::AllSources()); 48 content::NotificationService::AllSources());
47 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED, 49 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_CHANGED,
48 content::NotificationService::AllSources()); 50 content::NotificationService::AllSources());
49 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED, 51 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_COMMITTED,
50 content::NotificationService::AllSources()); 52 content::NotificationService::AllSources());
53 #if defined(ENABLE_EXTENSIONS)
51 registrar_.Add(this, 54 registrar_.Add(this,
52 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED, 55 chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED,
53 content::NotificationService::AllSources()); 56 content::NotificationService::AllSources());
57 #endif
54 registrar_.Add(this, 58 registrar_.Add(this,
55 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, 59 content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME,
56 content::NotificationService::AllBrowserContextsAndSources()); 60 content::NotificationService::AllBrowserContextsAndSources());
57 HistoryService* history_service = 61 HistoryService* history_service =
58 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS); 62 HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS);
59 if (history_service) { 63 if (history_service) {
60 favicon_changed_subscription_ = history_service->AddFaviconChangedCallback( 64 favicon_changed_subscription_ = history_service->AddFaviconChangedCallback(
61 base::Bind(&NotificationServiceSessionsRouter::OnFaviconChanged, 65 base::Bind(&NotificationServiceSessionsRouter::OnFaviconChanged,
62 base::Unretained(this))); 66 base::Unretained(this)));
63 } 67 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 content::Source<NavigationController>(source).ptr()-> 106 content::Source<NavigationController>(source).ptr()->
103 GetWebContents()); 107 GetWebContents());
104 if (!tab || tab->profile() != profile_) 108 if (!tab || tab->profile() != profile_)
105 return; 109 return;
106 if (handler_) 110 if (handler_)
107 handler_->OnLocalTabModified(tab); 111 handler_->OnLocalTabModified(tab);
108 if (!sessions_util::ShouldSyncTab(*tab)) 112 if (!sessions_util::ShouldSyncTab(*tab))
109 return; 113 return;
110 break; 114 break;
111 } 115 }
116 #if defined(ENABLE_EXTENSIONS)
112 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: { 117 case chrome::NOTIFICATION_TAB_CONTENTS_APPLICATION_EXTENSION_CHANGED: {
113 extensions::TabHelper* extension_tab_helper = 118 extensions::TabHelper* extension_tab_helper =
114 content::Source<extensions::TabHelper>(source).ptr(); 119 content::Source<extensions::TabHelper>(source).ptr();
115 if (extension_tab_helper->web_contents()->GetBrowserContext() != 120 if (extension_tab_helper->web_contents()->GetBrowserContext() !=
116 profile_) { 121 profile_) {
117 return; 122 return;
118 } 123 }
119 if (extension_tab_helper->extension_app()) { 124 if (extension_tab_helper->extension_app()) {
120 SyncedTabDelegate* tab = SyncedTabDelegate::ImplFromWebContents( 125 SyncedTabDelegate* tab = SyncedTabDelegate::ImplFromWebContents(
121 extension_tab_helper->web_contents()); 126 extension_tab_helper->web_contents());
122 if (!tab || tab->profile() != profile_) 127 if (!tab || tab->profile() != profile_)
123 return; 128 return;
124 if (handler_) 129 if (handler_)
125 handler_->OnLocalTabModified(tab); 130 handler_->OnLocalTabModified(tab);
126 break; 131 break;
127 } 132 }
128 return; 133 return;
129 } 134 }
135 #endif
130 default: 136 default:
131 LOG(ERROR) << "Received unexpected notification of type " << type; 137 LOG(ERROR) << "Received unexpected notification of type " << type;
132 return; 138 return;
133 } 139 }
134 140
135 if (!flare_.is_null()) { 141 if (!flare_.is_null()) {
136 flare_.Run(syncer::SESSIONS); 142 flare_.Run(syncer::SESSIONS);
137 flare_.Reset(); 143 flare_.Reset();
138 } 144 }
139 } 145 }
(...skipping 20 matching lines...) Expand all
160 DCHECK(!handler_); 166 DCHECK(!handler_);
161 handler_ = handler; 167 handler_ = handler;
162 } 168 }
163 169
164 void NotificationServiceSessionsRouter::Stop() { 170 void NotificationServiceSessionsRouter::Stop() {
165 weak_ptr_factory_.InvalidateWeakPtrs(); 171 weak_ptr_factory_.InvalidateWeakPtrs();
166 handler_ = NULL; 172 handler_ = NULL;
167 } 173 }
168 174
169 } // namespace browser_sync 175 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/extensions_activity_monitor.cc ('k') | chrome/browser/ui/webui/policy_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698