| 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 "base/memory/ptr_util.h" |
| 7 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "chrome/browser/chromeos/arc/arc_util.h" | 9 #include "chrome/browser/chromeos/arc/arc_util.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 11 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" | 12 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" |
| 12 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" | 13 #include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h" |
| 13 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 14 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 15 #include "ui/gfx/image/canvas_image_source.h" | 16 #include "ui/gfx/image/canvas_image_source.h" |
| 16 #include "ui/gfx/image/image_skia_operations.h" | 17 #include "ui/gfx/image/image_skia_operations.h" |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 105 |
| 105 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { | 106 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { |
| 106 const std::string shelf_app_id = | 107 const std::string shelf_app_id = |
| 107 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 108 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 108 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); | 109 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); |
| 109 if (it == app_controller_map_.end()) | 110 if (it == app_controller_map_.end()) |
| 110 return; | 111 return; |
| 111 | 112 |
| 112 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 113 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
| 113 const bool need_close_item = | 114 const bool need_close_item = |
| 114 it->second == owner_->GetLauncherItemController(shelf_id); | 115 it->second == owner_->GetShelfItemDelegate(shelf_id); |
| 115 app_controller_map_.erase(it); | 116 app_controller_map_.erase(it); |
| 116 if (need_close_item) | 117 if (need_close_item) |
| 117 owner_->CloseLauncherItem(shelf_id); | 118 owner_->CloseLauncherItem(shelf_id); |
| 118 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); | 119 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); |
| 119 } | 120 } |
| 120 | 121 |
| 121 void ArcAppDeferredLauncherController::OnAppReadyChanged( | 122 void ArcAppDeferredLauncherController::OnAppReadyChanged( |
| 122 const std::string& app_id, | 123 const std::string& app_id, |
| 123 bool ready) { | 124 bool ready) { |
| 124 if (!ready || app_controller_map_.empty()) | 125 if (!ready || app_controller_map_.empty()) |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 | 196 |
| 196 const std::string shelf_app_id = | 197 const std::string shelf_app_id = |
| 197 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 198 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 198 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 199 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
| 199 | 200 |
| 200 // We are allowed to apply new deferred controller only over non-active items. | 201 // We are allowed to apply new deferred controller only over non-active items. |
| 201 const ash::ShelfItem* item = owner_->GetItem(shelf_id); | 202 const ash::ShelfItem* item = owner_->GetItem(shelf_id); |
| 202 if (item && item->status != ash::STATUS_CLOSED) | 203 if (item && item->status != ash::STATUS_CLOSED) |
| 203 return; | 204 return; |
| 204 | 205 |
| 205 ArcAppDeferredLauncherItemController* controller = | 206 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = |
| 206 new ArcAppDeferredLauncherItemController( | 207 base::MakeUnique<ArcAppDeferredLauncherItemController>( |
| 207 shelf_app_id, owner_, event_flags, weak_ptr_factory_.GetWeakPtr()); | 208 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); |
| 209 ArcAppDeferredLauncherItemController* item_controller = controller.get(); |
| 208 if (shelf_id == 0) { | 210 if (shelf_id == 0) { |
| 209 owner_->CreateAppLauncherItem(controller, ash::STATUS_RUNNING); | 211 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); |
| 210 } else { | 212 } else { |
| 211 owner_->SetItemController(shelf_id, controller); | 213 owner_->SetShelfItemDelegate(shelf_id, std::move(controller)); |
| 212 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 213 } | 215 } |
| 214 | 216 |
| 215 if (app_controller_map_.empty()) | 217 if (app_controller_map_.empty()) |
| 216 RegisterNextUpdate(); | 218 RegisterNextUpdate(); |
| 217 | 219 |
| 218 app_controller_map_[shelf_app_id] = controller; | 220 app_controller_map_[shelf_app_id] = item_controller; |
| 219 } | 221 } |
| OLD | NEW |