| 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 8 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 10 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // For now, use the AppListControllerDelegate associated with the native | 114 // For now, use the AppListControllerDelegate associated with the native |
| 115 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller | 115 // desktop. TODO(stevenjb): Remove ExtensionAppModelBuilder controller |
| 116 // dependency and move the dependent methods from AppListControllerDelegate | 116 // dependency and move the dependent methods from AppListControllerDelegate |
| 117 // to an extension service delegate associated with this class. | 117 // to an extension service delegate associated with this class. |
| 118 AppListControllerDelegate* controller = NULL; | 118 AppListControllerDelegate* controller = NULL; |
| 119 AppListService* service = | 119 AppListService* service = |
| 120 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); | 120 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); |
| 121 if (service) | 121 if (service) |
| 122 controller = service->GetControllerDelegate(); | 122 controller = service->GetControllerDelegate(); |
| 123 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); | 123 apps_builder_.reset(new ExtensionAppModelBuilder(controller)); |
| 124 if (CommandLine::ForCurrentProcess()->HasSwitch( | 124 DCHECK(profile_); |
| 125 // TODO(stevenjb): Correctly handle OTR profiles for Guest mode. |
| 126 if (!profile_->IsOffTheRecord() && |
| 127 CommandLine::ForCurrentProcess()->HasSwitch( |
| 125 switches::kEnableSyncAppList)) { | 128 switches::kEnableSyncAppList)) { |
| 126 DVLOG(1) << this << ": AppListSyncableService: InitializeWithService."; | 129 DVLOG(1) << this << ": AppListSyncableService: InitializeWithService."; |
| 127 SyncStarted(); | 130 SyncStarted(); |
| 128 apps_builder_->InitializeWithService(this); | 131 apps_builder_->InitializeWithService(this); |
| 129 } else { | 132 } else { |
| 130 DVLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; | 133 DVLOG(1) << this << ": AppListSyncableService: InitializeWithProfile."; |
| 131 apps_builder_->InitializeWithProfile(profile_, model_.get()); | 134 apps_builder_->InitializeWithProfile(profile_, model_.get()); |
| 132 } | 135 } |
| 133 | |
| 134 DCHECK(profile_); | |
| 135 } | 136 } |
| 136 | 137 |
| 137 void AppListSyncableService::Observe( | 138 void AppListSyncableService::Observe( |
| 138 int type, | 139 int type, |
| 139 const content::NotificationSource& source, | 140 const content::NotificationSource& source, |
| 140 const content::NotificationDetails& details) { | 141 const content::NotificationDetails& details) { |
| 141 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); | 142 DCHECK_EQ(chrome::NOTIFICATION_EXTENSIONS_READY, type); |
| 142 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); | 143 DCHECK_EQ(profile_, content::Source<Profile>(source).ptr()); |
| 143 registrar_.RemoveAll(); | 144 registrar_.RemoveAll(); |
| 144 BuildModel(); | 145 BuildModel(); |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 delete iter->second; | 453 delete iter->second; |
| 453 sync_items_.erase(iter); | 454 sync_items_.erase(iter); |
| 454 model_->item_list()->DeleteItem(item_id); | 455 model_->item_list()->DeleteItem(item_id); |
| 455 } | 456 } |
| 456 | 457 |
| 457 std::string AppListSyncableService::SyncItem::ToString() const { | 458 std::string AppListSyncableService::SyncItem::ToString() const { |
| 458 return item_id.substr(0, 8) + " [" + item_ordinal.ToDebugString() + "]"; | 459 return item_id.substr(0, 8) + " [" + item_ordinal.ToDebugString() + "]"; |
| 459 } | 460 } |
| 460 | 461 |
| 461 } // namespace app_list | 462 } // namespace app_list |
| OLD | NEW |