Commit 18efa5f5 authored by nancylingwang's avatar nancylingwang Committed by Commit Bot

Modify file open with to load the adaptive icon.

From M86, we introduce the adaptive icon for all apps. So modify the
icon url for FullTaskDescriptor, and use the AppService interface
apps::AppIconSource::GetIconURL to fetch the adaptive icons for apps.
DD: go/appservice-adaptive-icon

BUG=1119545

Change-Id: Id5a67114b80127a23655f4a7087077a2eabb7543
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2368576
Commit-Queue: Nancy Wang <nancylingwang@chromium.org>
Reviewed-by: default avatarFrançois Degros <fdegros@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800930}
parent 88362923
...@@ -18,8 +18,11 @@ ...@@ -18,8 +18,11 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_service/app_icon_source.h"
#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_metrics.h" #include "chrome/browser/apps/app_service/app_service_metrics.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/crostini/crostini_features.h" #include "chrome/browser/chromeos/crostini/crostini_features.h"
#include "chrome/browser/chromeos/drive/file_system_util.h" #include "chrome/browser/chromeos/drive/file_system_util.h"
#include "chrome/browser/chromeos/file_manager/app_id.h" #include "chrome/browser/chromeos/file_manager/app_id.h"
...@@ -288,6 +291,21 @@ Profile* GetProfileForExtensionTask(Profile* profile, ...@@ -288,6 +291,21 @@ Profile* GetProfileForExtensionTask(Profile* profile,
return profile; return profile;
} }
GURL GetIconURL(Profile* profile, const Extension& extension) {
if (base::FeatureList::IsEnabled(features::kAppServiceAdaptiveIcon) &&
apps::AppServiceProxyFactory::IsAppServiceAvailableForProfile(profile) &&
apps::AppServiceProxyFactory::GetForProfile(profile)
->AppRegistryCache()
.GetAppType(extension.id()) != apps::mojom::AppType::kUnknown) {
return apps::AppIconSource::GetIconURL(
extension.id(), extension_misc::EXTENSION_ICON_SMALL);
}
return extensions::ExtensionIconSource::GetIconURL(
&extension, extension_misc::EXTENSION_ICON_SMALL,
ExtensionIconSet::MATCH_BIGGER,
false); // grayscale
}
void ExecuteByArcAfterMimeTypesCollected( void ExecuteByArcAfterMimeTypesCollected(
Profile* profile, Profile* profile,
const TaskDescriptor& task, const TaskDescriptor& task,
...@@ -707,10 +725,7 @@ void FindFileHandlerTasks(Profile* profile, ...@@ -707,10 +725,7 @@ void FindFileHandlerTasks(Profile* profile,
std::string task_id = file_tasks::MakeTaskID( std::string task_id = file_tasks::MakeTaskID(
extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, handler->id); extension->id(), file_tasks::TASK_TYPE_FILE_HANDLER, handler->id);
GURL best_icon = extensions::ExtensionIconSource::GetIconURL( const GURL best_icon = GetIconURL(profile, *extension);
extension, extension_misc::EXTENSION_ICON_SMALL,
ExtensionIconSet::MATCH_BIGGER,
false); // grayscale
// If file handler doesn't match as good match, regards it as generic file // If file handler doesn't match as good match, regards it as generic file
// handler. // handler.
...@@ -768,10 +783,7 @@ void FindFileBrowserHandlerTasks( ...@@ -768,10 +783,7 @@ void FindFileBrowserHandlerTasks(
// TODO(zelidrag): Figure out how to expose icon URL that task defined in // TODO(zelidrag): Figure out how to expose icon URL that task defined in
// manifest instead of the default extension icon. // manifest instead of the default extension icon.
const GURL icon_url = extensions::ExtensionIconSource::GetIconURL( const GURL icon_url = GetIconURL(profile, *extension);
extension, extension_misc::EXTENSION_ICON_SMALL,
ExtensionIconSet::MATCH_BIGGER,
false); // grayscale
result_list->push_back(FullTaskDescriptor( result_list->push_back(FullTaskDescriptor(
TaskDescriptor(extension_id, file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER, TaskDescriptor(extension_id, file_tasks::TASK_TYPE_FILE_BROWSER_HANDLER,
......
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