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

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

Issue 7243012: Change many extension event routers to not be singletons and to be more profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bookmark remove observer Created 9 years, 6 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
« no previous file with comments | « chrome/browser/extensions/extension_webnavigation_api.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // Implements the Chrome Extensions WebNavigation API. 5 // Implements the Chrome Extensions WebNavigation API.
6 6
7 #include "chrome/browser/extensions/extension_webnavigation_api.h" 7 #include "chrome/browser/extensions/extension_webnavigation_api.h"
8 8
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/string_number_conversions.h" 10 #include "base/string_number_conversions.h"
(...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 for (FrameIdIterator frame_id = frame_ids.first; frame_id != frame_ids.second; 240 for (FrameIdIterator frame_id = frame_ids.first; frame_id != frame_ids.second;
241 ++frame_id) { 241 ++frame_id) {
242 frame_state_map_.erase(frame_id->second); 242 frame_state_map_.erase(frame_id->second);
243 } 243 }
244 tab_contents_map_.erase(tab_contents); 244 tab_contents_map_.erase(tab_contents);
245 } 245 }
246 246
247 247
248 // ExtensionWebNavigtionEventRouter ------------------------------------------- 248 // ExtensionWebNavigtionEventRouter -------------------------------------------
249 249
250 ExtensionWebNavigationEventRouter::ExtensionWebNavigationEventRouter() {} 250 ExtensionWebNavigationEventRouter::ExtensionWebNavigationEventRouter(
251 Profile* profile) : profile_(profile) {}
251 252
252 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {} 253 ExtensionWebNavigationEventRouter::~ExtensionWebNavigationEventRouter() {}
253 254
254 // static
255 ExtensionWebNavigationEventRouter*
256 ExtensionWebNavigationEventRouter::GetInstance() {
257 return Singleton<ExtensionWebNavigationEventRouter>::get();
258 }
259
260 void ExtensionWebNavigationEventRouter::Init() { 255 void ExtensionWebNavigationEventRouter::Init() {
261 if (registrar_.IsEmpty()) { 256 if (registrar_.IsEmpty()) {
262 registrar_.Add(this, 257 registrar_.Add(this,
263 NotificationType::CREATING_NEW_WINDOW, 258 NotificationType::CREATING_NEW_WINDOW,
264 NotificationService::AllSources()); 259 NotificationService::AllSources());
265 } 260 }
266 } 261 }
267 262
268 void ExtensionWebNavigationEventRouter::Observe( 263 void ExtensionWebNavigationEventRouter::Observe(
269 NotificationType type, 264 NotificationType type,
270 const NotificationSource& source, 265 const NotificationSource& source,
271 const NotificationDetails& details) { 266 const NotificationDetails& details) {
272 switch (type.value) { 267 switch (type.value) {
273 case NotificationType::CREATING_NEW_WINDOW: 268 case NotificationType::CREATING_NEW_WINDOW:
274 CreatingNewWindow( 269 CreatingNewWindow(
275 Source<TabContents>(source).ptr(), 270 Source<TabContents>(source).ptr(),
276 Details<const ViewHostMsg_CreateWindow_Params>(details).ptr()); 271 Details<const ViewHostMsg_CreateWindow_Params>(details).ptr());
277 break; 272 break;
278 273
279 default: 274 default:
280 NOTREACHED(); 275 NOTREACHED();
281 } 276 }
282 } 277 }
283 278
284 void ExtensionWebNavigationEventRouter::CreatingNewWindow( 279 void ExtensionWebNavigationEventRouter::CreatingNewWindow(
285 TabContents* tab_contents, 280 TabContents* tab_contents,
286 const ViewHostMsg_CreateWindow_Params* details) { 281 const ViewHostMsg_CreateWindow_Params* details) {
287 DispatchOnBeforeRetarget(tab_contents, 282 if (profile_->IsSameProfile(tab_contents->profile())) {
288 tab_contents->profile(), 283 DispatchOnBeforeRetarget(tab_contents,
289 details->opener_url, 284 tab_contents->profile(),
290 details->target_url); 285 details->opener_url,
286 details->target_url);
287 }
291 } 288 }
292 289
293 290
294 // ExtensionWebNavigationTabObserver ------------------------------------------ 291 // ExtensionWebNavigationTabObserver ------------------------------------------
295 292
296 ExtensionWebNavigationTabObserver::ExtensionWebNavigationTabObserver( 293 ExtensionWebNavigationTabObserver::ExtensionWebNavigationTabObserver(
297 TabContents* tab_contents) 294 TabContents* tab_contents)
298 : TabContentsObserver(tab_contents) {} 295 : TabContentsObserver(tab_contents) {}
299 296
300 ExtensionWebNavigationTabObserver::~ExtensionWebNavigationTabObserver() {} 297 ExtensionWebNavigationTabObserver::~ExtensionWebNavigationTabObserver() {}
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 transition_type); 442 transition_type);
446 DispatchOnDOMContentLoaded(tab_contents(), 443 DispatchOnDOMContentLoaded(tab_contents(),
447 url, 444 url,
448 is_main_frame, 445 is_main_frame,
449 frame_id); 446 frame_id);
450 DispatchOnCompleted(tab_contents(), 447 DispatchOnCompleted(tab_contents(),
451 url, 448 url,
452 is_main_frame, 449 is_main_frame,
453 frame_id); 450 frame_id);
454 } 451 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_webnavigation_api.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698