| 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 "chrome/browser/chromeos/arc/arc_support_host.h" | 7 #include "chrome/browser/chromeos/arc/arc_support_host.h" |
| 8 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 9 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" | 9 #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" | 10 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_item_controll
er.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 const std::string shelf_app_id_; | 52 const std::string shelf_app_id_; |
| 53 const gfx::ImageSkia image_; | 53 const gfx::ImageSkia image_; |
| 54 | 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource); | 55 DISALLOW_COPY_AND_ASSIGN(SpinningEffectSource); |
| 56 }; | 56 }; |
| 57 } // namespace | 57 } // namespace |
| 58 | 58 |
| 59 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( | 59 ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( |
| 60 ChromeLauncherControllerImpl* owner) | 60 ChromeLauncherControllerImpl* owner) |
| 61 : owner_(owner), weak_ptr_factory_(this) { | 61 : owner_(owner), weak_ptr_factory_(this) { |
| 62 if (arc::ArcAuthService::IsAllowedForProfile(owner->profile())) { | 62 if (arc::ArcSessionManager::IsAllowedForProfile(owner->profile())) { |
| 63 observed_profile_ = owner->profile(); | 63 observed_profile_ = owner->profile(); |
| 64 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); | 64 ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); |
| 65 } | 65 } |
| 66 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); | 66 arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); |
| 67 // arc::ArcAuthService might not be set in tests. | 67 // arc::ArcSessionManager might not be set in tests. |
| 68 if (auth_service) | 68 if (arc_session_manager) |
| 69 auth_service->AddObserver(this); | 69 arc_session_manager->AddObserver(this); |
| 70 } | 70 } |
| 71 | 71 |
| 72 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { | 72 ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { |
| 73 arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); | 73 arc::ArcSessionManager* arc_session_manager = arc::ArcSessionManager::Get(); |
| 74 // arc::ArcAuthService may be released first. | 74 // arc::ArcSessionManager may be released first. |
| 75 if (auth_service) | 75 if (arc_session_manager) |
| 76 auth_service->RemoveObserver(this); | 76 arc_session_manager->RemoveObserver(this); |
| 77 if (observed_profile_) | 77 if (observed_profile_) |
| 78 ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this); | 78 ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void ArcAppDeferredLauncherController::MaybeApplySpinningEffect( | 81 void ArcAppDeferredLauncherController::MaybeApplySpinningEffect( |
| 82 const std::string& shelf_app_id, | 82 const std::string& shelf_app_id, |
| 83 gfx::ImageSkia* image) { | 83 gfx::ImageSkia* image) { |
| 84 DCHECK(image); | 84 DCHECK(image); |
| 85 if (app_controller_map_.find(shelf_app_id) == app_controller_map_.end()) | 85 if (app_controller_map_.find(shelf_app_id) == app_controller_map_.end()) |
| 86 return; | 86 return; |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 173 |
| 174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { | 174 void ArcAppDeferredLauncherController::RegisterNextUpdate() { |
| 175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 175 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, | 176 FROM_HERE, base::Bind(&ArcAppDeferredLauncherController::UpdateApps, |
| 177 weak_ptr_factory_.GetWeakPtr()), | 177 weak_ptr_factory_.GetWeakPtr()), |
| 178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); | 178 base::TimeDelta::FromMilliseconds(kUpdateIconIntervalMs)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( | 181 void ArcAppDeferredLauncherController::RegisterDeferredLaunch( |
| 182 const std::string& app_id) { | 182 const std::string& app_id) { |
| 183 const arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); | 183 const arc::ArcSessionManager* arc_session_manager = |
| 184 DCHECK(auth_service); | 184 arc::ArcSessionManager::Get(); |
| 185 DCHECK(auth_service->state() != arc::ArcAuthService::State::STOPPED); | 185 DCHECK(arc_session_manager); |
| 186 DCHECK(auth_service->state() != arc::ArcAuthService::State::NOT_INITIALIZED); | 186 DCHECK(arc_session_manager->state() != |
| 187 arc::ArcSessionManager::State::STOPPED); |
| 188 DCHECK(arc_session_manager->state() != |
| 189 arc::ArcSessionManager::State::NOT_INITIALIZED); |
| 187 | 190 |
| 188 const std::string shelf_app_id = | 191 const std::string shelf_app_id = |
| 189 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); | 192 ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id); |
| 190 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); | 193 const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id); |
| 191 | 194 |
| 192 if (shelf_id) { | 195 if (shelf_id) { |
| 193 LauncherItemController* controller = | 196 LauncherItemController* controller = |
| 194 owner_->GetLauncherItemController(shelf_id); | 197 owner_->GetLauncherItemController(shelf_id); |
| 195 if (controller && | 198 if (controller && |
| 196 controller->type() != LauncherItemController::TYPE_SHORTCUT) { | 199 controller->type() != LauncherItemController::TYPE_SHORTCUT) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 208 } else { | 211 } else { |
| 209 owner_->SetItemController(shelf_id, controller); | 212 owner_->SetItemController(shelf_id, controller); |
| 210 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); | 213 owner_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); |
| 211 } | 214 } |
| 212 | 215 |
| 213 if (app_controller_map_.empty()) | 216 if (app_controller_map_.empty()) |
| 214 RegisterNextUpdate(); | 217 RegisterNextUpdate(); |
| 215 | 218 |
| 216 app_controller_map_[shelf_app_id] = controller; | 219 app_controller_map_[shelf_app_id] = controller; |
| 217 } | 220 } |
| OLD | NEW |