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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 28053002: Add font_scale_factor_quirk pref. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master.pinned
Patch Set: Address review comments. Created 7 years, 2 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 | « android_webview/native/aw_settings.cc ('k') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 49fe6b1d5b98ce3b0175ac24ff087f3c7d82b582..054a4cc2ee714940219862a854df1e96072c56d7 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -182,6 +182,7 @@
#if defined(OS_ANDROID)
#include "ui/base/ui_base_paths.h"
+#include "ui/gfx/android/device_display_info.h"
#endif
#if defined(USE_NSS)
@@ -549,6 +550,7 @@ void HandleBlockedPopupOnUIThread(const BlockedWindowParams& params) {
}
#if defined(OS_ANDROID)
+
void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) {
WebContents* web_contents =
tab_util::GetWebContentsByID(params.render_process_id(),
@@ -558,6 +560,33 @@ void HandleSingleTabModeBlockOnUIThread(const BlockedWindowParams& params) {
SingleTabModeTabHelper::FromWebContents(web_contents)->HandleOpenUrl(params);
}
+
+float GetFontScaleMultiplier(const PrefService* prefs) {
+ if (prefs->GetBoolean(prefs::kWebKitFontScaleFactorQuirk)) {
+ // The value of kWebKitFontScaleFactor passed by Chrome for Android already
+ // includes the multiplier.
+ return 1.0f;
+ }
+
+ static const float kMinFSM = 1.05f;
+ static const int kWidthForMinFSM = 320;
+ static const float kMaxFSM = 1.3f;
+ static const int kWidthForMaxFSM = 800;
+
+ gfx::DeviceDisplayInfo info;
+ int minWidth = info.GetSmallestDIPWidth();
+
+ if (minWidth <= kWidthForMinFSM)
+ return kMinFSM;
+ if (minWidth >= kWidthForMaxFSM)
+ return kMaxFSM;
+
+ // The font scale multiplier varies linearly between kMinFSM and kMaxFSM.
+ float ratio = static_cast<float>(minWidth - kWidthForMinFSM) /
+ (kWidthForMaxFSM - kWidthForMinFSM);
+ return ratio * (kMaxFSM - kMinFSM) + kMinFSM;
+}
+
#endif // defined(OS_ANDROID)
} // namespace
@@ -2157,8 +2186,9 @@ void ChromeContentBrowserClient::OverrideWebkitPrefs(
web_prefs->allow_running_insecure_content =
prefs->GetBoolean(prefs::kWebKitAllowRunningInsecureContent);
#if defined(OS_ANDROID)
- web_prefs->font_scale_factor =
- static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor));
+ web_prefs->text_autosizing_font_scale_factor =
+ static_cast<float>(prefs->GetDouble(prefs::kWebKitFontScaleFactor)) *
+ GetFontScaleMultiplier(prefs);
web_prefs->force_enable_zoom =
prefs->GetBoolean(prefs::kWebKitForceEnableZoom);
#endif
« no previous file with comments | « android_webview/native/aw_settings.cc ('k') | chrome/browser/ui/prefs/prefs_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698