| Index: chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
|
| diff --git a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
|
| index d5925004a34bd16020e3adf633f202573b18a1bd..39d7f1d6d9e21bb2fbe034ca9ca81f1b1cc57e3c 100644
|
| --- a/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
|
| +++ b/chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc
|
| @@ -113,14 +113,12 @@ ArcAppListPrefs::ArcAppListPrefs(const base::FilePath& base_path,
|
| }
|
|
|
| bridge_service->AddObserver(this);
|
| - bridge_service->AddAppObserver(this);
|
| OnStateChanged(bridge_service->state());
|
| }
|
|
|
| ArcAppListPrefs::~ArcAppListPrefs() {
|
| arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
|
| if (bridge_service) {
|
| - bridge_service->RemoveAppObserver(this);
|
| bridge_service->RemoveObserver(this);
|
| }
|
| }
|
| @@ -170,8 +168,13 @@ void ArcAppListPrefs::RequestIcon(const std::string& app_id,
|
| }
|
|
|
| arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
|
| - if (!bridge_service ||
|
| - bridge_service->state() != arc::ArcBridgeService::State::READY) {
|
| + if (!bridge_service) {
|
| + VLOG(2) << "Request to load icon when bridge service is not ready: "
|
| + << app_id << ".";
|
| + return;
|
| + }
|
| + arc::AppInstance* app_instance = bridge_service->app_instance();
|
| + if (!app_instance) {
|
| VLOG(2) << "Request to load icon when bridge service is not ready: "
|
| << app_id << ".";
|
| return;
|
| @@ -183,9 +186,8 @@ void ArcAppListPrefs::RequestIcon(const std::string& app_id,
|
| return;
|
| }
|
|
|
| - bridge_service->RequestAppIcon(app_info->package,
|
| - app_info->activity,
|
| - static_cast<arc::ScaleFactor>(scale_factor));
|
| + app_instance->RequestAppIcon(app_info->package, app_info->activity,
|
| + static_cast<arc::ScaleFactor>(scale_factor));
|
| }
|
|
|
| void ArcAppListPrefs::AddObserver(Observer* observer) {
|
| @@ -251,12 +253,25 @@ void ArcAppListPrefs::DisableAllApps() {
|
| }
|
|
|
| void ArcAppListPrefs::OnStateChanged(arc::ArcBridgeService::State state) {
|
| - if (state == arc::ArcBridgeService::State::READY)
|
| - arc::ArcBridgeService::Get()->RefreshAppList();
|
| - else
|
| + if (state != arc::ArcBridgeService::State::READY)
|
| DisableAllApps();
|
| }
|
|
|
| +void ArcAppListPrefs::OnAppInstanceReady() {
|
| + arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
|
| + if (!bridge_service) {
|
| + VLOG(2) << "Request to refresh app list when bridge service is not ready.";
|
| + return;
|
| + }
|
| + arc::AppInstance* app_instance = bridge_service->app_instance();
|
| + if (!app_instance) {
|
| + VLOG(2) << "Request to refresh app list when bridge service is not ready.";
|
| + return;
|
| + }
|
| +
|
| + app_instance->RefreshAppList();
|
| +}
|
| +
|
| void ArcAppListPrefs::OnAppReady(const arc::AppInfo& app) {
|
| if (app.name.get().empty() || app.package.get().empty() ||
|
| app.activity.get().empty()) {
|
| @@ -299,13 +314,12 @@ void ArcAppListPrefs::OnAppReady(const arc::AppInfo& app) {
|
| }
|
| }
|
|
|
| -void ArcAppListPrefs::OnAppListRefreshed(
|
| - const std::vector<arc::AppInfo>& apps) {
|
| +void ArcAppListPrefs::OnAppListRefreshed(mojo::Array<arc::AppInfoPtr> apps) {
|
| std::set<std::string> old_ready_apps;
|
| old_ready_apps.swap(ready_apps_);
|
|
|
| - for (auto& app : apps)
|
| - OnAppReady(app);
|
| + for (size_t i = 0; i < apps.size(); ++i)
|
| + OnAppReady(*apps[i]);
|
|
|
| // Detect unavailable apps after current refresh.
|
| for (auto& app_id : old_ready_apps) {
|
| @@ -317,12 +331,12 @@ void ArcAppListPrefs::OnAppListRefreshed(
|
| }
|
| }
|
|
|
| -void ArcAppListPrefs::OnAppIcon(const std::string& package,
|
| - const std::string& activity,
|
| +void ArcAppListPrefs::OnAppIcon(const mojo::String& package,
|
| + const mojo::String& activity,
|
| arc::ScaleFactor scale_factor,
|
| - const std::vector<uint8_t>& icon_png_data) {
|
| + mojo::Array<uint8_t> icon_png_data) {
|
| DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
|
| - DCHECK(!icon_png_data.empty());
|
| + DCHECK_NE(0u, icon_png_data.size());
|
| DCHECK(scale_factor >= arc::SCALE_FACTOR_SCALE_FACTOR_100P &&
|
| scale_factor < arc::SCALE_FACTOR_NUM_SCALE_FACTORS);
|
|
|
| @@ -332,9 +346,8 @@ void ArcAppListPrefs::OnAppIcon(const std::string& package,
|
| return;
|
| }
|
|
|
| - InstallIcon(app_id,
|
| - static_cast<ui::ScaleFactor>(scale_factor),
|
| - icon_png_data);
|
| + InstallIcon(app_id, static_cast<ui::ScaleFactor>(scale_factor),
|
| + icon_png_data.To<std::vector<uint8_t>>());
|
| }
|
|
|
|
|
|
|