| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/extension_app_model_builder.h" | 5 #include "chrome/browser/ui/app_list/extension_app_model_builder.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ptr_util.h" |
| 12 #include "chrome/browser/extensions/extension_ui_util.h" | 13 #include "chrome/browser/extensions/extension_ui_util.h" |
| 13 #include "chrome/browser/extensions/extension_util.h" | 14 #include "chrome/browser/extensions/extension_util.h" |
| 14 #include "chrome/browser/extensions/install_tracker.h" | 15 #include "chrome/browser/extensions/install_tracker.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" | 17 #include "chrome/browser/ui/app_list/app_list_controller_delegate.h" |
| 17 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" | 18 #include "chrome/browser/ui/app_list/app_list_syncable_service.h" |
| 18 #include "chrome/browser/ui/app_list/extension_app_item.h" | 19 #include "chrome/browser/ui/app_list/extension_app_item.h" |
| 19 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
| 20 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
| 21 #include "extensions/browser/extension_registry.h" | 22 #include "extensions/browser/extension_registry.h" |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 void ExtensionAppModelBuilder::OnShutdown( | 197 void ExtensionAppModelBuilder::OnShutdown( |
| 197 extensions::ExtensionRegistry* registry) { | 198 extensions::ExtensionRegistry* registry) { |
| 198 if (!extension_registry_) | 199 if (!extension_registry_) |
| 199 return; | 200 return; |
| 200 | 201 |
| 201 DCHECK_EQ(extension_registry_, registry); | 202 DCHECK_EQ(extension_registry_, registry); |
| 202 extension_registry_->RemoveObserver(this); | 203 extension_registry_->RemoveObserver(this); |
| 203 extension_registry_ = nullptr; | 204 extension_registry_ = nullptr; |
| 204 } | 205 } |
| 205 | 206 |
| 206 scoped_ptr<ExtensionAppItem> ExtensionAppModelBuilder::CreateAppItem( | 207 std::unique_ptr<ExtensionAppItem> ExtensionAppModelBuilder::CreateAppItem( |
| 207 const std::string& extension_id, | 208 const std::string& extension_id, |
| 208 const std::string& extension_name, | 209 const std::string& extension_name, |
| 209 const gfx::ImageSkia& installing_icon, | 210 const gfx::ImageSkia& installing_icon, |
| 210 bool is_platform_app) { | 211 bool is_platform_app) { |
| 211 return make_scoped_ptr(new ExtensionAppItem(profile(), | 212 return base::WrapUnique( |
| 212 GetSyncItem(extension_id), | 213 new ExtensionAppItem(profile(), GetSyncItem(extension_id), extension_id, |
| 213 extension_id, | 214 extension_name, installing_icon, is_platform_app)); |
| 214 extension_name, | |
| 215 installing_icon, | |
| 216 is_platform_app)); | |
| 217 } | 215 } |
| 218 | 216 |
| 219 void ExtensionAppModelBuilder::BuildModel() { | 217 void ExtensionAppModelBuilder::BuildModel() { |
| 220 DCHECK(!tracker_); | 218 DCHECK(!tracker_); |
| 221 | 219 |
| 222 InitializePrefChangeRegistrars(); | 220 InitializePrefChangeRegistrars(); |
| 223 | 221 |
| 224 tracker_ = controller()->GetInstallTrackerFor(profile()); | 222 tracker_ = controller()->GetInstallTrackerFor(profile()); |
| 225 extension_registry_ = extensions::ExtensionRegistry::Get(profile()); | 223 extension_registry_ = extensions::ExtensionRegistry::Get(profile()); |
| 226 | 224 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 app_list::AppListItem* item = item_list->item_at(idx + 1); | 276 app_list::AppListItem* item = item_list->item_at(idx + 1); |
| 279 if (item->GetItemType() == ExtensionAppItem::kItemType) { | 277 if (item->GetItemType() == ExtensionAppItem::kItemType) { |
| 280 next = static_cast<ExtensionAppItem*>(item); | 278 next = static_cast<ExtensionAppItem*>(item); |
| 281 break; | 279 break; |
| 282 } | 280 } |
| 283 } | 281 } |
| 284 // item->Move will call set_position, overriding the item's position. | 282 // item->Move will call set_position, overriding the item's position. |
| 285 if (prev || next) | 283 if (prev || next) |
| 286 static_cast<ExtensionAppItem*>(item)->Move(prev, next); | 284 static_cast<ExtensionAppItem*>(item)->Move(prev, next); |
| 287 } | 285 } |
| OLD | NEW |