Chromium Code Reviews| OLD | NEW |
|---|---|
| 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(Profile* profile) |
| 16 : profile_(profile), | 20 : profile_(profile), |
| 17 model_(new AppListModel) { | 21 model_(new AppListModel) { |
| 22 ExtensionService* extension_service = | |
| 23 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
| |
| 24 if (extension_service && extension_service->is_ready()) { | |
| 25 BuildModel(); | |
| 26 return; | |
| 27 } | |
| 28 | |
| 29 // The extensions for this profile have not yet all been loaded. | |
| 30 registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, | |
| 31 content::Source<Profile>(profile)); | |
| 32 } | |
| 33 | |
| 34 AppListSyncableService::~AppListSyncableService() { | |
| 35 } | |
| 36 | |
| 37 void AppListSyncableService::BuildModel() { | |
| 18 // For now, use the AppListControllerDelegate associated with the native | 38 // For now, use the AppListControllerDelegate associated with the native |
| 19 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller | 39 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller |
| 20 // dependency and move the dependent methods from AppListControllerDelegate | 40 // dependency and move the dependent methods from AppListControllerDelegate |
| 21 // to an extension service delegate associated with this class. | 41 // to an extension service delegate associated with this class. |
| 22 AppListControllerDelegate* controller = NULL; | 42 AppListControllerDelegate* controller = NULL; |
| 23 AppListService* service = | 43 AppListService* service = |
| 24 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); | 44 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 25 if (service) | 45 if (service) |
| 26 controller = service->GetControllerDelegate(); | 46 controller = service->GetControllerDelegate(); |
| 27 apps_builder_.reset( | 47 apps_builder_.reset( |
| 28 new ExtensionAppModelBuilder(profile_, model_.get(), controller)); | 48 new ExtensionAppModelBuilder(profile_, model_.get(), controller)); |
| 29 DCHECK(profile_); | 49 DCHECK(profile_); |
| 30 VLOG(1) << "AppListSyncableService Created."; | 50 VLOG(1) << "AppListSyncableService Created."; |
| 31 } | 51 } |
| 32 | 52 |
| 33 AppListSyncableService::~AppListSyncableService() { | 53 void AppListSyncableService::Observe( |
| 54 int type, | |
| 55 const content::NotificationSource& source, | |
| 56 const content::NotificationDetails& details) { | |
| 57 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); | |
| 58 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | |
| 59 registrar_.RemoveAll(); | |
| 60 BuildModel(); | |
| 34 } | 61 } |
| 35 | 62 |
| 36 } // namespace app_list | 63 } // namespace app_list |
| OLD | NEW |