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

Side by Side 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: address comments 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" 5 #include "chrome/browser/ui/app_list/app_list_syncable_service.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h"
7 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/ui/app_list/app_list_service.h" 11 #include "chrome/browser/ui/app_list/app_list_service.h"
9 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" 12 #include "chrome/browser/ui/app_list/extension_app_model_builder.h"
10 #include "chrome/browser/ui/host_desktop.h" 13 #include "chrome/browser/ui/host_desktop.h"
14 #include "content/public/browser/notification_source.h"
11 #include "ui/app_list/app_list_model.h" 15 #include "ui/app_list/app_list_model.h"
12 16
13 namespace app_list { 17 namespace app_list {
14 18
15 AppListSyncableService::AppListSyncableService(Profile* profile) 19 AppListSyncableService::AppListSyncableService(
20 Profile* profile,
21 extensions::ExtensionSystem* extension_system)
benwells 2013/11/21 09:48:11 nit: can you make this an ExtensionService? Extens
tapted 2013/11/21 10:39:03 Done. (I felt too evil passing in something that c
16 : profile_(profile), 22 : profile_(profile),
17 model_(new AppListModel) { 23 model_(new AppListModel) {
24 ExtensionService* extension_service = extension_system->extension_service();
25 if (extension_service && extension_service->is_ready()) {
26 BuildModel();
27 return;
28 }
29
30 // The extensions for this profile have not yet all been loaded.
31 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY,
32 content::Source<Profile>(profile));
33 }
34
35 AppListSyncableService::~AppListSyncableService() {
36 }
37
38 void AppListSyncableService::BuildModel() {
18 // For now, use the AppListControllerDelegate associated with the native 39 // For now, use the AppListControllerDelegate associated with the native
19 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller 40 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller
20 // dependency and move the dependent methods from AppListControllerDelegate 41 // dependency and move the dependent methods from AppListControllerDelegate
21 // to an extension service delegate associated with this class. 42 // to an extension service delegate associated with this class.
22 AppListControllerDelegate* controller = NULL; 43 AppListControllerDelegate* controller = NULL;
23 AppListService* service = 44 AppListService* service =
24 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); 45 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE);
25 if (service) 46 if (service)
26 controller = service->GetControllerDelegate(); 47 controller = service->GetControllerDelegate();
27 apps_builder_.reset( 48 apps_builder_.reset(
28 new ExtensionAppModelBuilder(profile_, model_.get(), controller)); 49 new ExtensionAppModelBuilder(profile_, model_.get(), controller));
29 DCHECK(profile_); 50 DCHECK(profile_);
30 VLOG(1) << "AppListSyncableService Created."; 51 VLOG(1) << "AppListSyncableService Created.";
31 } 52 }
32 53
33 AppListSyncableService::~AppListSyncableService() { 54 void AppListSyncableService::Observe(
55 int type,
56 const content::NotificationSource& source,
57 const content::NotificationDetails& details) {
58 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type);
59 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr());
60 registrar_.RemoveAll();
61 BuildModel();
34 } 62 }
35 63
36 } // namespace app_list 64 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698