Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5870)

Unified Diff: chrome/browser/ui/webui/theme_source.cc

Issue 2279373002: Refix bug 497949 in a more efficient way that also doesn't rebreak bug 442384. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cleanup
Patch Set: Resync Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/theme_source.cc
diff --git a/chrome/browser/ui/webui/theme_source.cc b/chrome/browser/ui/webui/theme_source.cc
index ccce917749639b9b2dec0fa9fe43e79c7b818d3b..8e5de32c452c9535570c46d3c463ab3d632b134e 100644
--- a/chrome/browser/ui/webui/theme_source.cc
+++ b/chrome/browser/ui/webui/theme_source.cc
@@ -92,7 +92,6 @@ void ThemeSource::StartDataRequest(
float scale = 1.0f;
std::string parsed_path;
webui::ParsePathAndScale(GetThemeUrl(path), &parsed_path, &scale);
- scale = ui::GetScaleForScaleFactor(ui::GetSupportedScaleFactor(scale));
if (IsNewTabCssPath(parsed_path)) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
@@ -131,13 +130,20 @@ void ThemeSource::StartDataRequest(
resource_id = ResourcesUtil::GetThemeResourceId(parsed_path);
}
+ // Limit the maximum scale we'll respond to. Very large scale factors can
+ // take significant time to serve or, at worst, crash the browser due to OOM.
+ // We don't want to clamp to the max scale factor, though, for devices that
+ // use 2x scale without 2x data packs, as well as omnibox requests for larger
+ // (but still reasonable) scales (see below).
const float max_scale = ui::GetScaleForScaleFactor(
ResourceBundle::GetSharedInstance().GetMaxScaleFactor());
- if (resource_id == -1) {
- // We have no data to send back. This shouldn't happen normally, as
- // chrome://theme/ URLs are only used by WebUI pages and component
- // extensions. However, the user can also enter these into the omnibox, so
- // we need to fail gracefully.
+ const float unreasonable_scale = max_scale * 32;
+ if ((resource_id == -1) || (scale >= unreasonable_scale)) {
+ // Either we have no data to send back, or the requested scale is
+ // unreasonably large. This shouldn't happen normally, as chrome://theme/
+ // URLs are only used by WebUI pages and component extensions. However, the
+ // user can also enter these into the omnibox, so we need to fail
+ // gracefully.
callback.Run(nullptr);
} else if ((GetMimeType(path) == "image/png") && (scale > max_scale)) {
SendThemeImage(callback, resource_id, scale);
« no previous file with comments | « chrome/browser/ui/webui/chrome_url_data_manager_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698