Commit dc1a0243 authored by nancy's avatar nancy Committed by Commit Bot

Use AppServiceAppIconLoader to load icons for ARC apps.

This is the preparing for removing ArcAppIconLoader.
AppServiceAppIconLoader is used to replace ArcAppIconLoader to load app
icons for all apps.

AppServiceAppIconLoader doesn't call OnAppImageUpdated to update for
the default icon, so remove the DCHECK.

Fix the browser tests, because AppService uses mojom, so add run loop to
to wait AppService to load the app.

BUG=10161599

Change-Id: Ifbd799911016c386fb9b3b34bfd98bffbd5d9c75
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2081635
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#746253}
parent abafda3c
......@@ -14,6 +14,7 @@
#include "chrome/browser/chromeos/arc/icon_decode_request.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/app_service/app_service_app_icon_loader.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/grit/generated_resources.h"
......@@ -48,7 +49,7 @@ ArcAppShortcutSearchResult::ArcAppShortcutSearchResult(
icon_dimension);
icon_decode_request_->StartWithOptions(data_->icon_png);
badge_icon_loader_ = std::make_unique<ArcAppIconLoader>(
badge_icon_loader_ = std::make_unique<AppServiceAppIconLoader>(
profile_,
ash::AppListConfig::instance().search_tile_badge_icon_dimension(), this);
badge_icon_loader_->FetchImage(GetAppId());
......
......@@ -11,12 +11,12 @@
#include "ash/public/cpp/app_list/app_list_metrics.h"
#include "base/macros.h"
#include "chrome/browser/ui/app_icon_loader_delegate.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/app_list/search/chrome_search_result.h"
#include "components/arc/mojom/app.mojom.h"
#include "ui/gfx/image/image_skia.h"
class AppListControllerDelegate;
class AppServiceAppIconLoader;
class Profile;
namespace arc {
......@@ -54,7 +54,7 @@ class ArcAppShortcutSearchResult : public ChromeSearchResult,
arc::mojom::AppShortcutItemPtr data_;
std::unique_ptr<arc::IconDecodeRequest> icon_decode_request_;
std::unique_ptr<ArcAppIconLoader> badge_icon_loader_;
std::unique_ptr<AppServiceAppIconLoader> badge_icon_loader_;
Profile* const profile_; // Owned by ProfileInfo.
AppListControllerDelegate* const list_controller_; // Owned by AppListClient.
......
......@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_service/app_service_app_icon_loader.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/ash/launcher/arc_app_window_launcher_controller.h"
......@@ -107,7 +108,7 @@ void ArcAppWindow::OnAppImageUpdated(const std::string& app_id,
void ArcAppWindow::SetDefaultAppIcon() {
if (!app_icon_loader_) {
app_icon_loader_ = std::make_unique<ArcAppIconLoader>(
app_icon_loader_ = std::make_unique<AppServiceAppIconLoader>(
profile_, kArcAppWindowIconSize, this);
}
DCHECK(!image_fetching_);
......
......@@ -12,10 +12,11 @@
#include "base/macros.h"
#include "base/timer/timer.h"
#include "chrome/browser/image_decoder/image_decoder.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/app_icon_loader.h"
#include "chrome/browser/ui/ash/launcher/app_window_base.h"
#include "chrome/browser/ui/ash/launcher/arc_app_shelf_id.h"
class AppServiceAppIconLoader;
class ArcAppWindowDelegate;
namespace gfx {
......@@ -90,7 +91,7 @@ class ArcAppWindow : public AppWindowBase,
// Loads the ARC app icon to the window icon keys. Nullptr once a custom icon
// has been successfully set.
std::unique_ptr<ArcAppIconLoader> app_icon_loader_;
std::unique_ptr<AppServiceAppIconLoader> app_icon_loader_;
DISALLOW_COPY_AND_ASSIGN(ArcAppWindow);
};
......
......@@ -54,6 +54,7 @@
#include "chrome/browser/prefs/browser_prefs.h"
#include "chrome/browser/ui/app_icon_loader.h"
#include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_test.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
......
......@@ -10,7 +10,7 @@
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/app_list/app_list_controller_delegate.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/app_list/app_service/app_service_app_icon_loader.h"
#include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/app_list/arc/arc_usb_host_permission_manager.h"
......@@ -76,7 +76,7 @@ class ArcAppDialogView : public views::DialogDelegateView,
views::ImageView* icon_view_ = nullptr;
std::unique_ptr<ArcAppIconLoader> icon_loader_;
std::unique_ptr<AppServiceAppIconLoader> icon_loader_;
Profile* const profile_;
......@@ -137,12 +137,10 @@ ArcAppDialogView::ArcAppDialogView(Profile* profile,
if (!subheading_text.empty())
AddMultiLineLabel(text_container_ptr, subheading_text);
// The icon should be loaded synchronously (i.e. OnAppImageUpdated() will be
// directly called).
icon_loader_ = std::make_unique<ArcAppIconLoader>(
// The icon should be loaded asynchronously.
icon_loader_ = std::make_unique<AppServiceAppIconLoader>(
profile_, kIconSourceSize, this);
icon_loader_->FetchImage(app_id_);
DCHECK(!icon_view_->GetImage().isNull());
g_current_arc_app_dialog_view = this;
gfx::NativeWindow parent =
......
......@@ -10,6 +10,8 @@
#include "base/run_loop.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/profiles/profile.h"
......@@ -126,6 +128,12 @@ class ArcAppPermissionDialogViewBrowserTest
base::StringPrintf("fake.package.%d", id) /* package_name */,
id /* package_version */, id /* last_backup_android_id */,
0 /* last_backup_time */, false /* sync */));
// AppService uses mojom, so flush mojom calls to add the app to AppService.
auto* app_service_proxy =
apps::AppServiceProxyFactory::GetForProfile(profile());
ASSERT_TRUE(app_service_proxy);
app_service_proxy->FlushMojoCallsForTesting();
}
void set_accepted(bool accepted) { accepted_ = accepted; }
......
......@@ -6,7 +6,7 @@
#include "base/macros.h"
#include "chrome/browser/chromeos/arc/session/arc_session_manager.h"
#include "chrome/browser/ui/app_list/arc/arc_app_icon_loader.h"
#include "chrome/browser/ui/app_list/app_service/app_service_app_icon_loader.h"
#include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
......@@ -63,7 +63,7 @@ class DataRemovalConfirmationDialog : public views::DialogDelegateView,
// UI hierarchy owned.
views::ImageView* icon_view_ = nullptr;
std::unique_ptr<ArcAppIconLoader> icon_loader_;
std::unique_ptr<AppServiceAppIconLoader> icon_loader_;
Profile* const profile_;
......@@ -112,8 +112,8 @@ DataRemovalConfirmationDialog::DataRemovalConfirmationDialog(
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(std::move(label));
icon_loader_ =
std::make_unique<ArcAppIconLoader>(profile_, kArcAppIconSize, this);
icon_loader_ = std::make_unique<AppServiceAppIconLoader>(
profile_, kArcAppIconSize, this);
icon_loader_->FetchImage(kPlayStoreAppId);
chrome::RecordDialogCreation(
chrome::DialogIdentifier::ARC_DATA_REMOVAL_CONFIRMATION);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment