| Index: chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc
|
| diff --git a/chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc b/chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc
|
| index 8c393f1f6c3f4ce90d28d797100b25eb3a2e2e71..7e3917bc764155cb5d3df1df1e7f82a527167fb6 100644
|
| --- a/chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc
|
| +++ b/chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc
|
| @@ -16,6 +16,7 @@
|
| #include "ui/gfx/paint_throbber.h"
|
|
|
| namespace {
|
| +
|
| constexpr int kUpdateIconIntervalMs = 40; // 40ms for 25 frames per second.
|
| constexpr int kSpinningGapPercent = 25;
|
|
|
| @@ -62,9 +63,17 @@ ArcAppDeferredLauncherController::ArcAppDeferredLauncherController(
|
| observed_profile_ = owner->GetProfile();
|
| ArcAppListPrefs::Get(observed_profile_)->AddObserver(this);
|
| }
|
| + arc::ArcAuthService* auth_service = arc::ArcAuthService::Get();
|
| + // arc::ArcAuthService might not be set in tests.
|
| + if (auth_service)
|
| + auth_service->AddObserver(this);
|
| }
|
|
|
| ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() {
|
| + arc::ArcAuthService* auth_service = arc::ArcAuthService::Get();
|
| + // arc::ArcAuthService may be released first.
|
| + if (auth_service)
|
| + auth_service->RemoveObserver(this);
|
| if (observed_profile_)
|
| ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this);
|
| }
|
| @@ -123,6 +132,21 @@ void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) {
|
| Close(app_id);
|
| }
|
|
|
| +void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) {
|
| + if (enabled)
|
| + return;
|
| +
|
| + // If Arc was disabled, remove all deferred launch requests.
|
| + while (!app_controller_map_.empty())
|
| + Close(app_controller_map_.begin()->first);
|
| +}
|
| +
|
| +bool ArcAppDeferredLauncherController::HasApp(const std::string& app_id) const {
|
| + const std::string shelf_app_id =
|
| + ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
|
| + return app_controller_map_.count(shelf_app_id);
|
| +}
|
| +
|
| base::TimeDelta ArcAppDeferredLauncherController::GetActiveTime(
|
| const std::string& shelf_app_id) const {
|
| AppControllerMap::const_iterator it = app_controller_map_.find(shelf_app_id);
|
| @@ -150,6 +174,11 @@ void ArcAppDeferredLauncherController::RegisterNextUpdate() {
|
|
|
| void ArcAppDeferredLauncherController::RegisterDeferredLaunch(
|
| const std::string& app_id) {
|
| + const arc::ArcAuthService* auth_service = arc::ArcAuthService::Get();
|
| + DCHECK(auth_service);
|
| + DCHECK(auth_service->state() != arc::ArcAuthService::State::STOPPED);
|
| + DCHECK(auth_service->state() != arc::ArcAuthService::State::NOT_INITIALIZED);
|
| +
|
| const std::string shelf_app_id =
|
| ArcAppWindowLauncherController::GetShelfAppIdFromArcAppId(app_id);
|
| const ash::ShelfID shelf_id = owner_->GetShelfIDForAppID(shelf_app_id);
|
|
|