Commit 7a75987d authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Generate the standard icons for windows.

When the adaptive icon feature (DD:go/appservice-adaptive-icon) is
enabled, call AppServiceProxy's LoadIcon interface to generate the
standard icons for windows . Those windows icons are shown on the mini
window to switch between windows when click alt+tab. For some Chrome
apps, those window icons could be used to set the Shelf icon.

Modify the browser tests LauncherPlatformAppBrowserTest.SetIcon to
increaset the callback count, because AppServiceProxy's load icon could
update the window's icon. Also add the checking for the icon image.

Modify the browser tests WebAppIconManagerBrowserTest.SingleIcon to
check for the standard icon image.

Tests:
1. Manul tests
2. LauncherPlatformAppBrowserTest.SetIcon is used to test the change for
chrome_native_app_window_view*
3. WebAppIconManagerBrowserTest.SingleIcon is used to test the change
for web_app_browser_controller.*
4. HostedAppTest.LoadIcon is used to test the change for
hosted_app_browser_controller.*

BUG=1113576

Change-Id: Icf3e6ad2cbf3d0c01e0f8e2fc29e5742c1cb59ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2344428
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797108}
parent e2b92cf1
# Copyright 2020 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
source_set("test_support") {
testonly = true
sources = [
"app_service_test.cc",
"app_service_test.h",
]
deps = [
"//chrome/test:test_support",
"//skia",
]
}
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/run_loop.h" #include "base/run_loop.h"
#include "chrome/browser/apps/app_service/app_service_proxy.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/apps/app_service/app_service_proxy_factory.h"
#include "ui/gfx/image/image_unittest_util.h"
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/apps/app_service/arc_apps.h" #include "chrome/browser/apps/app_service/arc_apps.h"
...@@ -55,6 +56,36 @@ std::string AppServiceTest::GetAppName(const std::string& app_id) const { ...@@ -55,6 +56,36 @@ std::string AppServiceTest::GetAppName(const std::string& app_id) const {
return name; return name;
} }
gfx::ImageSkia AppServiceTest::LoadAppIconBlocking(
apps::mojom::AppType app_type,
const std::string& app_id,
int32_t size_hint_in_dip) {
gfx::ImageSkia image_skia;
base::RunLoop run_loop;
base::OnceClosure load_app_icon_callback = run_loop.QuitClosure();
app_service_proxy_->LoadIcon(
app_type, app_id, apps::mojom::IconType::kStandard, size_hint_in_dip,
false /* allow_placeholder_icon */,
base::BindOnce(
[](gfx::ImageSkia* icon, base::OnceClosure load_app_icon_callback,
apps::mojom::IconValuePtr icon_value) {
DCHECK_EQ(apps::mojom::IconType::kStandard, icon_value->icon_type);
*icon = icon_value->uncompressed;
std::move(load_app_icon_callback).Run();
},
&image_skia, std::move(load_app_icon_callback)));
run_loop.Run();
return image_skia;
}
bool AppServiceTest::AreIconImageEqual(const gfx::ImageSkia& src,
const gfx::ImageSkia& dst) {
return gfx::test::AreBitmapsEqual(src.GetRepresentation(1.0f).GetBitmap(),
dst.GetRepresentation(1.0f).GetBitmap());
}
void AppServiceTest::WaitForAppService() { void AppServiceTest::WaitForAppService() {
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
} }
......
...@@ -10,6 +10,8 @@ ...@@ -10,6 +10,8 @@
#include <vector> #include <vector>
#include "base/macros.h" #include "base/macros.h"
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
#include "ui/gfx/image/image_skia.h"
class Profile; class Profile;
...@@ -29,6 +31,14 @@ class AppServiceTest { ...@@ -29,6 +31,14 @@ class AppServiceTest {
std::string GetAppName(const std::string& app_id) const; std::string GetAppName(const std::string& app_id) const;
// Synchronously fetches the icon for |app_id| of type |app_type| for the
// specified |size_hint_in_dp|, and blocks until the fetching is completed.
gfx::ImageSkia LoadAppIconBlocking(apps::mojom::AppType app_type,
const std::string& app_id,
int32_t size_hint_in_dip);
bool AreIconImageEqual(const gfx::ImageSkia& src, const gfx::ImageSkia& dst);
// Allow AppService async callbacks to run. // Allow AppService async callbacks to run.
void WaitForAppService(); void WaitForAppService();
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.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/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h" #include "chrome/browser/apps/app_service/browser_app_launcher.h"
#include "chrome/browser/apps/app_service/launch_utils.h" #include "chrome/browser/apps/app_service/launch_utils.h"
#include "chrome/browser/apps/platform_apps/app_browsertest_util.h" #include "chrome/browser/apps/platform_apps/app_browsertest_util.h"
...@@ -225,6 +226,7 @@ class LauncherPlatformAppBrowserTest ...@@ -225,6 +226,7 @@ class LauncherPlatformAppBrowserTest
controller_ = ChromeLauncherController::instance(); controller_ = ChromeLauncherController::instance();
ASSERT_TRUE(controller_); ASSERT_TRUE(controller_);
extensions::PlatformAppBrowserTest::SetUpOnMainThread(); extensions::PlatformAppBrowserTest::SetUpOnMainThread();
app_service_test_.SetUp(browser()->profile());
} }
ash::ShelfModel* shelf_model() { return controller_->shelf_model(); } ash::ShelfModel* shelf_model() { return controller_->shelf_model(); }
...@@ -243,9 +245,13 @@ class LauncherPlatformAppBrowserTest ...@@ -243,9 +245,13 @@ class LauncherPlatformAppBrowserTest
return shelf_model()->GetShelfItemDelegate(id); return shelf_model()->GetShelfItemDelegate(id);
} }
apps::AppServiceTest& app_service_test() { return app_service_test_; }
ChromeLauncherController* controller_; ChromeLauncherController* controller_;
private: private:
apps::AppServiceTest app_service_test_;
DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest); DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest);
}; };
...@@ -876,21 +882,45 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { ...@@ -876,21 +882,45 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) {
int base_shelf_item_count = shelf_model()->item_count(); int base_shelf_item_count = shelf_model()->item_count();
ExtensionTestMessageListener ready_listener("ready", true); ExtensionTestMessageListener ready_listener("ready", true);
LoadAndLaunchPlatformApp("app_icon", "Launched"); const Extension* extension = LoadAndLaunchPlatformApp("app_icon", "Launched");
ASSERT_TRUE(extension);
gfx::ImageSkia image_skia;
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
int32_t size_hint_in_dip = 48;
image_skia = app_service_test().LoadAppIconBlocking(
apps::mojom::AppType::kExtension, extension->id(), size_hint_in_dip);
}
// Create non-shelf window. // Create non-shelf window.
EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
ready_listener.Reply("createNonShelfWindow"); ready_listener.Reply("createNonShelfWindow");
ready_listener.Reset(); ready_listener.Reset();
// Default app icon + extension icon updates. if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
test_observer.WaitForIconUpdates(2); // Default app icon + extension icon updates + AppServiceProxy load icon
// updates.
test_observer.WaitForIconUpdates(3);
EXPECT_TRUE(app_service_test().AreIconImageEqual(
image_skia, test_observer.last_app_icon()));
} else {
// Default app icon + extension icon updates.
test_observer.WaitForIconUpdates(2);
}
// Create shelf window. // Create shelf window.
EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
ready_listener.Reply("createShelfWindow"); ready_listener.Reply("createShelfWindow");
ready_listener.Reset(); ready_listener.Reset();
// Default app icon + extension icon updates. if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
test_observer.WaitForIconUpdates(2); // Default app icon + extension icon updates + AppServiceProxy load icon
// updates.
test_observer.WaitForIconUpdates(3);
EXPECT_TRUE(app_service_test().AreIconImageEqual(
image_skia, test_observer.last_app_icon()));
} else {
// Default app icon + extension icon updates.
test_observer.WaitForIconUpdates(2);
}
// Set shelf window icon. // Set shelf window icon.
EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
...@@ -903,8 +933,15 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { ...@@ -903,8 +933,15 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) {
EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
ready_listener.Reply("createShelfWindowWithCustomIcon"); ready_listener.Reply("createShelfWindowWithCustomIcon");
ready_listener.Reset(); ready_listener.Reset();
// Default app icon + extension icon + custom icon updates. if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
test_observer.WaitForIconUpdates(3); // Default app icon + extension icon + AppServiceProxy load icon + custom
// icon updates.
test_observer.WaitForIconUpdates(4);
} else {
// Default app icon + extension icon + custom icon updates.
test_observer.WaitForIconUpdates(3);
}
const gfx::ImageSkia app_item_custom_image = test_observer.last_app_icon(); const gfx::ImageSkia app_item_custom_image = test_observer.last_app_icon();
const int shelf_item_count = shelf_model()->item_count(); const int shelf_item_count = shelf_model()->item_count();
...@@ -935,7 +972,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) { ...@@ -935,7 +972,13 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) {
// No more icon updates. // No more icon updates.
base::RunLoop().RunUntilIdle(); base::RunLoop().RunUntilIdle();
EXPECT_EQ(8, test_observer.icon_updates()); if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
// 3 + 3 + 1 + 4
EXPECT_EQ(11, test_observer.icon_updates());
} else {
// 2 + 2 + 1 + 3
EXPECT_EQ(8, test_observer.icon_updates());
}
// Exit. // Exit.
EXPECT_TRUE(ready_listener.WaitUntilSatisfied()); EXPECT_TRUE(ready_listener.WaitUntilSatisfied());
......
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include "chrome/browser/ui/extensions/hosted_app_browser_controller.h" #include "chrome/browser/ui/extensions/hosted_app_browser_controller.h"
#include "base/strings/utf_string_conversions.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/extensions/extension_util.h" #include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/extensions/tab_helper.h" #include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/installable/installable_manager.h" #include "chrome/browser/installable/installable_manager.h"
...@@ -70,6 +72,25 @@ bool HostedAppBrowserController::HasMinimalUiButtons() const { ...@@ -70,6 +72,25 @@ bool HostedAppBrowserController::HasMinimalUiButtons() const {
gfx::ImageSkia HostedAppBrowserController::GetWindowAppIcon() const { gfx::ImageSkia HostedAppBrowserController::GetWindowAppIcon() const {
// TODO(calamity): Use the app name to retrieve the app icon without using the // TODO(calamity): Use the app name to retrieve the app icon without using the
// extensions tab helper to make icon load more immediate. // extensions tab helper to make icon load more immediate.
#if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon) &&
apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(
browser()->profile())) {
if (!app_icon_.isNull())
return app_icon_;
const Extension* extension = GetExtension();
if (extension &&
apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->AppRegistryCache()
.GetAppType(extension->id()) !=
apps::mojom::AppType::kUnknown) {
LoadAppIcon(true /* allow_placeholder_icon */);
return GetFallbackAppIcon();
}
}
#endif
content::WebContents* contents = content::WebContents* contents =
browser()->tab_strip_model()->GetActiveWebContents(); browser()->tab_strip_model()->GetActiveWebContents();
if (!contents) if (!contents)
...@@ -226,4 +247,25 @@ void HostedAppBrowserController::OnTabRemoved(content::WebContents* contents) { ...@@ -226,4 +247,25 @@ void HostedAppBrowserController::OnTabRemoved(content::WebContents* contents) {
web_app::ClearAppPrefsForWebContents(contents); web_app::ClearAppPrefsForWebContents(contents);
} }
void HostedAppBrowserController::LoadAppIcon(
bool allow_placeholder_icon) const {
apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->LoadIcon(apps::mojom::AppType::kExtension, GetExtension()->id(),
apps::mojom::IconType::kStandard,
extension_misc::EXTENSION_ICON_SMALL, allow_placeholder_icon,
base::BindOnce(&HostedAppBrowserController::OnLoadIcon,
weak_ptr_factory_.GetWeakPtr()));
}
void HostedAppBrowserController::OnLoadIcon(
apps::mojom::IconValuePtr icon_value) {
if (icon_value->icon_type != apps::mojom::IconType::kStandard)
return;
app_icon_ = icon_value->uncompressed;
if (icon_value->is_placeholder_icon)
LoadAppIcon(false /* allow_placeholder_icon */);
}
} // namespace extensions } // namespace extensions
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "chrome/browser/extensions/extension_uninstall_dialog.h" #include "chrome/browser/extensions/extension_uninstall_dialog.h"
#include "chrome/browser/ui/tabs/tab_strip_model_observer.h" #include "chrome/browser/ui/tabs/tab_strip_model_observer.h"
#include "chrome/browser/ui/web_applications/app_browser_controller.h" #include "chrome/browser/ui/web_applications/app_browser_controller.h"
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
class Browser; class Browser;
...@@ -62,8 +63,16 @@ class HostedAppBrowserController : public web_app::AppBrowserController, ...@@ -62,8 +63,16 @@ class HostedAppBrowserController : public web_app::AppBrowserController,
// Will return nullptr if the extension has been uninstalled. // Will return nullptr if the extension has been uninstalled.
const Extension* GetExtension() const; const Extension* GetExtension() const;
// Helper function to call AppServiceProxy to load icon.
void LoadAppIcon(bool allow_placeholder_icon) const;
// Invoked when the icon is loaded.
void OnLoadIcon(apps::mojom::IconValuePtr icon_value);
gfx::ImageSkia app_icon_;
std::unique_ptr<ExtensionUninstallDialog> uninstall_dialog_; std::unique_ptr<ExtensionUninstallDialog> uninstall_dialog_;
base::WeakPtrFactory<HostedAppBrowserController> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserController); DISALLOW_COPY_AND_ASSIGN(HostedAppBrowserController);
}; };
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "base/values.h" #include "base/values.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/extensions/extension_browsertest.h" #include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/predictors/loading_predictor_config.h" #include "chrome/browser/predictors/loading_predictor_config.h"
#include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h" #include "chrome/browser/renderer_context_menu/render_view_context_menu_test_util.h"
...@@ -282,6 +283,8 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest, ...@@ -282,6 +283,8 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest,
web_app::WebAppProviderBase::GetProviderBase(profile()) web_app::WebAppProviderBase::GetProviderBase(profile())
->shortcut_manager() ->shortcut_manager()
.SuppressShortcutsForTesting(); .SuppressShortcutsForTesting();
app_service_test_.SetUp(profile());
} }
// Tests that performing |action| results in a new foreground tab // Tests that performing |action| results in a new foreground tab
...@@ -313,6 +316,8 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest, ...@@ -313,6 +316,8 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest,
return provider->registrar(); return provider->registrar();
} }
apps::AppServiceTest& app_service_test() { return app_service_test_; }
std::string app_id_; std::string app_id_;
Browser* app_browser_; Browser* app_browser_;
...@@ -327,6 +332,7 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest, ...@@ -327,6 +332,7 @@ class HostedOrWebAppTest : public extensions::ExtensionBrowserTest,
private: private:
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
AppType app_type_; AppType app_type_;
apps::AppServiceTest app_service_test_;
net::EmbeddedTestServer https_server_; net::EmbeddedTestServer https_server_;
// Similar to net::MockCertVerifier, but also updates the CertVerifier // Similar to net::MockCertVerifier, but also updates the CertVerifier
...@@ -470,6 +476,21 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, NotWebApp) { ...@@ -470,6 +476,21 @@ IN_PROC_BROWSER_TEST_P(HostedAppTest, NotWebApp) {
EXPECT_FALSE(app->from_bookmark()); EXPECT_FALSE(app->from_bookmark());
} }
#if defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_P(HostedAppTest, LoadIcon) {
if (!base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon))
return;
SetupApp("hosted_app");
EXPECT_TRUE(app_service_test().AreIconImageEqual(
app_service_test().LoadAppIconBlocking(
apps::mojom::AppType::kExtension, app_id_,
extension_misc::EXTENSION_ICON_SMALL),
app_browser_->app_controller()->GetWindowAppIcon()));
}
#endif
class HostedAppTestWithAutoupgradesDisabled : public HostedOrWebAppTest { class HostedAppTestWithAutoupgradesDisabled : public HostedOrWebAppTest {
public: public:
void SetUpCommandLine(base::CommandLine* command_line) override { void SetUpCommandLine(base::CommandLine* command_line) override {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/zoom/page_zoom.h" #include "components/zoom/page_zoom.h"
#include "components/zoom/zoom_controller.h" #include "components/zoom/zoom_controller.h"
#include "extensions/browser/app_window/app_delegate.h" #include "extensions/browser/app_window/app_delegate.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_operations.h" #include "ui/gfx/image/image_skia_operations.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/views/controls/webview/webview.h" #include "ui/views/controls/webview/webview.h"
...@@ -229,7 +230,7 @@ ui::ZOrderLevel ChromeNativeAppWindowViews::GetZOrderLevel() const { ...@@ -229,7 +230,7 @@ ui::ZOrderLevel ChromeNativeAppWindowViews::GetZOrderLevel() const {
gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() { gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() {
// Resulting icon is cached in aura::client::kAppIconKey window property. // Resulting icon is cached in aura::client::kAppIconKey window property.
const gfx::Image& custom_image = app_window()->custom_app_icon(); const gfx::Image& custom_image = GetCustomImage();
if (app_window()->app_icon_url().is_valid() && if (app_window()->app_icon_url().is_valid() &&
app_window()->show_in_shelf()) { app_window()->show_in_shelf()) {
EnsureAppIconCreated(); EnsureAppIconCreated();
...@@ -246,16 +247,16 @@ gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() { ...@@ -246,16 +247,16 @@ gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowAppIcon() {
base_image.AsImageSkia(), skia::ImageOperations::RESIZE_BEST, base_image.AsImageSkia(), skia::ImageOperations::RESIZE_BEST,
gfx::Size(large_icon_size, large_icon_size)); gfx::Size(large_icon_size, large_icon_size));
return gfx::ImageSkiaOperations::CreateIconWithBadge( return gfx::ImageSkiaOperations::CreateIconWithBadge(
resized_image, app_icon_->image_skia()); resized_image, GetAppIconImage().AsImageSkia());
} }
return gfx::ImageSkiaOperations::CreateIconWithBadge( return gfx::ImageSkiaOperations::CreateIconWithBadge(
base_image.AsImageSkia(), app_icon_->image_skia()); base_image.AsImageSkia(), GetAppIconImage().AsImageSkia());
} }
if (!custom_image.IsEmpty()) if (!custom_image.IsEmpty())
return *custom_image.ToImageSkia(); return *custom_image.ToImageSkia();
EnsureAppIconCreated(); EnsureAppIconCreated();
return app_icon_->image_skia(); return GetAppIconImage().AsImageSkia();
} }
gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() { gfx::ImageSkia ChromeNativeAppWindowViews::GetWindowIcon() {
...@@ -371,6 +372,15 @@ void ChromeNativeAppWindowViews::InitializeWindow( ...@@ -371,6 +372,15 @@ void ChromeNativeAppWindowViews::InitializeWindow(
extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, nullptr); extensions::ExtensionKeybindingRegistry::PLATFORM_APPS_ONLY, nullptr);
} }
gfx::Image ChromeNativeAppWindowViews::GetCustomImage() {
return app_window()->custom_app_icon();
}
gfx::Image ChromeNativeAppWindowViews::GetAppIconImage() {
DCHECK(app_icon_);
return gfx::Image(app_icon_->image_skia());
}
void ChromeNativeAppWindowViews::EnsureAppIconCreated() { void ChromeNativeAppWindowViews::EnsureAppIconCreated() {
if (app_icon_ && app_icon_->IsValid()) if (app_icon_ && app_icon_->IsValid())
return; return;
......
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
#include "chrome/browser/extensions/chrome_app_icon_delegate.h" #include "chrome/browser/extensions/chrome_app_icon_delegate.h"
#include "extensions/components/native_app_window/native_app_window_views.h" #include "extensions/components/native_app_window/native_app_window_views.h"
namespace gfx {
class ImageSkia;
}
class ExtensionKeybindingRegistryViews; class ExtensionKeybindingRegistryViews;
class ChromeNativeAppWindowViews class ChromeNativeAppWindowViews
...@@ -71,10 +75,13 @@ class ChromeNativeAppWindowViews ...@@ -71,10 +75,13 @@ class ChromeNativeAppWindowViews
extensions::AppWindow* app_window, extensions::AppWindow* app_window,
const extensions::AppWindow::CreateParams& create_params) override; const extensions::AppWindow::CreateParams& create_params) override;
private: virtual gfx::Image GetCustomImage();
virtual gfx::Image GetAppIconImage();
// Ensures that the Chrome app icon is created. // Ensures that the Chrome app icon is created.
void EnsureAppIconCreated(); virtual void EnsureAppIconCreated();
private:
// extensions::ChromeAppIconDelegate: // extensions::ChromeAppIconDelegate:
void OnIconUpdated(extensions::ChromeAppIcon* icon) override; void OnIconUpdated(extensions::ChromeAppIcon* icon) override;
......
...@@ -20,15 +20,20 @@ ...@@ -20,15 +20,20 @@
#include "ash/public/cpp/window_state_type.h" #include "ash/public/cpp/window_state_type.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h" #include "base/logging.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/note_taking_helper.h" #include "chrome/browser/chromeos/note_taking_helper.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profiles_state.h" #include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/ui/app_list/icon_standardizer.h"
#include "chrome/browser/ui/ash/ash_util.h" #include "chrome/browser/ui/ash/ash_util.h"
#include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h" #include "chrome/browser/ui/ash/multi_user/multi_user_context_menu.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views.h" #include "chrome/browser/ui/views/exclusive_access_bubble_views.h"
#include "chrome/common/chrome_features.h"
#include "chrome/common/extensions/extension_constants.h" #include "chrome/common/extensions/extension_constants.h"
#include "components/session_manager/core/session_manager.h" #include "components/session_manager/core/session_manager.h"
#include "extensions/browser/app_window/app_delegate.h"
#include "extensions/common/constants.h" #include "extensions/common/constants.h"
#include "ui/aura/client/aura_constants.h" #include "ui/aura/client/aura_constants.h"
#include "ui/base/hit_test.h" #include "ui/base/hit_test.h"
...@@ -37,6 +42,7 @@ ...@@ -37,6 +42,7 @@
#include "ui/display/screen.h" #include "ui/display/screen.h"
#include "ui/events/event_constants.h" #include "ui/events/event_constants.h"
#include "ui/events/keycodes/keyboard_codes.h" #include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/skia_util.h" #include "ui/gfx/skia_util.h"
#include "ui/views/controls/menu/menu_model_adapter.h" #include "ui/views/controls/menu/menu_model_adapter.h"
#include "ui/views/controls/menu/menu_runner.h" #include "ui/views/controls/menu/menu_runner.h"
...@@ -157,6 +163,16 @@ ui::ModalType ChromeNativeAppWindowViewsAuraAsh::GetModalType() const { ...@@ -157,6 +163,16 @@ ui::ModalType ChromeNativeAppWindowViewsAuraAsh::GetModalType() const {
return ChromeNativeAppWindowViewsAura::GetModalType(); return ChromeNativeAppWindowViewsAura::GetModalType();
} }
gfx::ImageSkia ChromeNativeAppWindowViewsAuraAsh::GetWindowIcon() {
if (!base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon))
return ChromeNativeAppWindowViews::GetWindowIcon();
const gfx::ImageSkia& image_skia =
ChromeNativeAppWindowViews::GetWindowIcon();
return !image_skia.isNull() ? app_list::CreateStandardIconImage(image_skia)
: gfx::ImageSkia();
}
bool ChromeNativeAppWindowViewsAuraAsh::ShouldRemoveStandardFrame() { bool ChromeNativeAppWindowViewsAuraAsh::ShouldRemoveStandardFrame() {
if (IsFrameless()) if (IsFrameless())
return true; return true;
...@@ -189,6 +205,10 @@ void ChromeNativeAppWindowViewsAuraAsh:: ...@@ -189,6 +205,10 @@ void ChromeNativeAppWindowViewsAuraAsh::
work_area.bottom() - out_bounds->height())); work_area.bottom() - out_bounds->height()));
} }
void ChromeNativeAppWindowViewsAuraAsh::EnsureAppIconCreated() {
LoadAppIcon(true /* allow_placeholder_icon */);
}
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// ui::BaseWindow implementation: // ui::BaseWindow implementation:
gfx::Rect ChromeNativeAppWindowViewsAuraAsh::GetRestoredBounds() const { gfx::Rect ChromeNativeAppWindowViewsAuraAsh::GetRestoredBounds() const {
...@@ -558,3 +578,58 @@ void ChromeNativeAppWindowViewsAuraAsh::UpdateImmersiveMode() { ...@@ -558,3 +578,58 @@ void ChromeNativeAppWindowViewsAuraAsh::UpdateImmersiveMode() {
ash::ImmersiveFullscreenController::EnableForWidget( ash::ImmersiveFullscreenController::EnableForWidget(
widget(), ShouldEnableImmersiveMode()); widget(), ShouldEnableImmersiveMode());
} }
gfx::Image ChromeNativeAppWindowViewsAuraAsh::GetCustomImage() {
if (!base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon))
return ChromeNativeAppWindowViews::GetCustomImage();
gfx::Image image = ChromeNativeAppWindowViews::GetCustomImage();
return !image.IsEmpty() ? gfx::Image(app_list::CreateStandardIconImage(
image.AsImageSkia()))
: gfx::Image();
}
gfx::Image ChromeNativeAppWindowViewsAuraAsh::GetAppIconImage() {
if (!app_icon_image_skia_.isNull())
return gfx::Image(app_icon_image_skia_);
return ChromeNativeAppWindowViews::GetAppIconImage();
}
void ChromeNativeAppWindowViewsAuraAsh::LoadAppIcon(
bool allow_placeholder_icon) {
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon) &&
apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(
Profile::FromBrowserContext(app_window()->browser_context()))) {
apps::AppServiceProxy* proxy = apps::AppServiceProxyFactory::GetForProfile(
Profile::FromBrowserContext(app_window()->browser_context()));
apps::mojom::AppType app_type =
proxy->AppRegistryCache().GetAppType(app_window()->extension_id());
if (app_type != apps::mojom::AppType::kUnknown) {
proxy->LoadIcon(
app_type, app_window()->extension_id(),
apps::mojom::IconType::kStandard,
app_window()->app_delegate()->PreferredIconSize(),
allow_placeholder_icon,
base::BindOnce(&ChromeNativeAppWindowViewsAuraAsh::OnLoadIcon,
weak_ptr_factory_.GetWeakPtr()));
}
}
// Ensures the Chrome app icon is created to generate the default app icon.
// Otherwise, the test cases are broken.
ChromeNativeAppWindowViews::EnsureAppIconCreated();
}
void ChromeNativeAppWindowViewsAuraAsh::OnLoadIcon(
apps::mojom::IconValuePtr icon_value) {
if (icon_value->icon_type != apps::mojom::IconType::kStandard)
return;
app_icon_image_skia_ = icon_value->uncompressed;
if (icon_value->is_placeholder_icon)
LoadAppIcon(false /* allow_placeholder_icon */);
}
...@@ -12,15 +12,21 @@ ...@@ -12,15 +12,21 @@
#include "ash/wm/window_state.h" #include "ash/wm/window_state.h"
#include "ash/wm/window_state_observer.h" #include "ash/wm/window_state_observer.h"
#include "base/gtest_prod_util.h" #include "base/gtest_prod_util.h"
#include "base/memory/weak_ptr.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h" #include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h" #include "chrome/browser/ui/views/apps/chrome_native_app_window_views_aura.h"
#include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h" #include "chrome/browser/ui/views/exclusive_access_bubble_views_context.h"
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/aura/window_observer.h" #include "ui/aura/window_observer.h"
#include "ui/base/accelerators/accelerator.h" #include "ui/base/accelerators/accelerator.h"
#include "ui/views/context_menu_controller.h" #include "ui/views/context_menu_controller.h"
namespace gfx {
class ImageSkia;
}
namespace ui { namespace ui {
class MenuModel; class MenuModel;
} }
...@@ -63,6 +69,7 @@ class ChromeNativeAppWindowViewsAuraAsh ...@@ -63,6 +69,7 @@ class ChromeNativeAppWindowViewsAuraAsh
bool ShouldRemoveStandardFrame() override; bool ShouldRemoveStandardFrame() override;
void AdjustBoundsToBeVisibleOnDisplayForNewWindows( void AdjustBoundsToBeVisibleOnDisplayForNewWindows(
gfx::Rect* out_bounds) override; gfx::Rect* out_bounds) override;
void EnsureAppIconCreated() override;
// ui::BaseWindow: // ui::BaseWindow:
gfx::Rect GetRestoredBounds() const override; gfx::Rect GetRestoredBounds() const override;
...@@ -78,6 +85,7 @@ class ChromeNativeAppWindowViewsAuraAsh ...@@ -78,6 +85,7 @@ class ChromeNativeAppWindowViewsAuraAsh
std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView( std::unique_ptr<views::NonClientFrameView> CreateNonClientFrameView(
views::Widget* widget) override; views::Widget* widget) override;
ui::ModalType GetModalType() const override; ui::ModalType GetModalType() const override;
gfx::ImageSkia GetWindowIcon() override;
// NativeAppWindow: // NativeAppWindow:
void SetFullscreen(int fullscreen_types) override; void SetFullscreen(int fullscreen_types) override;
...@@ -167,6 +175,18 @@ class ChromeNativeAppWindowViewsAuraAsh ...@@ -167,6 +175,18 @@ class ChromeNativeAppWindowViewsAuraAsh
// app's and window manager's state. // app's and window manager's state.
void UpdateImmersiveMode(); void UpdateImmersiveMode();
// Generates the standard custom icon
gfx::Image GetCustomImage() override;
// Generates the standard app icon
gfx::Image GetAppIconImage() override;
// Helper function to call AppServiceProxy to load icon.
void LoadAppIcon(bool allow_placeholder_icon);
// Invoked when the icon is loaded.
void OnLoadIcon(apps::mojom::IconValuePtr icon_value);
gfx::ImageSkia app_icon_image_skia_;
// Used to show the system menu. // Used to show the system menu.
std::unique_ptr<ui::MenuModel> menu_model_; std::unique_ptr<ui::MenuModel> menu_model_;
std::unique_ptr<views::MenuRunner> menu_runner_; std::unique_ptr<views::MenuRunner> menu_runner_;
...@@ -182,6 +202,9 @@ class ChromeNativeAppWindowViewsAuraAsh ...@@ -182,6 +202,9 @@ class ChromeNativeAppWindowViewsAuraAsh
ScopedObserver<ash::WindowState, ash::WindowStateObserver> ScopedObserver<ash::WindowState, ash::WindowStateObserver>
observed_window_state_{this}; observed_window_state_{this};
base::WeakPtrFactory<ChromeNativeAppWindowViewsAuraAsh> weak_ptr_factory_{
this};
DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViewsAuraAsh); DISALLOW_COPY_AND_ASSIGN(ChromeNativeAppWindowViewsAuraAsh);
}; };
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
#include "chrome/browser/chromeos/crostini/crostini_terminal.h" #include "chrome/browser/chromeos/crostini/crostini_terminal.h"
#include "chrome/browser/ui/app_list/icon_standardizer.h"
#endif #endif
namespace { namespace {
...@@ -471,8 +472,13 @@ void AppBrowserController::OnTabRemoved(content::WebContents* contents) {} ...@@ -471,8 +472,13 @@ void AppBrowserController::OnTabRemoved(content::WebContents* contents) {}
gfx::ImageSkia AppBrowserController::GetFallbackAppIcon() const { gfx::ImageSkia AppBrowserController::GetFallbackAppIcon() const {
gfx::ImageSkia page_icon = browser()->GetCurrentPageIcon().AsImageSkia(); gfx::ImageSkia page_icon = browser()->GetCurrentPageIcon().AsImageSkia();
if (!page_icon.isNull()) if (!page_icon.isNull()) {
#if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon))
return app_list::CreateStandardIconImage(page_icon);
#endif
return page_icon; return page_icon;
}
// The icon may be loading still. Return a transparent icon rather // The icon may be loading still. Return a transparent icon rather
// than using a placeholder to avoid flickering. // than using a placeholder to avoid flickering.
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/bind_helpers.h" #include "base/bind_helpers.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.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/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h" #include "chrome/browser/ui/browser_commands.h"
...@@ -17,6 +19,7 @@ ...@@ -17,6 +19,7 @@
#include "chrome/browser/web_applications/components/web_app_constants.h" #include "chrome/browser/web_applications/components/web_app_constants.h"
#include "chrome/browser/web_applications/components/web_app_helpers.h" #include "chrome/browser/web_applications/components/web_app_helpers.h"
#include "chrome/browser/web_applications/web_app_provider.h" #include "chrome/browser/web_applications/web_app_provider.h"
#include "chrome/common/chrome_features.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "ui/gfx/favicon_size.h" #include "ui/gfx/favicon_size.h"
#include "ui/gfx/image/image.h" #include "ui/gfx/image/image.h"
...@@ -99,6 +102,15 @@ gfx::ImageSkia WebAppBrowserController::GetWindowAppIcon() const { ...@@ -99,6 +102,15 @@ gfx::ImageSkia WebAppBrowserController::GetWindowAppIcon() const {
return *app_icon_; return *app_icon_;
app_icon_ = GetFallbackAppIcon(); app_icon_ = GetFallbackAppIcon();
#if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon) &&
apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(
browser()->profile())) {
LoadAppIcon(true /* allow_placeholder_icon */);
return *app_icon_;
}
#endif
if (provider_.icon_manager().HasSmallestIcon(GetAppId(), if (provider_.icon_manager().HasSmallestIcon(GetAppId(),
web_app::kWebAppIconSmall)) { web_app::kWebAppIconSmall)) {
provider_.icon_manager().ReadSmallestIcon( provider_.icon_manager().ReadSmallestIcon(
...@@ -211,6 +223,30 @@ const AppRegistrar& WebAppBrowserController::registrar() const { ...@@ -211,6 +223,30 @@ const AppRegistrar& WebAppBrowserController::registrar() const {
return provider_.registrar(); return provider_.registrar();
} }
void WebAppBrowserController::LoadAppIcon(bool allow_placeholder_icon) const {
apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->LoadIcon(apps::mojom::AppType::kWeb, GetAppId(),
apps::mojom::IconType::kStandard, web_app::kWebAppIconSmall,
allow_placeholder_icon,
base::BindOnce(&WebAppBrowserController::OnLoadIcon,
weak_ptr_factory_.GetWeakPtr()));
}
void WebAppBrowserController::OnLoadIcon(apps::mojom::IconValuePtr icon_value) {
if (icon_value->icon_type != apps::mojom::IconType::kStandard)
return;
app_icon_ = icon_value->uncompressed;
if (icon_value->is_placeholder_icon)
LoadAppIcon(false /* allow_placeholder_icon */);
if (auto* contents = web_contents())
contents->NotifyNavigationStateChanged(content::INVALIDATE_TYPE_TAB);
if (callback_for_testing_)
std::move(callback_for_testing_).Run();
}
void WebAppBrowserController::OnReadIcon(const SkBitmap& bitmap) { void WebAppBrowserController::OnReadIcon(const SkBitmap& bitmap) {
if (bitmap.empty()) { if (bitmap.empty()) {
DLOG(ERROR) << "Failed to read icon for web app"; DLOG(ERROR) << "Failed to read icon for web app";
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/browser/web_applications/components/app_registrar.h" #include "chrome/browser/web_applications/components/app_registrar.h"
#include "chrome/browser/web_applications/components/app_registrar_observer.h" #include "chrome/browser/web_applications/components/app_registrar_observer.h"
#include "chrome/browser/web_applications/components/web_app_id.h" #include "chrome/browser/web_applications/components/web_app_id.h"
#include "components/services/app_service/public/mojom/types.mojom-forward.h"
#include "third_party/skia/include/core/SkColor.h" #include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/image/image_skia.h" #include "ui/gfx/image/image_skia.h"
...@@ -83,6 +84,11 @@ class WebAppBrowserController : public AppBrowserController, ...@@ -83,6 +84,11 @@ class WebAppBrowserController : public AppBrowserController,
private: private:
const AppRegistrar& registrar() const; const AppRegistrar& registrar() const;
// Helper function to call AppServiceProxy to load icon.
void LoadAppIcon(bool allow_placeholder_icon) const;
// Invoked when the icon is loaded.
void OnLoadIcon(apps::mojom::IconValuePtr icon_value);
void OnReadIcon(const SkBitmap& bitmap); void OnReadIcon(const SkBitmap& bitmap);
void PerformDigitalAssetLinkVerification(Browser* browser); void PerformDigitalAssetLinkVerification(Browser* browser);
......
...@@ -264,6 +264,7 @@ source_set("web_applications_browser_tests") { ...@@ -264,6 +264,7 @@ source_set("web_applications_browser_tests") {
":web_applications_on_extensions_test_support", ":web_applications_on_extensions_test_support",
":web_applications_test_support", ":web_applications_test_support",
"//chrome/app:command_ids", "//chrome/app:command_ids",
"//chrome/browser/apps/app_service:test_support",
"//chrome/browser/extensions:test_support", "//chrome/browser/extensions:test_support",
"//chrome/browser/web_applications/components", "//chrome/browser/web_applications/components",
"//chrome/browser/web_applications/extensions", "//chrome/browser/web_applications/extensions",
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "chrome/browser/apps/app_service/app_launch_params.h" #include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/apps/app_service/app_service_proxy.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/apps/app_service/app_service_proxy_factory.h"
#include "chrome/browser/apps/app_service/app_service_test.h"
#include "chrome/browser/apps/app_service/browser_app_launcher.h" #include "chrome/browser/apps/app_service/browser_app_launcher.h"
#include "chrome/browser/installable/installable_metrics.h" #include "chrome/browser/installable/installable_metrics.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
...@@ -45,15 +46,22 @@ class WebAppIconManagerBrowserTest : public InProcessBrowserTest { ...@@ -45,15 +46,22 @@ class WebAppIconManagerBrowserTest : public InProcessBrowserTest {
protected: protected:
net::EmbeddedTestServer* https_server() { return &https_server_; } net::EmbeddedTestServer* https_server() { return &https_server_; }
void SetUpOnMainThread() override {
app_service_test_.SetUp(browser()->profile());
}
// InProcessBrowserTest: // InProcessBrowserTest:
void SetUp() override { void SetUp() override {
https_server_.AddDefaultHandlers(GetChromeTestDataDir()); https_server_.AddDefaultHandlers(GetChromeTestDataDir());
InProcessBrowserTest::SetUp(); InProcessBrowserTest::SetUp();
} }
apps::AppServiceTest& app_service_test() { return app_service_test_; }
private: private:
base::test::ScopedFeatureList scoped_feature_list_; base::test::ScopedFeatureList scoped_feature_list_;
net::EmbeddedTestServer https_server_; net::EmbeddedTestServer https_server_;
apps::AppServiceTest app_service_test_;
DISALLOW_COPY_AND_ASSIGN(WebAppIconManagerBrowserTest); DISALLOW_COPY_AND_ASSIGN(WebAppIconManagerBrowserTest);
}; };
...@@ -99,6 +107,15 @@ IN_PROC_BROWSER_TEST_F(WebAppIconManagerBrowserTest, SingleIcon) { ...@@ -99,6 +107,15 @@ IN_PROC_BROWSER_TEST_F(WebAppIconManagerBrowserTest, SingleIcon) {
run_loop.Run(); run_loop.Run();
} }
#if defined(OS_CHROMEOS)
gfx::ImageSkia image_skia;
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
app_service_test().FlushMojoCalls();
image_skia = app_service_test().LoadAppIconBlocking(
apps::mojom::AppType::kWeb, app_id, web_app::kWebAppIconSmall);
}
#endif
WebAppBrowserController* controller; WebAppBrowserController* controller;
{ {
apps::AppLaunchParams params( apps::AppLaunchParams params(
...@@ -115,6 +132,20 @@ IN_PROC_BROWSER_TEST_F(WebAppIconManagerBrowserTest, SingleIcon) { ...@@ -115,6 +132,20 @@ IN_PROC_BROWSER_TEST_F(WebAppIconManagerBrowserTest, SingleIcon) {
} }
base::RunLoop run_loop; base::RunLoop run_loop;
#if defined(OS_CHROMEOS)
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon)) {
controller->SetReadIconCallbackForTesting(base::BindLambdaForTesting(
[controller, &image_skia, &run_loop, this]() {
EXPECT_TRUE(app_service_test().AreIconImageEqual(
image_skia, controller->GetWindowAppIcon()));
run_loop.Quit();
}));
run_loop.Run();
return;
}
#endif
controller->SetReadIconCallbackForTesting( controller->SetReadIconCallbackForTesting(
base::BindLambdaForTesting([controller, &run_loop]() { base::BindLambdaForTesting([controller, &run_loop]() {
const SkBitmap* bitmap = controller->GetWindowAppIcon().bitmap(); const SkBitmap* bitmap = controller->GetWindowAppIcon().bitmap();
......
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