| 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..9f1a8c96b0ae2f48712b214b56688516bf54c3b4 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
|
| @@ -102,8 +102,7 @@ std::string ArcAppListPrefs::GetAppId(const std::string& package,
|
|
|
| ArcAppListPrefs::ArcAppListPrefs(const base::FilePath& base_path,
|
| PrefService* prefs)
|
| - : prefs_(prefs),
|
| - weak_ptr_factory_(this) {
|
| + : prefs_(prefs), binding_(this), weak_ptr_factory_(this) {
|
| base_path_ = base_path.AppendASCII(prefs::kArcApps);
|
|
|
| arc::ArcBridgeService* bridge_service = arc::ArcBridgeService::Get();
|
| @@ -113,14 +112,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 +167,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 +185,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 +252,28 @@ 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;
|
| + }
|
| +
|
| + arc::AppHostPtr host;
|
| + binding_.Bind(mojo::GetProxy(&host));
|
| + app_instance->Init(std::move(host));
|
| + 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 +316,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 +333,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 +348,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>>());
|
| }
|
|
|
|
|
|
|