Commit 6508b6dd authored by Nigel Tao's avatar Nigel Tao Committed by Commit Bot

Don't hard-code app icons to SCALE_FACTOR_100P

BUG=826982

Change-Id: Ieae4773919ec7446cefe41cf497d907386cc890f
Reviewed-on: https://chromium-review.googlesource.com/c/1454110
Commit-Queue: Nigel Tao <nigeltao@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#629829}
parent 734196c0
......@@ -26,7 +26,7 @@ namespace {
void LoadDefaultImage(const content::URLDataSource::GotDataCallback& callback) {
base::StringPiece contents =
ui::ResourceBundle::GetSharedInstance().GetRawDataResourceForScale(
IDR_APP_DEFAULT_ICON, ui::SCALE_FACTOR_100P);
IDR_APP_DEFAULT_ICON, GetPrimaryDisplayUIScaleFactor());
base::RefCountedBytes* image_bytes = new base::RefCountedBytes();
image_bytes->data().assign(contents.data(),
......
......@@ -331,11 +331,9 @@ const base::FilePath ArcApps::GetCachedIconFilePath(const std::string& app_id,
// TODO(crbug.com/826982): process the app_id argument like the private
// GetAppFromAppOrGroupId function and the ArcAppIcon::mapped_app_id_ field
// in arc_app_icon.cc?
//
// TODO(crbug.com/826982): don't hard-code SCALE_FACTOR_100P.
return prefs_->GetIconPath(
app_id, ArcAppIconDescriptor(size_hint_in_dip,
ui::ScaleFactor::SCALE_FACTOR_100P));
app_id,
ArcAppIconDescriptor(size_hint_in_dip, GetPrimaryDisplayUIScaleFactor()));
}
void ArcApps::LoadIconFromVM(const std::string icon_key_s_key,
......
......@@ -8,6 +8,7 @@
#include "chrome/browser/apps/app_service/app_icon_factory.h"
#include "chrome/browser/apps/app_service/app_service_proxy.h"
#include "chrome/browser/apps/app_service/dip_px_util.h"
#include "chrome/browser/apps/app_service/launch_util.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service_factory.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
......@@ -76,8 +77,7 @@ void CrostiniApps::LoadIcon(const std::string& app_id,
}
if (icon_key->icon_type == apps::mojom::IconType::kCrostini) {
// TODO(crbug.com/826982): don't hard-code SCALE_FACTOR_100P.
auto scale_factor = ui::ScaleFactor::SCALE_FACTOR_100P;
auto scale_factor = GetPrimaryDisplayUIScaleFactor();
// Try loading the icon from an on-disk cache. If that fails, fall back
// to LoadIconFromVM.
......
......@@ -7,9 +7,15 @@
#include <cmath>
#include "base/numerics/safe_conversions.h"
#include "ui/base/layout.h"
#include "ui/display/display.h"
#include "ui/display/screen.h"
// TODO(crbug.com/826982): plumb through enough information to use one of
// Screen::GetDisplayNearest{Window/View/Point}. That way in multi-monitor
// setups where one screen is hidpi and the other one isn't, we don't always do
// the wrong thing.
namespace {
float GetPrimaryDisplayScaleFactor() {
......@@ -34,4 +40,8 @@ int ConvertPxToDip(int px) {
std::floor(static_cast<float>(px) / GetPrimaryDisplayScaleFactor()));
}
ui::ScaleFactor GetPrimaryDisplayUIScaleFactor() {
return ui::GetSupportedScaleFactor(GetPrimaryDisplayScaleFactor());
}
} // namespace apps
......@@ -8,10 +8,13 @@
// Utility functions for converting between DIP (device independent pixels) and
// PX (physical pixels).
#include "ui/base/resource/scale_factor.h"
namespace apps {
int ConvertDipToPx(int dip);
int ConvertPxToDip(int px);
ui::ScaleFactor GetPrimaryDisplayUIScaleFactor();
} // namespace apps
......
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