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

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

Issue 11232066: Remove GetExtensionEventRouter from Profile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rerebase Created 8 years, 1 month 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) 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/browser_event_router.h" 5 #include "chrome/browser/extensions/browser_event_router.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h" 9 #include "chrome/browser/extensions/api/extension_action/extension_page_actions_ api_constants.h"
10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" 10 #include "chrome/browser/extensions/api/tabs/tabs_constants.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 if (changed_properties) 354 if (changed_properties)
355 DispatchTabUpdatedEvent(contents, changed_properties); 355 DispatchTabUpdatedEvent(contents, changed_properties);
356 } 356 }
357 357
358 void BrowserEventRouter::DispatchEvent( 358 void BrowserEventRouter::DispatchEvent(
359 Profile* profile, 359 Profile* profile,
360 const char* event_name, 360 const char* event_name,
361 scoped_ptr<ListValue> args, 361 scoped_ptr<ListValue> args,
362 EventRouter::UserGestureState user_gesture) { 362 EventRouter::UserGestureState user_gesture) {
363 if (!profile_->IsSameProfile(profile) || !profile->GetExtensionEventRouter()) 363 if (!profile_->IsSameProfile(profile) ||
364 !extensions::ExtensionSystem::Get(profile)->event_router())
364 return; 365 return;
365 366
366 profile->GetExtensionEventRouter()->DispatchEventToRenderers( 367 extensions::ExtensionSystem::Get(profile)->event_router()->
367 event_name, args.Pass(), profile, GURL(), user_gesture); 368 DispatchEventToRenderers(event_name, args.Pass(), profile, GURL(),
369 user_gesture);
368 } 370 }
369 371
370 void BrowserEventRouter::DispatchEventToExtension( 372 void BrowserEventRouter::DispatchEventToExtension(
371 Profile* profile, 373 Profile* profile,
372 const std::string& extension_id, 374 const std::string& extension_id,
373 const char* event_name, 375 const char* event_name,
374 scoped_ptr<ListValue> event_args, 376 scoped_ptr<ListValue> event_args,
375 EventRouter::UserGestureState user_gesture) { 377 EventRouter::UserGestureState user_gesture) {
376 if (!profile_->IsSameProfile(profile) || !profile->GetExtensionEventRouter()) 378 if (!profile_->IsSameProfile(profile) ||
379 !extensions::ExtensionSystem::Get(profile)->event_router())
377 return; 380 return;
378 381
379 profile->GetExtensionEventRouter()->DispatchEventToExtension( 382 extensions::ExtensionSystem::Get(profile)->event_router()->
380 extension_id, event_name, event_args.Pass(), profile, GURL(), 383 DispatchEventToExtension(extension_id, event_name, event_args.Pass(),
381 user_gesture); 384 profile, GURL(), user_gesture);
382 } 385 }
383 386
384 void BrowserEventRouter::DispatchEventsAcrossIncognito( 387 void BrowserEventRouter::DispatchEventsAcrossIncognito(
385 Profile* profile, 388 Profile* profile,
386 const char* event_name, 389 const char* event_name,
387 scoped_ptr<ListValue> event_args, 390 scoped_ptr<ListValue> event_args,
388 scoped_ptr<ListValue> cross_incognito_args) { 391 scoped_ptr<ListValue> cross_incognito_args) {
389 if (!profile_->IsSameProfile(profile) || !profile->GetExtensionEventRouter()) 392 if (!profile_->IsSameProfile(profile) ||
393 !extensions::ExtensionSystem::Get(profile)->event_router())
390 return; 394 return;
391 395
392 profile->GetExtensionEventRouter()->DispatchEventsToRenderersAcrossIncognito( 396 extensions::ExtensionSystem::Get(profile)->event_router()->
393 event_name, event_args.Pass(), profile, cross_incognito_args.Pass(), 397 DispatchEventsToRenderersAcrossIncognito(event_name, event_args.Pass(),
394 GURL()); 398 profile, cross_incognito_args.Pass(), GURL());
395 } 399 }
396 400
397 void BrowserEventRouter::DispatchSimpleBrowserEvent( 401 void BrowserEventRouter::DispatchSimpleBrowserEvent(
398 Profile* profile, const int window_id, const char* event_name) { 402 Profile* profile, const int window_id, const char* event_name) {
399 if (!profile_->IsSameProfile(profile)) 403 if (!profile_->IsSameProfile(profile))
400 return; 404 return;
401 405
402 scoped_ptr<ListValue> args(new ListValue()); 406 scoped_ptr<ListValue> args(new ListValue());
403 args->Append(Value::CreateIntegerValue(window_id)); 407 args->Append(Value::CreateIntegerValue(window_id));
404 408
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 601
598 DispatchEventToExtension(profile, 602 DispatchEventToExtension(profile,
599 extension_action.extension_id(), 603 extension_action.extension_id(),
600 event_name, 604 event_name,
601 args.Pass(), 605 args.Pass(),
602 EventRouter::USER_GESTURE_ENABLED); 606 EventRouter::USER_GESTURE_ENABLED);
603 } 607 }
604 } 608 }
605 609
606 } // namespace extensions 610 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/bluetooth_event_router.cc ('k') | chrome/browser/extensions/event_router_forwarder.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698