OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/arc/arc_app_model_builder.h" | 5 #include "chrome/browser/ui/app_list/arc/arc_app_model_builder.h" |
6 | 6 |
| 7 #include "base/memory/ptr_util.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" | 9 #include "chrome/browser/ui/app_list/arc/arc_app_item.h" |
9 | 10 |
10 ArcAppModelBuilder::ArcAppModelBuilder(AppListControllerDelegate* controller) | 11 ArcAppModelBuilder::ArcAppModelBuilder(AppListControllerDelegate* controller) |
11 : AppListModelBuilder(controller, ArcAppItem::kItemType) { | 12 : AppListModelBuilder(controller, ArcAppItem::kItemType) { |
12 } | 13 } |
13 | 14 |
14 ArcAppModelBuilder::~ArcAppModelBuilder() { | 15 ArcAppModelBuilder::~ArcAppModelBuilder() { |
15 prefs_->RemoveObserver(this); | 16 prefs_->RemoveObserver(this); |
16 } | 17 } |
17 | 18 |
18 void ArcAppModelBuilder::BuildModel() { | 19 void ArcAppModelBuilder::BuildModel() { |
19 prefs_ = ArcAppListPrefs::Get(profile()); | 20 prefs_ = ArcAppListPrefs::Get(profile()); |
20 | 21 |
21 std::vector<std::string> app_ids = prefs_->GetAppIds(); | 22 std::vector<std::string> app_ids = prefs_->GetAppIds(); |
22 for (auto& app_id : app_ids) { | 23 for (auto& app_id : app_ids) { |
23 scoped_ptr<ArcAppListPrefs::AppInfo> app_info = prefs_->GetApp(app_id); | 24 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = prefs_->GetApp(app_id); |
24 if (!app_info) | 25 if (!app_info) |
25 continue; | 26 continue; |
26 | 27 |
27 InsertApp(CreateApp(app_id, *app_info)); | 28 InsertApp(CreateApp(app_id, *app_info)); |
28 } | 29 } |
29 | 30 |
30 prefs_->AddObserver(this); | 31 prefs_->AddObserver(this); |
31 } | 32 } |
32 | 33 |
33 ArcAppItem* ArcAppModelBuilder::GetArcAppItem(const std::string& app_id) { | 34 ArcAppItem* ArcAppModelBuilder::GetArcAppItem(const std::string& app_id) { |
34 return static_cast<ArcAppItem*>(GetAppItem(app_id)); | 35 return static_cast<ArcAppItem*>(GetAppItem(app_id)); |
35 } | 36 } |
36 | 37 |
37 scoped_ptr<ArcAppItem> ArcAppModelBuilder::CreateApp( | 38 std::unique_ptr<ArcAppItem> ArcAppModelBuilder::CreateApp( |
38 const std::string& app_id, | 39 const std::string& app_id, |
39 const ArcAppListPrefs::AppInfo& app_info) { | 40 const ArcAppListPrefs::AppInfo& app_info) { |
40 return make_scoped_ptr(new ArcAppItem(profile(), | 41 return base::WrapUnique(new ArcAppItem(profile(), GetSyncItem(app_id), app_id, |
41 GetSyncItem(app_id), | 42 app_info.name, app_info.ready)); |
42 app_id, | |
43 app_info.name, | |
44 app_info.ready)); | |
45 } | 43 } |
46 | 44 |
47 void ArcAppModelBuilder::OnAppRegistered( | 45 void ArcAppModelBuilder::OnAppRegistered( |
48 const std::string& app_id, | 46 const std::string& app_id, |
49 const ArcAppListPrefs::AppInfo& app_info) { | 47 const ArcAppListPrefs::AppInfo& app_info) { |
50 InsertApp(CreateApp(app_id, app_info)); | 48 InsertApp(CreateApp(app_id, app_info)); |
51 } | 49 } |
52 | 50 |
53 void ArcAppModelBuilder::OnAppReadyChanged(const std::string& app_id, | 51 void ArcAppModelBuilder::OnAppReadyChanged(const std::string& app_id, |
54 bool ready) { | 52 bool ready) { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 app_item->SetName(name); | 89 app_item->SetName(name); |
92 } | 90 } |
93 | 91 |
94 void ArcAppModelBuilder::OnListItemMoved(size_t from_index, | 92 void ArcAppModelBuilder::OnListItemMoved(size_t from_index, |
95 size_t to_index, | 93 size_t to_index, |
96 app_list::AppListItem* item) { | 94 app_list::AppListItem* item) { |
97 // On ChromeOS we expect that ArcAppModelBuilder is initialized with | 95 // On ChromeOS we expect that ArcAppModelBuilder is initialized with |
98 // AppListSyncableService and in this case this observer is not used. | 96 // AppListSyncableService and in this case this observer is not used. |
99 NOTREACHED(); | 97 NOTREACHED(); |
100 } | 98 } |
OLD | NEW |