OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ash/launcher/arc_app_deferred_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" |
6 | 6 |
| 7 #include "ash/common/shelf/shelf_model.h" |
| 8 #include "ash/shell.h" |
7 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
8 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
9 #include "chrome/browser/chromeos/arc/arc_util.h" | 11 #include "chrome/browser/chromeos/arc/arc_util.h" |
10 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 13 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
12 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" | 14 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" |
13 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 15 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 16 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
15 #include "ui/gfx/canvas.h" | 17 #include "ui/gfx/canvas.h" |
16 #include "ui/gfx/image/canvas_image_source.h" | 18 #include "ui/gfx/image/canvas_image_source.h" |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 106 } |
105 | 107 |
106 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { | 108 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { |
107 const std::string shelf_app_id = | 109 const std::string shelf_app_id = |
108 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 110 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
109 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); | 111 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); |
110 if (it == app_controller_map_.end()) | 112 if (it == app_controller_map_.end()) |
111 return; | 113 return; |
112 | 114 |
113 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 115 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
| 116 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); |
114 const bool need_close_item = | 117 const bool need_close_item = |
115 it->second == owner_->GetShelfItemDelegate(shelf_id); | 118 it->second == shelf_model->GetShelfItemDelegate(shelf_id); |
116 app_controller_map_.erase(it); | 119 app_controller_map_.erase(it); |
117 if (need_close_item) | 120 if (need_close_item) |
118 owner_->CloseLauncherItem(shelf_id); | 121 owner_->CloseLauncherItem(shelf_id); |
119 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); | 122 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); |
120 } | 123 } |
121 | 124 |
122 void ArcAppDeferredLauncherController::OnAppReadyChanged( | 125 void ArcAppDeferredLauncherController::OnAppReadyChanged( |
123 const std::string& app_id, | 126 const std::string& app_id, |
124 bool ready) { | 127 bool ready) { |
125 if (!ready || app_controller_map_.empty()) | 128 if (!ready || app_controller_map_.empty()) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 if (item && item->status != ash::STATUS_CLOSED) | 206 if (item && item->status != ash::STATUS_CLOSED) |
204 return; | 207 return; |
205 | 208 |
206 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = | 209 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = |
207 base::MakeUnique<ArcAppDeferredLauncherItemController>( | 210 base::MakeUnique<ArcAppDeferredLauncherItemController>( |
208 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); | 211 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); |
209 ArcAppDeferredLauncherItemController* item_controller = controller.get(); | 212 ArcAppDeferredLauncherItemController* item_controller = controller.get(); |
210 if (shelf_id == 0) { | 213 if (shelf_id == 0) { |
211 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); | 214 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); |
212 } else { | 215 } else { |
213 owner_->SetShelfItemDelegate(shelf_id, std::move(controller)); | 216 ash::ShelfModel* shelf_model = ash::Shell::Get()->shelf_model(); |
| 217 shelf_model->SetShelfItemDelegate(shelf_id, std::move(controller)); |
214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 218 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
215 } | 219 } |
216 | 220 |
217 if (app_controller_map_.empty()) | 221 if (app_controller_map_.empty()) |
218 RegisterNextUpdate(); | 222 RegisterNextUpdate(); |
219 | 223 |
220 app_controller_map_[shelf_app_id] = item_controller; | 224 app_controller_map_[shelf_app_id] = item_controller; |
221 } | 225 } |
OLD | NEW |