Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Unified Diff: chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.cc

Issue 2322683003: [Merge-M54] arc: Add support of default and OEM apps. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..524356f9532e810c27b3e4face48b78b14aab847 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);
}
@@ -129,6 +138,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);
@@ -156,6 +180,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);

Powered by Google App Engine
This is Rietveld 408576698