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

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

Issue 10829186: Tabs API is usable without tabs permission. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: fixed sample extensions Created 8 years, 3 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 (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/event_router.h" 5 #include "chrome/browser/extensions/event_router.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/extensions/api/runtime/runtime_api.h" 12 #include "chrome/browser/extensions/api/runtime/runtime_api.h"
13 #include "chrome/browser/extensions/api/web_request/web_request_api.h" 13 #include "chrome/browser/extensions/api/web_request/web_request_api.h"
14 #include "chrome/browser/extensions/extension_devtools_manager.h" 14 #include "chrome/browser/extensions/extension_devtools_manager.h"
15 #include "chrome/browser/extensions/extension_host.h" 15 #include "chrome/browser/extensions/extension_host.h"
16 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/extensions/extension_process_manager.h" 17 #include "chrome/browser/extensions/extension_process_manager.h"
17 #include "chrome/browser/extensions/extension_processes_api.h" 18 #include "chrome/browser/extensions/extension_processes_api.h"
18 #include "chrome/browser/extensions/extension_processes_api_constants.h" 19 #include "chrome/browser/extensions/extension_processes_api_constants.h"
19 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
20 #include "chrome/browser/extensions/extension_system.h" 21 #include "chrome/browser/extensions/extension_system.h"
21 #include "chrome/browser/extensions/lazy_background_task_queue.h" 22 #include "chrome/browser/extensions/lazy_background_task_queue.h"
22 #include "chrome/browser/extensions/process_map.h" 23 #include "chrome/browser/extensions/process_map.h"
23 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
24 #include "chrome/browser/profiles/profile_manager.h" 25 #include "chrome/browser/profiles/profile_manager.h"
25 #include "chrome/common/chrome_notification_types.h" 26 #include "chrome/common/chrome_notification_types.h"
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 !process_map->Contains(extension->id(), process->GetID())) { 437 !process_map->Contains(extension->id(), process->GetID())) {
437 return; 438 return;
438 } 439 }
439 440
440 ListValue* event_args = NULL; 441 ListValue* event_args = NULL;
441 if (!CanDispatchEventToProfile(listener_profile, extension, 442 if (!CanDispatchEventToProfile(listener_profile, extension,
442 event, &event_args)) { 443 event, &event_args)) {
443 return; 444 return;
444 } 445 }
445 446
447 // If the "tabs" permission is not present, we need to strip the Tab argument
448 // of sensitive data.
449 ExtensionTabUtil::MaybeStripEventArgsOfSensitiveData(
Aaron Boodman 2012/08/30 05:45:48 Can we go back to only adding it in the first plac
chebert 2012/08/30 23:17:20 Done.
450 event->event_name, extension, event_args);
451
446 DispatchExtensionMessage(process, extension_id, 452 DispatchExtensionMessage(process, extension_id,
447 event->event_name, event_args, 453 event->event_name, event_args,
448 event->event_url, event->user_gesture, 454 event->event_url, event->user_gesture,
449 event->info); 455 event->info);
450 IncrementInFlightEvents(listener_profile, extension); 456 IncrementInFlightEvents(listener_profile, extension);
451 } 457 }
452 458
453 bool EventRouter::CanDispatchEventToProfile(Profile* profile, 459 bool EventRouter::CanDispatchEventToProfile(Profile* profile,
454 const Extension* extension, 460 const Extension* extension,
455 const linked_ptr<Event>& event, 461 const linked_ptr<Event>& event,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 if (host->extension() && host->extension()->has_lazy_background_page()) 522 if (host->extension() && host->extension()->has_lazy_background_page())
517 pm->DecrementLazyKeepaliveCount(host->extension()); 523 pm->DecrementLazyKeepaliveCount(host->extension());
518 } 524 }
519 525
520 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event, 526 void EventRouter::DispatchPendingEvent(const linked_ptr<Event>& event,
521 ExtensionHost* host) { 527 ExtensionHost* host) {
522 if (!host) 528 if (!host)
523 return; 529 return;
524 530
525 if (listeners_.HasProcessListener(host->render_process_host(), 531 if (listeners_.HasProcessListener(host->render_process_host(),
526 host->extension()->id())) 532 host->extension()->id())) {
527 DispatchEventToProcess(host->extension()->id(), 533 DispatchEventToProcess(host->extension()->id(),
528 host->render_process_host(), event); 534 host->render_process_host(), event);
535 }
529 } 536 }
530 537
531 void EventRouter::Observe(int type, 538 void EventRouter::Observe(int type,
532 const content::NotificationSource& source, 539 const content::NotificationSource& source,
533 const content::NotificationDetails& details) { 540 const content::NotificationDetails& details) {
534 switch (type) { 541 switch (type) {
535 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED: 542 case content::NOTIFICATION_RENDERER_PROCESS_TERMINATED:
536 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: { 543 case content::NOTIFICATION_RENDERER_PROCESS_CLOSED: {
537 content::RenderProcessHost* renderer = 544 content::RenderProcessHost* renderer =
538 content::Source<content::RenderProcessHost>(source).ptr(); 545 content::Source<content::RenderProcessHost>(source).ptr();
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 event_args(event_args.Pass()), 609 event_args(event_args.Pass()),
603 event_url(event_url), 610 event_url(event_url),
604 restrict_to_profile(restrict_to_profile), 611 restrict_to_profile(restrict_to_profile),
605 cross_incognito_args(NULL), 612 cross_incognito_args(NULL),
606 user_gesture(user_gesture), 613 user_gesture(user_gesture),
607 info(info) {} 614 info(info) {}
608 615
609 Event::~Event() {} 616 Event::~Event() {}
610 617
611 } // namespace extensions 618 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698