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

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

Issue 2810053003: Reland of Fetch ARC Kiosk app name and icon from Android side. (Closed)
Patch Set: fix memory leak, reland the CL 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 d505ec21f8a885f6d8f51270467b1f84b6337561..71f17812231d3d24d3078f2a362365c8462e4941 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() {
VLOG(2) << "Preconditions for kiosk app changed";
app_id_ = GetAppId();
@@ -172,17 +197,16 @@ void ArcKioskAppService::PreconditionsChanged() {
VLOG(2) << "Kiosk app should be closed";
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
« no previous file with comments | « chrome/browser/chromeos/app_mode/arc/arc_kiosk_app_service.h ('k') | chrome/browser/chromeos/app_mode/kiosk_app_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698