| 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 "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/threading/thread_task_runner_handle.h" | 9 #include "base/threading/thread_task_runner_handle.h" |
| 10 #include "chrome/browser/chromeos/arc/arc_util.h" | 10 #include "chrome/browser/chromeos/arc/arc_util.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 app_controller_map_.erase(shelf_app_id); | 104 app_controller_map_.erase(shelf_app_id); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { | 107 void ArcAppDeferredLauncherController::Close(const std::string& app_id) { |
| 108 const std::string shelf_app_id = | 108 const std::string shelf_app_id = |
| 109 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 109 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 110 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); | 110 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); |
| 111 if (it == app_controller_map_.end()) | 111 if (it == app_controller_map_.end()) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 114 const ash::ShelfID shelf_id(shelf_app_id); |
| 115 const bool need_close_item = | 115 const bool need_close_item = |
| 116 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id); | 116 it->second == owner_->shelf_model()->GetShelfItemDelegate(shelf_id); |
| 117 app_controller_map_.erase(it); | 117 app_controller_map_.erase(it); |
| 118 if (need_close_item) | 118 if (need_close_item) |
| 119 owner_->CloseLauncherItem(shelf_id); | 119 owner_->CloseLauncherItem(shelf_id); |
| 120 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); | 120 owner_->OnAppUpdated(owner_->profile(), shelf_app_id); |
| 121 } | 121 } |
| 122 | 122 |
| 123 void ArcAppDeferredLauncherController::OnAppReadyChanged( | 123 void ArcAppDeferredLauncherController::OnAppReadyChanged( |
| 124 const std::string& app_id, | 124 const std::string& app_id, |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 const arc::ArcSessionManager* arc_session_manager = | 190 const arc::ArcSessionManager* arc_session_manager = |
| 191 arc::ArcSessionManager::Get(); | 191 arc::ArcSessionManager::Get(); |
| 192 DCHECK(arc_session_manager); | 192 DCHECK(arc_session_manager); |
| 193 DCHECK(arc_session_manager->state() != | 193 DCHECK(arc_session_manager->state() != |
| 194 arc::ArcSessionManager::State::STOPPED); | 194 arc::ArcSessionManager::State::STOPPED); |
| 195 DCHECK(arc_session_manager->state() != | 195 DCHECK(arc_session_manager->state() != |
| 196 arc::ArcSessionManager::State::NOT_INITIALIZED); | 196 arc::ArcSessionManager::State::NOT_INITIALIZED); |
| 197 | 197 |
| 198 const std::string shelf_app_id = | 198 const std::string shelf_app_id = |
| 199 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 199 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 200 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 200 const ash::ShelfID shelf_id(shelf_app_id); |
| 201 | 201 |
| 202 // We are allowed to apply new deferred controller only over non-active items. | 202 // We are allowed to apply new deferred controller only over non-active items. |
| 203 const ash::ShelfItem* item = owner_->GetItem(shelf_id); | 203 const ash::ShelfItem* item = owner_->GetItem(shelf_id); |
| 204 if (item && item->status != ash::STATUS_CLOSED) | 204 if (item && item->status != ash::STATUS_CLOSED) |
| 205 return; | 205 return; |
| 206 | 206 |
| 207 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = | 207 std::unique_ptr<ArcAppDeferredLauncherItemController> controller = |
| 208 base::MakeUnique<ArcAppDeferredLauncherItemController>( | 208 base::MakeUnique<ArcAppDeferredLauncherItemController>( |
| 209 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); | 209 shelf_app_id, event_flags, weak_ptr_factory_.GetWeakPtr()); |
| 210 ArcAppDeferredLauncherItemController* item_controller = controller.get(); | 210 ArcAppDeferredLauncherItemController* item_controller = controller.get(); |
| 211 if (shelf_id.IsNull()) { | 211 if (item == nullptr) { |
| 212 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); | 212 owner_->CreateAppLauncherItem(std::move(controller), ash::STATUS_RUNNING); |
| 213 } else { | 213 } else { |
| 214 owner_->shelf_model()->SetShelfItemDelegate(shelf_id, | 214 owner_->shelf_model()->SetShelfItemDelegate(shelf_id, |
| 215 std::move(controller)); | 215 std::move(controller)); |
| 216 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 216 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 217 } | 217 } |
| 218 | 218 |
| 219 if (app_controller_map_.empty()) | 219 if (app_controller_map_.empty()) |
| 220 RegisterNextUpdate(); | 220 RegisterNextUpdate(); |
| 221 | 221 |
| 222 app_controller_map_[shelf_app_id] = item_controller; | 222 app_controller_map_[shelf_app_id] = item_controller; |
| 223 } | 223 } |
| OLD | NEW |