Chromium Code Reviews| 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 <string> | |
|
khmel
2016/11/28 23:23:48
nit: Remove it here. You included it in .h file.
Luis Héctor Chávez
2016/11/28 23:27:56
Done.
| |
| 8 | |
| 7 #include "chrome/browser/chromeos/arc/arc_support_host.h" | 9 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 11 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" |
| 10 #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" |
| 11 #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" |
| 12 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" | 14 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" |
| 13 #include "ui/gfx/canvas.h" | 15 #include "ui/gfx/canvas.h" |
| 14 #include "ui/gfx/image/canvas_image_source.h" | 16 #include "ui/gfx/image/canvas_image_source.h" |
| 15 #include "ui/gfx/image/image_skia_operations.h" | 17 #include "ui/gfx/image/image_skia_operations.h" |
| 16 #include "ui/gfx/paint_throbber.h" | 18 #include "ui/gfx/paint_throbber.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 124 return; | 126 return; |
| 125 | 127 |
| 126 const std::string shelf_app_id = | 128 const std::string shelf_app_id = |
| 127 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 129 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 128 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); | 130 AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id); |
| 129 if (it == app_controller_map_.end()) | 131 if (it == app_controller_map_.end()) |
| 130 return; | 132 return; |
| 131 | 133 |
| 132 Close(app_id); | 134 Close(app_id); |
| 133 | 135 |
| 134 arc::LaunchApp(observed_profile_, app_id); | 136 arc::LaunchApp(observed_profile_, app_id, it->second->event_flags()); |
| 135 } | 137 } |
| 136 | 138 |
| 137 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) { | 139 void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) { |
| 138 Close(app_id); | 140 Close(app_id); |
| 139 } | 141 } |
| 140 | 142 |
| 141 void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) { | 143 void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) { |
| 142 if (enabled) | 144 if (enabled) |
| 143 return; | 145 return; |
| 144 | 146 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 172 } | 174 } |
| 173 | 175 |
| 174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { | 176 void ArcAppDeferredLauncherController::RegisterNextUpdate() { |
| 175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 177 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, | 178 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, |
| 177 weak_ptr_factory_.GetWeakPtr()), | 179 weak_ptr_factory_.GetWeakPtr()), |
| 178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); | 180 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); |
| 179 } | 181 } |
| 180 | 182 |
| 181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( | 183 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( |
| 182 const std::string& app_id) { | 184 const std::string& app_id, |
| 185 int event_flags) { | |
| 183 const arc::ArcSessionManager* arc_session_manager = | 186 const arc::ArcSessionManager* arc_session_manager = |
| 184 arc::ArcSessionManager::Get(); | 187 arc::ArcSessionManager::Get(); |
| 185 DCHECK(arc_session_manager); | 188 DCHECK(arc_session_manager); |
| 186 DCHECK(arc_session_manager->state() != | 189 DCHECK(arc_session_manager->state() != |
| 187 arc::ArcSessionManager::State::STOPPED); | 190 arc::ArcSessionManager::State::STOPPED); |
| 188 DCHECK(arc_session_manager->state() != | 191 DCHECK(arc_session_manager->state() != |
| 189 arc::ArcSessionManager::State::NOT_INITIALIZED); | 192 arc::ArcSessionManager::State::NOT_INITIALIZED); |
| 190 | 193 |
| 191 const std::string shelf_app_id = | 194 const std::string shelf_app_id = |
| 192 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 195 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 193 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 196 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
| 194 | 197 |
| 195 if (shelf_id) { | 198 if (shelf_id) { |
| 196 LauncherItemController* controller = | 199 LauncherItemController* controller = |
| 197 owner_->GetLauncherItemController(shelf_id); | 200 owner_->GetLauncherItemController(shelf_id); |
| 198 if (controller && | 201 if (controller && |
| 199 controller->type() != LauncherItemController::TYPE_SHORTCUT) { | 202 controller->type() != LauncherItemController::TYPE_SHORTCUT) { |
| 200 // We are allowed to apply new deferred controller only over shortcut. | 203 // We are allowed to apply new deferred controller only over shortcut. |
| 201 return; | 204 return; |
| 202 } | 205 } |
| 203 } | 206 } |
| 204 | 207 |
| 205 ArcAppDeferredLauncherItemController* controller = | 208 ArcAppDeferredLauncherItemController* controller = |
| 206 new ArcAppDeferredLauncherItemController(shelf_app_id, owner_, | 209 new ArcAppDeferredLauncherItemController( |
| 207 weak_ptr_factory_.GetWeakPtr()); | 210 shelf_app_id, owner_, event_flags, weak_ptr_factory_.GetWeakPtr()); |
| 208 if (shelf_id == 0) { | 211 if (shelf_id == 0) { |
| 209 owner_->CreateAppLauncherItem(controller, shelf_app_id, | 212 owner_->CreateAppLauncherItem(controller, shelf_app_id, |
| 210 ash::STATUS_RUNNING); | 213 ash::STATUS_RUNNING); |
| 211 } else { | 214 } else { |
| 212 owner_->SetItemController(shelf_id, controller); | 215 owner_->SetItemController(shelf_id, controller); |
| 213 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 216 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 214 } | 217 } |
| 215 | 218 |
| 216 if (app_controller_map_.empty()) | 219 if (app_controller_map_.empty()) |
| 217 RegisterNextUpdate(); | 220 RegisterNextUpdate(); |
| 218 | 221 |
| 219 app_controller_map_[shelf_app_id] = controller; | 222 app_controller_map_[shelf_app_id] = controller; |
| 220 } | 223 } |
| OLD | NEW |