summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 13:17:37 +0000
committermirandac@chromium.org <mirandac@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-26 13:17:37 +0000
commitd912680227118548244bf2d51b90256ad42a81bd (patch)
tree715d9f0be7a4e2efef16833d2d7083b256abf98d
parentc95c886977c189d7b7fc6578beae33d779fe3155 (diff)
downloadchromium_src-d912680227118548244bf2d51b90256ad42a81bd.zip
chromium_src-d912680227118548244bf2d51b90256ad42a81bd.tar.gz
chromium_src-d912680227118548244bf2d51b90256ad42a81bd.tar.bz2
Do not initialize event routers in the Profile Import process.
BUG=90909 TEST=launch organic browser with empty fresh profile; no message about a bad profile seen before search engine dialog. Review URL: http://codereview.chromium.org/7717025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98418 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser_main.cc9
-rw-r--r--chrome/browser/extensions/extension_service.cc11
-rw-r--r--chrome/browser/extensions/extension_service.h3
-rw-r--r--chrome/browser/profiles/profile_impl.cc13
-rw-r--r--chrome/browser/profiles/profile_manager.cc16
-rw-r--r--chrome/browser/profiles/profile_manager.h10
-rw-r--r--chrome/common/chrome_notification_types.h3
7 files changed, 62 insertions, 3 deletions
diff --git a/chrome/browser/browser_main.cc b/chrome/browser/browser_main.cc
index 34a18d7..8874c9b 100644
--- a/chrome/browser/browser_main.cc
+++ b/chrome/browser/browser_main.cc
@@ -1709,6 +1709,12 @@ int BrowserMain(const MainFunctionParams& parameters) {
}
#endif
+ if (is_first_run) {
+ // Warn the ProfileManager that an import process will run, possibly
+ // locking the WebDataService directory of the next Profile created.
+ g_browser_process->profile_manager()->SetWillImport();
+ }
+
Profile* profile = CreateProfile(parameters, user_data_dir,
parsed_command_line);
if (!profile)
@@ -1812,7 +1818,8 @@ int BrowserMain(const MainFunctionParams& parameters) {
} // if (!first_run_ui_bypass)
Browser::SetNewHomePagePrefs(user_prefs);
- }
+ g_browser_process->profile_manager()->OnImportFinished(profile);
+ } // if (is_first_run)
// Sets things up so that if we crash from this point on, a dialog will
// popup asking the user to restart chrome. It is done this late to avoid
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 61385ed..c5fe857 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -689,6 +689,11 @@ ExtensionService::~ExtensionService() {
}
}
+void ExtensionService::InitEventRoutersAfterImport() {
+ registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED,
+ Source<Profile>(profile_));
+}
+
void ExtensionService::InitEventRouters() {
if (event_routers_initialized_)
return;
@@ -2718,6 +2723,12 @@ void ExtensionService::Observe(int type,
}
break;
}
+ case chrome::NOTIFICATION_IMPORT_FINISHED: {
+ registrar_.Remove(this, chrome::NOTIFICATION_IMPORT_FINISHED,
+ Source<Profile>(profile_));
+ InitEventRouters();
+ break;
+ }
default:
NOTREACHED() << "Unexpected notification type.";
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index c8e98bb..c25c976 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -243,6 +243,9 @@ class ExtensionService
// Initialize and start all installed extensions.
void Init();
+ // Initialize the event routers after import has finished.
+ void InitEventRoutersAfterImport();
+
// Start up the extension event routers.
void InitEventRouters();
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index d33e81a..17bc4a2 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -506,7 +506,18 @@ void ProfileImpl::InitExtensions(bool extensions_enabled) {
// initialized (see issue 40144). Now that bookmarks aren't imported and
// the event routers need to be initialized for every profile individually,
// initialize them with the extension service.
- extension_service_->InitEventRouters();
+ // If this profile is being created as part of the import process, never
+ // initialize the event routers. If import is going to run in a separate
+ // process (the profile itself is on the main process), wait for import to
+ // finish before initializing the routers.
+ if (!command_line->HasSwitch(switches::kImport) &&
+ !command_line->HasSwitch(switches::kImportFromFile)) {
+ if (g_browser_process->profile_manager()->will_import()) {
+ extension_service_->InitEventRoutersAfterImport();
+ } else {
+ extension_service_->InitEventRouters();
+ }
+ }
}
void ProfileImpl::RegisterComponentExtensions() {
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index a1d7922..9e77534 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -103,7 +103,8 @@ Profile* ProfileManager::GetLastUsedProfile() {
return profile_manager->GetLastUsedProfile(user_data_dir);
}
-ProfileManager::ProfileManager() : logged_in_(false) {
+ProfileManager::ProfileManager() : logged_in_(false),
+ will_import_(false) {
BrowserList::AddObserver(this);
#if defined(OS_CHROMEOS)
registrar_.Add(
@@ -340,6 +341,19 @@ void ProfileManager::Observe(
#endif
}
+void ProfileManager::SetWillImport() {
+ will_import_ = true;
+}
+
+void ProfileManager::OnImportFinished(Profile* profile) {
+ will_import_ = false;
+ DCHECK(profile);
+ NotificationService::current()->Notify(
+ chrome::NOTIFICATION_IMPORT_FINISHED,
+ Source<Profile>(profile),
+ NotificationService::NoDetails());
+}
+
void ProfileManager::OnBrowserAdded(const Browser* browser) {}
void ProfileManager::OnBrowserRemoved(const Browser* browser) {}
diff --git a/chrome/browser/profiles/profile_manager.h b/chrome/browser/profiles/profile_manager.h
index ad3dc46..258f541 100644
--- a/chrome/browser/profiles/profile_manager.h
+++ b/chrome/browser/profiles/profile_manager.h
@@ -126,6 +126,13 @@ class ProfileManager : public base::NonThreadSafe,
virtual void OnBrowserRemoved(const Browser* browser);
virtual void OnBrowserSetLastActive(const Browser* browser);
+ // Indicate that an import process will run for the next created Profile.
+ void SetWillImport();
+ bool will_import() { return will_import_; }
+
+ // Indicate that the import process for |profile| has completed.
+ void OnImportFinished(Profile* profile);
+
// ------------------ static utility functions -------------------
// Returns the path to the default profile directory, based on the given
@@ -225,6 +232,9 @@ class ProfileManager : public base::NonThreadSafe,
// default.
bool logged_in_;
+ // True if an import process will be run.
+ bool will_import_;
+
// Maps profile path to ProfileInfo (if profile has been created). Use
// RegisterProfile() to add into this map.
typedef std::map<FilePath, linked_ptr<ProfileInfo> > ProfilesInfoMap;
diff --git a/chrome/common/chrome_notification_types.h b/chrome/common/chrome_notification_types.h
index 0f3dc08..20142c0 100644
--- a/chrome/common/chrome_notification_types.h
+++ b/chrome/common/chrome_notification_types.h
@@ -835,6 +835,9 @@ enum {
// |webkit_glue::PasswordForm|s that were affected.
NOTIFICATION_LOGINS_CHANGED,
+ // Sent when an import process has ended.
+ NOTIFICATION_IMPORT_FINISHED,
+
// Sent when the applications in the NTP app launcher have been reordered.
NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,