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