diff options
author | tmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-08 03:02:13 +0000 |
---|---|---|
committer | tmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-01-08 03:02:13 +0000 |
commit | 8b44050162743d7456c596c210d36365001c73bc (patch) | |
tree | ee009c2e3941862349518795556c4193d945a689 /extensions | |
parent | a82d72a4a9740e36f377406e74896e7ee42db09f (diff) | |
download | chromium_src-8b44050162743d7456c596c210d36365001c73bc.zip chromium_src-8b44050162743d7456c596c210d36365001c73bc.tar.gz chromium_src-8b44050162743d7456c596c210d36365001c73bc.tar.bz2 |
Do not dispatch events to inactive ephemeral apps
With the exception of the chrome.app.runtime.onLaunched() event,
events will only be dispatched to ephemeral apps that are running.
This was implemented by adding a "can_load_ephemeral_apps" flag to
extensions::Event. Only events which enable this flag will have the
ability to load the event page of apps.
BUG=312460
TEST=browser_tests (EphemeralAppBrowserTest.*)
Review URL: https://codereview.chromium.org/118033002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243477 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/browser/event_router.cc | 18 | ||||
-rw-r--r-- | extensions/browser/event_router.h | 6 |
2 files changed, 21 insertions, 3 deletions
diff --git a/extensions/browser/event_router.cc b/extensions/browser/event_router.cc index 3c85b8b..7d1b811 100644 --- a/extensions/browser/event_router.cc +++ b/extensions/browser/event_router.cc @@ -576,6 +576,15 @@ bool EventRouter::MaybeLoadLazyBackgroundPageToDispatchEvent( BrowserContext* context, const Extension* extension, const linked_ptr<Event>& event) { + if (extension->is_ephemeral() && !event->can_load_ephemeral_apps) { + // Most events can only be dispatched to ephemeral apps that are already + // running. + ProcessManager* pm = + ExtensionSystem::GetForBrowserContext(context)->process_manager(); + if (!pm->GetBackgroundHostForExtension(extension->id())) + return false; + } + if (!CanDispatchEventToBrowserContext(context, extension, event)) return false; @@ -723,7 +732,8 @@ Event::Event(const std::string& event_name, : event_name(event_name), event_args(event_args.Pass()), restrict_to_browser_context(NULL), - user_gesture(EventRouter::USER_GESTURE_UNKNOWN) { + user_gesture(EventRouter::USER_GESTURE_UNKNOWN), + can_load_ephemeral_apps(false) { DCHECK(this->event_args.get()); } @@ -733,7 +743,8 @@ Event::Event(const std::string& event_name, : event_name(event_name), event_args(event_args.Pass()), restrict_to_browser_context(restrict_to_browser_context), - user_gesture(EventRouter::USER_GESTURE_UNKNOWN) { + user_gesture(EventRouter::USER_GESTURE_UNKNOWN), + can_load_ephemeral_apps(false) { DCHECK(this->event_args.get()); } @@ -748,7 +759,8 @@ Event::Event(const std::string& event_name, restrict_to_browser_context(restrict_to_browser_context), event_url(event_url), user_gesture(user_gesture), - filter_info(filter_info) { + filter_info(filter_info), + can_load_ephemeral_apps(false) { DCHECK(this->event_args.get()); } diff --git a/extensions/browser/event_router.h b/extensions/browser/event_router.h index 7052389..a42aa68 100644 --- a/extensions/browser/event_router.h +++ b/extensions/browser/event_router.h @@ -338,6 +338,12 @@ struct Event { // DispatchEvent, so callers don't need to worry about lifetime. WillDispatchCallback will_dispatch_callback; + // If true, this event will always be dispatched to ephemeral apps, regardless + // of whether they are running or inactive. Defaults to false. + // Most events can only be dispatched to ephemeral apps that are already + // running. Cached ephemeral apps are inactive until launched by the user. + bool can_load_ephemeral_apps; + Event(const std::string& event_name, scoped_ptr<base::ListValue> event_args); |