summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/browser_main.cc3
-rw-r--r--chrome/browser/chromeos/login/login_utils.cc9
-rw-r--r--chrome/browser/extensions/extensions_service.cc7
-rw-r--r--chrome/browser/extensions/extensions_service.h3
4 files changed, 21 insertions, 1 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 7845098..7af8504 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1408,6 +1408,9 @@ int BrowserMain(const MainFunctionParams& parameters) {
metrics->StartExternalMetrics();
#endif
+ // Initialize extension event routers. Note that on Chrome OS, this will
+ // not succeed if the user has not logged in yet, in which case the
+ // event routers are initialized in LoginUtilsImpl::CompleteLogin instead.
if (profile->GetExtensionsService()) {
// This will initialize bookmarks. Call it after bookmark import is done.
// See issue 40144.
diff --git a/chrome/browser/chromeos/login/login_utils.cc b/chrome/browser/chromeos/login/login_utils.cc
index 2be1cde..234ed21 100644
--- a/chrome/browser/chromeos/login/login_utils.cc
+++ b/chrome/browser/chromeos/login/login_utils.cc
@@ -26,6 +26,7 @@
#include "chrome/browser/chromeos/login/parallel_authenticator.h"
#include "chrome/browser/chromeos/login/user_image_downloader.h"
#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/extensions/extensions_service.h"
#include "chrome/browser/net/gaia/token_service.h"
#include "chrome/browser/prefs/pref_member.h"
#include "chrome/browser/profile.h"
@@ -134,6 +135,14 @@ void LoginUtilsImpl::CompleteLogin(const std::string& username,
// will process the notification that the UserManager sends out.
Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
+ // Init extension event routers; this normally happens in browser_main
+ // but on Chrome OS it has to be deferred until the user finishes
+ // logging in and the profile is not OTR.
+ if (profile->GetExtensionsService() &&
+ profile->GetExtensionsService()->extensions_enabled()) {
+ profile->GetExtensionsService()->InitEventRouters();
+ }
+
logging::RedirectChromeLogging(
user_data_dir.Append(profile_manager->GetCurrentProfileDir()),
*(CommandLine::ForCurrentProcess()),
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 3c65525..acff4a6 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -566,7 +566,8 @@ ExtensionsService::ExtensionsService(Profile* profile,
show_extensions_prompts_(true),
ready_(false),
ALLOW_THIS_IN_INITIALIZER_LIST(toolbar_model_(this)),
- default_apps_(profile->GetPrefs()) {
+ default_apps_(profile->GetPrefs()),
+ event_routers_initialized_(false) {
// Figure out if extension installation should be enabled.
if (command_line->HasSwitch(switches::kDisableExtensions)) {
extensions_enabled_ = false;
@@ -612,6 +613,9 @@ ExtensionsService::~ExtensionsService() {
}
void ExtensionsService::InitEventRouters() {
+ if (event_routers_initialized_)
+ return;
+
ExtensionHistoryEventRouter::GetInstance()->ObserveProfile(profile_);
ExtensionAccessibilityEventRouter::GetInstance()->ObserveProfile(profile_);
ExtensionBrowserEventRouter::GetInstance()->Init(profile_);
@@ -620,6 +624,7 @@ void ExtensionsService::InitEventRouters() {
ExtensionCookiesEventRouter::GetInstance()->Init();
ExtensionManagementEventRouter::GetInstance()->Init();
ExtensionWebNavigationEventRouter::GetInstance()->Init();
+ event_routers_initialized_ = true;
}
void ExtensionsService::Init() {
diff --git a/chrome/browser/extensions/extensions_service.h b/chrome/browser/extensions/extensions_service.h
index 228dd48..bf398de 100644
--- a/chrome/browser/extensions/extensions_service.h
+++ b/chrome/browser/extensions/extensions_service.h
@@ -529,6 +529,9 @@ class ExtensionsService
// app launcher.
DefaultApps default_apps_;
+ // Flag to make sure event routers are only initialized once.
+ bool event_routers_initialized_;
+
FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest,
UpdatePendingExtensionAlreadyInstalled);
FRIEND_TEST_ALL_PREFIXES(ExtensionsServiceTest,