diff options
-rw-r--r-- | chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/api/runtime/runtime_api.cc | 186 | ||||
-rw-r--r-- | chrome/browser/extensions/api/runtime/runtime_api.h | 41 | ||||
-rw-r--r-- | chrome/chrome_browser_extensions.gypi | 1 | ||||
-rw-r--r-- | extensions/browser/DEPS | 2 | ||||
-rw-r--r-- | extensions/browser/api/runtime/runtime_event_router.cc | 165 | ||||
-rw-r--r-- | extensions/browser/api/runtime/runtime_event_router.h | 59 | ||||
-rw-r--r-- | extensions/browser/process_manager.cc | 5 | ||||
-rw-r--r-- | extensions/extensions.gyp | 2 |
9 files changed, 267 insertions, 196 deletions
diff --git a/chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc b/chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc index a488b51..371fc0a 100644 --- a/chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc +++ b/chrome/browser/chromeos/app_mode/kiosk_app_update_service.cc @@ -10,11 +10,11 @@ #include "chrome/browser/browser_process_platform_part_chromeos.h" #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" #include "chrome/browser/chromeos/system/automatic_reboot_manager.h" -#include "chrome/browser/extensions/api/runtime/runtime_api.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/profiles/profile.h" #include "components/keyed_service/content/browser_context_dependency_manager.h" +#include "extensions/browser/api/runtime/runtime_event_router.h" #include "extensions/browser/extension_system.h" #include "extensions/browser/extension_system_provider.h" #include "extensions/browser/extensions_browser_client.h" diff --git a/chrome/browser/extensions/api/runtime/runtime_api.cc b/chrome/browser/extensions/api/runtime/runtime_api.cc index 3545291..0a9c61b6 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.cc +++ b/chrome/browser/extensions/api/runtime/runtime_api.cc @@ -10,7 +10,6 @@ #include "base/logging.h" #include "base/memory/scoped_ptr.h" #include "base/values.h" -#include "chrome/browser/browser_process.h" #include "chrome/browser/chrome_notification_types.h" #include "chrome/browser/extensions/extension_service.h" #include "chrome/browser/extensions/updater/extension_updater.h" @@ -25,7 +24,7 @@ #include "content/public/browser/notification_service.h" #include "content/public/browser/render_process_host.h" #include "content/public/browser/render_view_host.h" -#include "extensions/browser/event_router.h" +#include "extensions/browser/api/runtime/runtime_event_router.h" #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" @@ -56,11 +55,6 @@ namespace { const char kNoBackgroundPageError[] = "You do not have a background page."; const char kPageLoadError[] = "Background page failed to load."; -const char kInstallReason[] = "reason"; -const char kInstallReasonChromeUpdate[] = "chrome_update"; -const char kInstallReasonUpdate[] = "update"; -const char kInstallReasonInstall[] = "install"; -const char kInstallPreviousVersion[] = "previousVersion"; const char kInvalidUrlError[] = "Invalid URL."; const char kUpdatesDisabledError[] = "Autoupdate is not enabled."; const char kUpdateFound[] = "update_available"; @@ -75,49 +69,6 @@ const char kUninstallUrl[] = "uninstall_url"; // with the equivalent Pepper API. const char kPackageDirectoryPath[] = "crxfs"; -void DispatchOnStartupEventImpl(BrowserContext* browser_context, - const std::string& extension_id, - bool first_call, - ExtensionHost* host) { - // A NULL host from the LazyBackgroundTaskQueue means the page failed to - // load. Give up. - if (!host && !first_call) - return; - - // Don't send onStartup events to incognito browser contexts. - if (browser_context->IsOffTheRecord()) - return; - - if (ExtensionsBrowserClient::Get()->IsShuttingDown() || - !ExtensionsBrowserClient::Get()->IsValidContext(browser_context)) - return; - ExtensionSystem* system = ExtensionSystem::Get(browser_context); - if (!system) - return; - - // If this is a persistent background page, we want to wait for it to load - // (it might not be ready, since this is startup). But only enqueue once. - // If it fails to load the first time, don't bother trying again. - const Extension* extension = - ExtensionRegistry::Get(browser_context)->enabled_extensions().GetByID( - extension_id); - if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && - first_call && - system->lazy_background_task_queue()-> - ShouldEnqueueTask(browser_context, extension)) { - system->lazy_background_task_queue()->AddPendingTask( - browser_context, extension_id, - base::Bind(&DispatchOnStartupEventImpl, - browser_context, extension_id, false)); - return; - } - - scoped_ptr<base::ListValue> event_args(new base::ListValue()); - scoped_ptr<Event> event(new Event(runtime::OnStartup::kEventName, - event_args.Pass())); - system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); -} - void SetUninstallURL(ExtensionPrefs* prefs, const std::string& extension_id, const std::string& url_string) { @@ -147,7 +98,7 @@ BrowserContextKeyedAPIFactory<RuntimeAPI>* RuntimeAPI::GetFactoryInstance() { return g_factory.Pointer(); } -RuntimeAPI::RuntimeAPI(content::BrowserContext* context) +RuntimeAPI::RuntimeAPI(BrowserContext* context) : browser_context_(context), dispatch_chrome_updated_event_(false), registered_for_updates_(false) { @@ -236,9 +187,9 @@ void RuntimeAPI::OnExtensionInstalled(const Extension* extension) { return; // Get the previous version to check if this is an upgrade. - ExtensionService* service = ExtensionSystem::Get( - browser_context_)->extension_service(); - const Extension* old = service->GetExtensionById(extension->id(), true); + const Extension* old = + ExtensionRegistry::Get(browser_context_) + ->GetExtensionById(extension->id(), ExtensionRegistry::EVERYTHING); Version old_version; if (old) old_version = *old->version(); @@ -261,110 +212,12 @@ void RuntimeAPI::OnExtensionUninstalled(const Extension* extension) { return; Profile* profile = Profile::FromBrowserContext(browser_context_); - RuntimeEventRouter::OnExtensionUninstalled(profile, extension->id()); -} - -void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) { - Profile* profile = Profile::FromBrowserContext(browser_context_); - RuntimeEventRouter::DispatchOnUpdateAvailableEvent( - profile, extension->id(), extension->manifest()->value()); -} - -void RuntimeAPI::OnChromeUpdateAvailable() { - Profile* profile = Profile::FromBrowserContext(browser_context_); - RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(profile); -} - -/////////////////////////////////////////////////////////////////////////////// - -// static -void RuntimeEventRouter::DispatchOnStartupEvent( - content::BrowserContext* context, const std::string& extension_id) { - DispatchOnStartupEventImpl(context, extension_id, true, NULL); -} - -// static -void RuntimeEventRouter::DispatchOnInstalledEvent( - content::BrowserContext* context, - const std::string& extension_id, - const Version& old_version, - bool chrome_updated) { - if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) - return; - ExtensionSystem* system = ExtensionSystem::Get(context); - if (!system) - return; - - scoped_ptr<base::ListValue> event_args(new base::ListValue()); - base::DictionaryValue* info = new base::DictionaryValue(); - event_args->Append(info); - if (old_version.IsValid()) { - info->SetString(kInstallReason, kInstallReasonUpdate); - info->SetString(kInstallPreviousVersion, old_version.GetString()); - } else if (chrome_updated) { - info->SetString(kInstallReason, kInstallReasonChromeUpdate); - } else { - info->SetString(kInstallReason, kInstallReasonInstall); - } - DCHECK(system->event_router()); - scoped_ptr<Event> event(new Event(runtime::OnInstalled::kEventName, - event_args.Pass())); - system->event_router()->DispatchEventWithLazyListener(extension_id, - event.Pass()); + ShowUninstallURL(profile, extension->id()); } // static -void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( - Profile* profile, - const std::string& extension_id, - const base::DictionaryValue* manifest) { - ExtensionSystem* system = ExtensionSystem::Get(profile); - if (!system) - return; - - scoped_ptr<base::ListValue> args(new base::ListValue); - args->Append(manifest->DeepCopy()); - DCHECK(system->event_router()); - scoped_ptr<Event> event(new Event(runtime::OnUpdateAvailable::kEventName, - args.Pass())); - system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); -} - -// static -void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent( - Profile* profile) { - ExtensionSystem* system = ExtensionSystem::Get(profile); - if (!system) - return; - - scoped_ptr<base::ListValue> args(new base::ListValue); - DCHECK(system->event_router()); - scoped_ptr<Event> event(new Event( - runtime::OnBrowserUpdateAvailable::kEventName, args.Pass())); - system->event_router()->BroadcastEvent(event.Pass()); -} - -// static -void RuntimeEventRouter::DispatchOnRestartRequiredEvent( - Profile* profile, - const std::string& app_id, - api::runtime::OnRestartRequired::Reason reason) { - ExtensionSystem* system = ExtensionSystem::Get(profile); - if (!system) - return; - - scoped_ptr<Event> event( - new Event(runtime::OnRestartRequired::kEventName, - api::runtime::OnRestartRequired::Create(reason))); - - DCHECK(system->event_router()); - system->event_router()->DispatchEventToExtension(app_id, event.Pass()); -} - -// static -void RuntimeEventRouter::OnExtensionUninstalled( - Profile* profile, - const std::string& extension_id) { +void RuntimeAPI::ShowUninstallURL(Profile* profile, + const std::string& extension_id) { #if defined(ENABLE_EXTENSIONS) GURL uninstall_url(GetUninstallURL(ExtensionPrefs::Get(profile), extension_id)); @@ -386,6 +239,17 @@ void RuntimeEventRouter::OnExtensionUninstalled( #endif // defined(ENABLE_EXTENSIONS) } +void RuntimeAPI::OnAppUpdateAvailable(const Extension* extension) { + RuntimeEventRouter::DispatchOnUpdateAvailableEvent( + browser_context_, extension->id(), extension->manifest()->value()); +} + +void RuntimeAPI::OnChromeUpdateAvailable() { + RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent(browser_context_); +} + +/////////////////////////////////////////////////////////////////////////////// + bool RuntimeGetBackgroundPageFunction::RunImpl() { ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); ExtensionHost* host = system->process_manager()-> @@ -415,6 +279,8 @@ void RuntimeGetBackgroundPageFunction::OnPageLoaded(ExtensionHost* host) { } } +////////////////////////////////////////////////////////////////////////////// + bool RuntimeSetUninstallURLFunction::RunImpl() { std::string url_string; EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &url_string)); @@ -430,6 +296,8 @@ bool RuntimeSetUninstallURLFunction::RunImpl() { return true; } +////////////////////////////////////////////////////////////////////////////// + bool RuntimeReloadFunction::RunImpl() { // We can't call ReloadExtension directly, since when this method finishes // it tries to decrease the reference count for the extension, which fails @@ -442,6 +310,8 @@ bool RuntimeReloadFunction::RunImpl() { return true; } +////////////////////////////////////////////////////////////////////////////// + RuntimeRequestUpdateCheckFunction::RuntimeRequestUpdateCheckFunction() { registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UPDATE_FOUND, content::NotificationService::AllSources()); @@ -514,6 +384,8 @@ void RuntimeRequestUpdateCheckFunction::ReplyUpdateFound( SendResponse(true); } +////////////////////////////////////////////////////////////////////////////// + bool RuntimeRestartFunction::RunImpl() { #if defined(OS_CHROMEOS) if (chromeos::UserManager::Get()->IsLoggedInAsKioskApp()) { @@ -527,6 +399,8 @@ bool RuntimeRestartFunction::RunImpl() { return false; } +////////////////////////////////////////////////////////////////////////////// + bool RuntimeGetPlatformInfoFunction::RunImpl() { GetPlatformInfo::Results::PlatformInfo info; @@ -576,6 +450,8 @@ bool RuntimeGetPlatformInfoFunction::RunImpl() { return true; } +////////////////////////////////////////////////////////////////////////////// + bool RuntimeGetPackageDirectoryEntryFunction::RunImpl() { fileapi::IsolatedContext* isolated_context = fileapi::IsolatedContext::GetInstance(); diff --git a/chrome/browser/extensions/api/runtime/runtime_api.h b/chrome/browser/extensions/api/runtime/runtime_api.h index 6e65e1b..463fab0 100644 --- a/chrome/browser/extensions/api/runtime/runtime_api.h +++ b/chrome/browser/extensions/api/runtime/runtime_api.h @@ -8,7 +8,6 @@ #include <string> #include "chrome/browser/extensions/chrome_extension_function.h" -#include "chrome/common/extensions/api/runtime.h" #include "content/public/browser/notification_observer.h" #include "content/public/browser/notification_registrar.h" #include "extensions/browser/browser_context_keyed_api_factory.h" @@ -16,10 +15,6 @@ class Profile; -namespace base { -class Version; -} - namespace content { class BrowserContext; } @@ -53,6 +48,10 @@ class RuntimeAPI : public BrowserContextKeyedAPI, void OnExtensionInstalled(const Extension* extension); void OnExtensionUninstalled(const Extension* extension); + // Shows the uninstall URL in a new tab. + static void ShowUninstallURL(Profile* profile, + const std::string& extension_id); + // BrowserContextKeyedAPI implementation: static const char* service_name() { return "RuntimeAPI"; } static const bool kServiceRedirectedInIncognito = true; @@ -77,38 +76,6 @@ class RuntimeAPI : public BrowserContextKeyedAPI, DISALLOW_COPY_AND_ASSIGN(RuntimeAPI); }; -class RuntimeEventRouter { - public: - // Dispatches the onStartup event to all currently-loaded extensions. - static void DispatchOnStartupEvent(content::BrowserContext* context, - const std::string& extension_id); - - // Dispatches the onInstalled event to the given extension. - static void DispatchOnInstalledEvent(content::BrowserContext* context, - const std::string& extension_id, - const base::Version& old_version, - bool chrome_updated); - - // Dispatches the onUpdateAvailable event to the given extension. - static void DispatchOnUpdateAvailableEvent( - Profile* profile, - const std::string& extension_id, - const base::DictionaryValue* manifest); - - // Dispatches the onBrowserUpdateAvailable event to all extensions. - static void DispatchOnBrowserUpdateAvailableEvent(Profile* profile); - - // Dispatches the onRestartRequired event to the given app. - static void DispatchOnRestartRequiredEvent( - Profile* profile, - const std::string& app_id, - api::runtime::OnRestartRequired::Reason reason); - - // Does any work needed at extension uninstall (e.g. load uninstall url). - static void OnExtensionUninstalled(Profile* profile, - const std::string& extension_id); -}; - class RuntimeGetBackgroundPageFunction : public ChromeAsyncExtensionFunction { public: DECLARE_EXTENSION_FUNCTION("runtime.getBackgroundPage", diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi index 329b322..8843bcf 100644 --- a/chrome/chrome_browser_extensions.gypi +++ b/chrome/chrome_browser_extensions.gypi @@ -969,7 +969,6 @@ ['include', '^browser/extensions/api/preference/preference_api.cc'], ['include', '^browser/extensions/api/proxy/proxy_api.cc'], ['include', '^browser/extensions/api/proxy/proxy_api_constants.cc'], - ['include', '^browser/extensions/api/runtime/runtime_api.cc'], ['include', '^browser/extensions/api/tabs/tabs_constants.cc'], ['include', '^browser/extensions/api/web_navigation/frame_navigation_state.cc'], ['include', '^browser/extensions/api/web_navigation/web_navigation_api.cc'], diff --git a/extensions/browser/DEPS b/extensions/browser/DEPS index 3ff0288..22cf083 100644 --- a/extensions/browser/DEPS +++ b/extensions/browser/DEPS @@ -15,8 +15,8 @@ include_rules = [ "+chrome/browser/chrome_notification_types.h", "+chrome/browser/extensions/api/content_settings/content_settings_store.h", "+chrome/browser/extensions/api/preference/preference_api.h", - "+chrome/browser/extensions/api/runtime/runtime_api.h", "+chrome/browser/renderer_host/chrome_render_message_filter.h", + "+chrome/common/extensions/api/runtime.h", "+chrome/common/extensions/api/sockets/sockets_manifest_data.h", "+chrome/common/extensions/features/feature_channel.h", "+grit/generated_resources.h", diff --git a/extensions/browser/api/runtime/runtime_event_router.cc b/extensions/browser/api/runtime/runtime_event_router.cc new file mode 100644 index 0000000..e63ef2d --- /dev/null +++ b/extensions/browser/api/runtime/runtime_event_router.cc @@ -0,0 +1,165 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "extensions/browser/api/runtime/runtime_event_router.h" + +#include "base/bind.h" +#include "base/memory/scoped_ptr.h" +#include "base/values.h" +#include "base/version.h" +#include "content/public/browser/browser_context.h" +#include "extensions/browser/event_router.h" +#include "extensions/browser/extension_registry.h" +#include "extensions/browser/extension_system.h" +#include "extensions/browser/extensions_browser_client.h" +#include "extensions/browser/lazy_background_task_queue.h" +#include "extensions/common/manifest_handlers/background_info.h" + +using content::BrowserContext; + +namespace extensions { + +namespace runtime = api::runtime; + +namespace { + +const char kInstallReason[] = "reason"; +const char kInstallReasonChromeUpdate[] = "chrome_update"; +const char kInstallReasonUpdate[] = "update"; +const char kInstallReasonInstall[] = "install"; +const char kInstallPreviousVersion[] = "previousVersion"; + +// Dispatches the onStartup event. May do so by posting a task if the extension +// background page has not yet loaded. +void DispatchOnStartupEventImpl(BrowserContext* browser_context, + const std::string& extension_id, + bool first_call, + ExtensionHost* host) { + // A NULL host from the LazyBackgroundTaskQueue means the page failed to + // load. Give up. + if (!host && !first_call) + return; + + // Don't send onStartup events to incognito browser contexts. + if (browser_context->IsOffTheRecord()) + return; + + if (ExtensionsBrowserClient::Get()->IsShuttingDown() || + !ExtensionsBrowserClient::Get()->IsValidContext(browser_context)) + return; + ExtensionSystem* system = ExtensionSystem::Get(browser_context); + if (!system) + return; + + // If this is a persistent background page, we want to wait for it to load + // (it might not be ready, since this is startup). But only enqueue once. + // If it fails to load the first time, don't bother trying again. + const Extension* extension = + ExtensionRegistry::Get(browser_context) + ->GetExtensionById(extension_id, ExtensionRegistry::ENABLED); + LazyBackgroundTaskQueue* queue = system->lazy_background_task_queue(); + if (extension && BackgroundInfo::HasPersistentBackgroundPage(extension) && + first_call && queue->ShouldEnqueueTask(browser_context, extension)) { + queue->AddPendingTask( + browser_context, + extension_id, + base::Bind( + &DispatchOnStartupEventImpl, browser_context, extension_id, false)); + return; + } + + scoped_ptr<base::ListValue> event_args(new base::ListValue()); + scoped_ptr<Event> event( + new Event(runtime::OnStartup::kEventName, event_args.Pass())); + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); +} + +} // namespace + +// static +void RuntimeEventRouter::DispatchOnStartupEvent( + BrowserContext* context, + const std::string& extension_id) { + DispatchOnStartupEventImpl(context, extension_id, true, NULL); +} + +// static +void RuntimeEventRouter::DispatchOnInstalledEvent( + BrowserContext* context, + const std::string& extension_id, + const base::Version& old_version, + bool chrome_updated) { + if (!ExtensionsBrowserClient::Get()->IsValidContext(context)) + return; + ExtensionSystem* system = ExtensionSystem::Get(context); + if (!system) + return; + + scoped_ptr<base::ListValue> event_args(new base::ListValue()); + base::DictionaryValue* info = new base::DictionaryValue(); + event_args->Append(info); + if (old_version.IsValid()) { + info->SetString(kInstallReason, kInstallReasonUpdate); + info->SetString(kInstallPreviousVersion, old_version.GetString()); + } else if (chrome_updated) { + info->SetString(kInstallReason, kInstallReasonChromeUpdate); + } else { + info->SetString(kInstallReason, kInstallReasonInstall); + } + DCHECK(system->event_router()); + scoped_ptr<Event> event( + new Event(runtime::OnInstalled::kEventName, event_args.Pass())); + system->event_router()->DispatchEventWithLazyListener(extension_id, + event.Pass()); +} + +// static +void RuntimeEventRouter::DispatchOnUpdateAvailableEvent( + BrowserContext* context, + const std::string& extension_id, + const base::DictionaryValue* manifest) { + ExtensionSystem* system = ExtensionSystem::Get(context); + if (!system) + return; + + scoped_ptr<base::ListValue> args(new base::ListValue); + args->Append(manifest->DeepCopy()); + DCHECK(system->event_router()); + scoped_ptr<Event> event( + new Event(runtime::OnUpdateAvailable::kEventName, args.Pass())); + system->event_router()->DispatchEventToExtension(extension_id, event.Pass()); +} + +// static +void RuntimeEventRouter::DispatchOnBrowserUpdateAvailableEvent( + BrowserContext* context) { + ExtensionSystem* system = ExtensionSystem::Get(context); + if (!system) + return; + + scoped_ptr<base::ListValue> args(new base::ListValue); + DCHECK(system->event_router()); + scoped_ptr<Event> event( + new Event(runtime::OnBrowserUpdateAvailable::kEventName, args.Pass())); + system->event_router()->BroadcastEvent(event.Pass()); +} + +// static +void RuntimeEventRouter::DispatchOnRestartRequiredEvent( + BrowserContext* context, + const std::string& app_id, + api::runtime::OnRestartRequired::Reason reason) { + ExtensionSystem* system = ExtensionSystem::Get(context); + if (!system) + return; + + scoped_ptr<Event> event( + new Event(runtime::OnRestartRequired::kEventName, + api::runtime::OnRestartRequired::Create(reason))); + + DCHECK(system->event_router()); + system->event_router()->DispatchEventToExtension(app_id, event.Pass()); +} + +} // namespace extensions diff --git a/extensions/browser/api/runtime/runtime_event_router.h b/extensions/browser/api/runtime/runtime_event_router.h new file mode 100644 index 0000000..7808cff --- /dev/null +++ b/extensions/browser/api/runtime/runtime_event_router.h @@ -0,0 +1,59 @@ +// Copyright 2014 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_EVENT_ROUTER_H_ +#define EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_EVENT_ROUTER_H_ + +#include <string> + +#include "base/macros.h" +#include "chrome/common/extensions/api/runtime.h" + +namespace base { +class DictionaryValue; +class Version; +} + +namespace content { +class BrowserContext; +}; + +namespace extensions { + +// Dispatches events to extensions such as onStartup, onInstalled, etc. +class RuntimeEventRouter { + public: + // Dispatches the onStartup event to all currently-loaded extensions. + static void DispatchOnStartupEvent(content::BrowserContext* context, + const std::string& extension_id); + + // Dispatches the onInstalled event to the given extension. + static void DispatchOnInstalledEvent(content::BrowserContext* context, + const std::string& extension_id, + const base::Version& old_version, + bool chrome_updated); + + // Dispatches the onUpdateAvailable event to the given extension. + static void DispatchOnUpdateAvailableEvent( + content::BrowserContext* context, + const std::string& extension_id, + const base::DictionaryValue* manifest); + + // Dispatches the onBrowserUpdateAvailable event to all extensions. + static void DispatchOnBrowserUpdateAvailableEvent( + content::BrowserContext* context); + + // Dispatches the onRestartRequired event to the given app. + static void DispatchOnRestartRequiredEvent( + content::BrowserContext* context, + const std::string& app_id, + api::runtime::OnRestartRequired::Reason reason); + + private: + DISALLOW_IMPLICIT_CONSTRUCTORS(RuntimeEventRouter); +}; + +} // namespace extensions + +#endif // EXTENSIONS_BROWSER_API_RUNTIME_RUNTIME_EVENT_ROUTER_H_ diff --git a/extensions/browser/process_manager.cc b/extensions/browser/process_manager.cc index 2146969..d2c921b 100644 --- a/extensions/browser/process_manager.cc +++ b/extensions/browser/process_manager.cc @@ -14,7 +14,6 @@ #include "base/strings/string_number_conversions.h" #include "base/time/time.h" #include "chrome/browser/chrome_notification_types.h" -#include "chrome/browser/extensions/api/runtime/runtime_api.h" #include "content/public/browser/browser_context.h" #include "content/public/browser/browser_thread.h" #include "content/public/browser/devtools_agent_host.h" @@ -29,6 +28,7 @@ #include "content/public/browser/web_contents_observer.h" #include "content/public/browser/web_contents_user_data.h" #include "content/public/common/renderer_preferences.h" +#include "extensions/browser/api/runtime/runtime_event_router.h" #include "extensions/browser/extension_host.h" #include "extensions/browser/extension_registry.h" #include "extensions/browser/extension_system.h" @@ -771,8 +771,11 @@ void ProcessManager::CreateBackgroundHostsForProfileStartup() { ++extension) { CreateBackgroundHostForExtensionLoad(this, extension->get()); +#if defined(ENABLE_EXTENSIONS) + // Android cannot call API implementations. RuntimeEventRouter::DispatchOnStartupEvent(GetBrowserContext(), (*extension)->id()); +#endif } startup_background_hosts_created_ = true; diff --git a/extensions/extensions.gyp b/extensions/extensions.gyp index 3319a5c..f0f706f 100644 --- a/extensions/extensions.gyp +++ b/extensions/extensions.gyp @@ -206,6 +206,8 @@ 'browser/api/dns/host_resolver_wrapper.h', 'browser/api/extensions_api_client.cc', 'browser/api/extensions_api_client.h', + 'browser/api/runtime/runtime_event_router.cc', + 'browser/api/runtime/runtime_event_router.h', 'browser/api/socket/socket.cc', 'browser/api/socket/socket.h', 'browser/api/socket/socket_api.cc', |