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/threading/thread_task_runner_handle.h" | 7 #include "base/threading/thread_task_runner_handle.h" |
8 #include "chrome/browser/chromeos/arc/arc_util.h" | 8 #include "chrome/browser/chromeos/arc/arc_util.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 10 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
191 DCHECK(arc_session_manager->state() != | 191 DCHECK(arc_session_manager->state() != |
192 arc::ArcSessionManager::State::STOPPED); | 192 arc::ArcSessionManager::State::STOPPED); |
193 DCHECK(arc_session_manager->state() != | 193 DCHECK(arc_session_manager->state() != |
194 arc::ArcSessionManager::State::NOT_INITIALIZED); | 194 arc::ArcSessionManager::State::NOT_INITIALIZED); |
195 | 195 |
196 const std::string shelf_app_id = | 196 const std::string shelf_app_id = |
197 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 197 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
198 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 198 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
199 | 199 |
200 // We are allowed to apply new deferred controller only over shortcut. | 200 // We are allowed to apply new deferred controller only over shortcut. |
201 const ash::ShelfItem* item = owner_->GetItem(shelf_id); | 201 const LauncherItemController* existing_controller = |
202 if (item && item->type != ash::TYPE_APP_SHORTCUT) | 202 owner_->GetLauncherItemController(shelf_id); |
203 if (existing_controller && !existing_controller->IsShortcut()) | |
msw
2017/03/14 01:24:59
Can you write an automated test that ensures this
khmel
2017/03/14 20:19:56
Done.
| |
203 return; | 204 return; |
204 | 205 |
205 ArcAppDeferredLauncherItemController* controller = | 206 ArcAppDeferredLauncherItemController* controller = |
206 new ArcAppDeferredLauncherItemController( | 207 new ArcAppDeferredLauncherItemController( |
207 shelf_app_id, owner_, event_flags, weak_ptr_factory_.GetWeakPtr()); | 208 shelf_app_id, owner_, event_flags, weak_ptr_factory_.GetWeakPtr()); |
208 if (shelf_id == 0) { | 209 if (shelf_id == 0) { |
209 owner_->CreateAppLauncherItem(controller, shelf_app_id, | 210 owner_->CreateAppLauncherItem(controller, shelf_app_id, |
210 ash::STATUS_RUNNING); | 211 ash::STATUS_RUNNING); |
211 } else { | 212 } else { |
212 owner_->SetItemController(shelf_id, controller); | 213 owner_->SetItemController(shelf_id, controller); |
213 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 214 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
214 } | 215 } |
215 | 216 |
216 if (app_controller_map_.empty()) | 217 if (app_controller_map_.empty()) |
217 RegisterNextUpdate(); | 218 RegisterNextUpdate(); |
218 | 219 |
219 app_controller_map_[shelf_app_id] = controller; | 220 app_controller_map_[shelf_app_id] = controller; |
220 } | 221 } |
OLD | NEW |