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 247a047e2bb1681bff1b7bcf8a0f1c37cf805dee..c8677e7d43efeee9761d4627f3594204ee194312 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,15 @@ ArcAppDeferredLauncherController::ArcAppDeferredLauncherController( |
observed_profile_ = owner->GetProfile(); |
ArcAppListPrefs::Get(observed_profile_)->AddObserver(this); |
} |
+ arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); |
+ if (auth_service) |
+ auth_service->AddObserver(this); |
Mr4D (OOO till 08-26)
2016/08/30 20:21:46
Just checking - is it guaranteed that the lifetime
khmel
2016/08/30 21:22:11
Actually we have unit tests were ArcAuthService mi
|
} |
ArcAppDeferredLauncherController::~ArcAppDeferredLauncherController() { |
+ arc::ArcAuthService* auth_service = arc::ArcAuthService::Get(); |
+ if (auth_service) |
+ auth_service->RemoveObserver(this); |
if (observed_profile_) |
ArcAppListPrefs::Get(observed_profile_)->RemoveObserver(this); |
} |
@@ -129,6 +136,21 @@ void ArcAppDeferredLauncherController::OnAppRemoved(const std::string& app_id) { |
Close(app_id); |
} |
+void ArcAppDeferredLauncherController::OnOptInEnabled(bool enabled) { |
+ // If Arc was disabled, remove all deferred launch requests. |
Mr4D (OOO till 08-26)
2016/08/30 20:21:46
I suppose you want to move this comment to line 14
khmel
2016/08/30 21:22:11
Right, that the better place
|
+ if (enabled) |
+ return; |
+ |
+ 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); |
@@ -156,6 +178,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); |