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

Unified Diff: chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc

Issue 2778053002: Fetch ARC Kiosk app name and icon from Android side. (Closed)
Patch Set: some nits Created 3 years, 8 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/chromeos/app_mode/arc/arc_kiosk_app_service.cc
diff --git a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
index 4c2aa1187891da7962ede8d519361e2666858b67..185b347d4a31558bf470e047bd2ad1d8661c9a28 100644
--- a/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
+++ b/chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.cc
@@ -12,6 +12,10 @@
#include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
#include "chrome/common/pref_names.h"
#include "components/prefs/pref_service.h"
+#include "ui/app_list/app_list_constants.h"
+#include "ui/base/layout.h"
+#include "ui/display/display.h"
+#include "ui/display/screen.h"
#include "ui/message_center/message_center.h"
#include "ui/message_center/notification_blocker.h"
@@ -134,6 +138,16 @@ void ArcKioskAppService::OnAppWindowLaunched() {
delegate_->OnAppWindowLaunched();
}
+void ArcKioskAppService::OnIconUpdated(ArcAppIcon* icon) {
+ DCHECK_EQ(icon, app_icon_.get());
+ if (icon->image_skia().isNull()) {
+ app_icon_.release();
+ return;
+ }
+ app_manager_->UpdateNameAndIcon(app_info_->package_name, app_info_->name,
+ app_icon_->image_skia());
+}
+
ArcKioskAppService::ArcKioskAppService(Profile* profile) : profile_(profile) {
ArcAppListPrefs::Get(profile_)->AddObserver(this);
app_manager_ = ArcKioskAppManager::Get();
@@ -149,6 +163,17 @@ ArcKioskAppService::~ArcKioskAppService() {
maintenance_timeout_timer_.Stop();
}
+void ArcKioskAppService::RequestNameAndIconUpdate() {
+ // Request only once when app_icon_ is not initialized.
+ if (!app_info_ || !app_info_->ready || app_icon_)
+ return;
+ app_icon_ = base::MakeUnique<ArcAppIcon>(profile_, app_id_,
+ app_list::kGridIconDimension, this);
+ app_icon_->LoadForScaleFactor(ui::GetSupportedScaleFactor(
+ display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor()));
+ // Name and icon are updated when icon is loaded in OnIconUpdated()
+}
+
void ArcKioskAppService::PreconditionsChanged() {
app_id_ = GetAppId();
if (app_id_.empty())
@@ -161,17 +186,16 @@ void ArcKioskAppService::PreconditionsChanged() {
} else if (task_id_ != -1) {
arc::CloseTask(task_id_);
}
+ RequestNameAndIconUpdate();
}
std::string ArcKioskAppService::GetAppId() {
AccountId account_id = multi_user_util::GetAccountIdFromProfile(profile_);
- const ArcKioskAppManager::ArcKioskApp* app =
- app_manager_->GetAppByAccountId(account_id);
+ const ArcKioskAppData* app = app_manager_->GetAppByAccountId(account_id);
if (!app)
return std::string();
std::unordered_set<std::string> app_ids =
- ArcAppListPrefs::Get(profile_)->GetAppsForPackage(
- app->app_info().package_name());
+ ArcAppListPrefs::Get(profile_)->GetAppsForPackage(app->app_id());
if (app_ids.empty())
return std::string();
// TODO(poromov@): Choose appropriate app id to launch. See

Powered by Google App Engine
This is Rietveld 408576698