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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 9053005: Delay some extension startup until after first run import. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 9 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 5a58bd9c28fa91acad650f2b9c81359e7cf1a79c..30a3c43f4e616c2b9a5079f9f0a0a2167b5577d8 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -64,6 +64,7 @@
#include "chrome/browser/net/chrome_url_request_context.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/search_engines/template_url_service.h"
#include "chrome/browser/search_engines/template_url_service_factory.h"
#include "chrome/browser/sync/api/sync_change.h"
@@ -493,8 +494,26 @@ ExtensionService::~ExtensionService() {
}
void ExtensionService::InitEventRoutersAfterImport() {
- registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED,
- content::Source<Profile>(profile_));
+ RegisterForImportFinished();
+}
+
+void ExtensionService::RegisterForImportFinished() {
+ if (!registrar_.IsRegistered(this, chrome::NOTIFICATION_IMPORT_FINISHED,
+ content::Source<Profile>(profile_))) {
+ registrar_.Add(this, chrome::NOTIFICATION_IMPORT_FINISHED,
+ content::Source<Profile>(profile_));
+ }
+}
+
+void ExtensionService::InitAfterImport() {
+ CheckForExternalUpdates();
+
+ GarbageCollectExtensions();
+
+ // Idempotent, so although there is a possible race if the import
+ // process finished sometime in the middle of ProfileImpl::InitExtensions,
+ // it cannot happen twice.
+ InitEventRouters();
}
void ExtensionService::InitEventRouters() {
@@ -563,12 +582,17 @@ void ExtensionService::Init() {
// http://crbug.com/107636
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImport) &&
!CommandLine::ForCurrentProcess()->HasSwitch(switches::kImportFromFile)) {
- // TODO(erikkay) this should probably be deferred to a future point
- // rather than running immediately at startup.
- CheckForExternalUpdates();
+ if (g_browser_process->profile_manager() &&
+ g_browser_process->profile_manager()->will_import()) {
+ RegisterForImportFinished();
+ } else {
+ // TODO(erikkay) this should probably be deferred to a future point
+ // rather than running immediately at startup.
+ CheckForExternalUpdates();
- // TODO(erikkay) this should probably be deferred as well.
- GarbageCollectExtensions();
+ // TODO(erikkay) this should probably be deferred as well.
+ GarbageCollectExtensions();
+ }
}
}
@@ -2446,9 +2470,7 @@ void ExtensionService::Observe(int type,
break;
}
case chrome::NOTIFICATION_IMPORT_FINISHED: {
- registrar_.Remove(this, chrome::NOTIFICATION_IMPORT_FINISHED,
- content::Source<Profile>(profile_));
- InitEventRouters();
+ InitAfterImport();
break;
}
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698