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

Unified Diff: chrome/browser/ui/app_list/app_list_syncable_service.cc

Issue 77773002: Ensure the ExtensionSystem is ready before initializing an ExtensionAppModelBuilder (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 7 years, 1 month 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
Index: chrome/browser/ui/app_list/app_list_syncable_service.cc
diff --git a/chrome/browser/ui/app_list/app_list_syncable_service.cc b/chrome/browser/ui/app_list/app_list_syncable_service.cc
index b62e7b223010496ad3bc7d02d747185d3dfe6f1d..447e76e5cf61de94d9d6a39452b74f5151ef49a6 100644
--- a/chrome/browser/ui/app_list/app_list_syncable_service.cc
+++ b/chrome/browser/ui/app_list/app_list_syncable_service.cc
@@ -4,10 +4,14 @@
#include "chrome/browser/ui/app_list/app_list_syncable_service.h"
+#include "chrome/browser/chrome_notification_types.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_service.h"
#include "chrome/browser/ui/app_list/extension_app_model_builder.h"
#include "chrome/browser/ui/host_desktop.h"
+#include "content/public/browser/notification_source.h"
#include "ui/app_list/app_list_model.h"
namespace app_list {
@@ -15,6 +19,22 @@ namespace app_list {
AppListSyncableService::AppListSyncableService(Profile* profile)
: profile_(profile),
model_(new AppListModel) {
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile)->extension_service();
benwells 2013/11/21 00:47:47 I prefer to pass this into the constructor, and ha
tapted 2013/11/21 03:29:56 Done modulo ExtensionSystem/ExtensionsService. (as
+ if (extension_service && extension_service->is_ready()) {
+ BuildModel();
+ return;
+ }
+
+ // The extensions for this profile have not yet all been loaded.
+ registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
+ content::Source<Profile>(profile));
+}
+
+AppListSyncableService::~AppListSyncableService() {
+}
+
+void AppListSyncableService::BuildModel() {
// For now, use the AppListControllerDelegate associated with the native
// desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller
// dependency and move the dependent methods from AppListControllerDelegate
@@ -30,7 +50,14 @@ AppListSyncableService::AppListSyncableService(Profile* profile)
VLOG(1) << "AppListSyncableService Created.";
}
-AppListSyncableService::~AppListSyncableService() {
+void AppListSyncableService::Observe(
+ int type,
+ const content::NotificationSource& source,
+ const content::NotificationDetails& details) {
+ DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type);
+ DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
+ registrar_.RemoveAll();
+ BuildModel();
}
} // namespace app_list

Powered by Google App Engine
This is Rietveld 408576698