Move Webstore URL concepts to //extensions and out
[chromium-blink-merge.git] / chrome / browser / renderer_preferences_util.cc
blob8cc171cbbcdbb897dfa528d262847928b983d589
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/renderer_preferences_util.h"
7 #include "base/macros.h"
8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h"
11 #include "content/public/common/renderer_preferences.h"
12 #include "third_party/skia/include/core/SkColor.h"
14 #if defined(OS_LINUX) || defined(OS_ANDROID)
15 #include "ui/gfx/font_render_params.h"
16 #endif
18 #if defined(TOOLKIT_VIEWS)
19 #include "ui/views/controls/textfield/textfield.h"
20 #endif
22 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
23 #include "chrome/browser/themes/theme_service.h"
24 #include "chrome/browser/themes/theme_service_factory.h"
25 #include "ui/views/linux_ui/linux_ui.h"
26 #endif
28 namespace renderer_preferences_util {
30 void UpdateFromSystemSettings(
31 content::RendererPreferences* prefs, Profile* profile) {
32 const PrefService* pref_service = profile->GetPrefs();
33 prefs->accept_languages = pref_service->GetString(prefs::kAcceptLanguages);
34 prefs->enable_referrers = pref_service->GetBoolean(prefs::kEnableReferrers);
35 prefs->enable_do_not_track =
36 pref_service->GetBoolean(prefs::kEnableDoNotTrack);
37 prefs->default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel);
39 #if defined(USE_DEFAULT_RENDER_THEME)
40 prefs->focus_ring_color = SkColorSetRGB(0x4D, 0x90, 0xFE);
42 #if defined(OS_CHROMEOS)
43 // This color is 0x544d90fe modulated with 0xffffff.
44 prefs->active_selection_bg_color = SkColorSetRGB(0xCB, 0xE4, 0xFA);
45 prefs->active_selection_fg_color = SK_ColorBLACK;
46 prefs->inactive_selection_bg_color = SkColorSetRGB(0xEA, 0xEA, 0xEA);
47 prefs->inactive_selection_fg_color = SK_ColorBLACK;
48 #endif
50 prefs->touchpad_fling_profile[0] =
51 pref_service->GetDouble(prefs::kFlingCurveTouchpadAlpha);
52 prefs->touchpad_fling_profile[1] =
53 pref_service->GetDouble(prefs::kFlingCurveTouchpadBeta);
54 prefs->touchpad_fling_profile[2] =
55 pref_service->GetDouble(prefs::kFlingCurveTouchpadGamma);
56 prefs->touchscreen_fling_profile[0] =
57 pref_service->GetDouble(prefs::kFlingCurveTouchscreenAlpha);
58 prefs->touchscreen_fling_profile[1] =
59 pref_service->GetDouble(prefs::kFlingCurveTouchscreenBeta);
60 prefs->touchscreen_fling_profile[2] =
61 pref_service->GetDouble(prefs::kFlingCurveTouchscreenGamma);
62 #endif
64 #if defined(TOOLKIT_VIEWS)
65 prefs->caret_blink_interval = views::Textfield::GetCaretBlinkMs() / 1000.0;
66 #endif
68 #if defined(USE_AURA) && defined(OS_LINUX) && !defined(OS_CHROMEOS)
69 views::LinuxUI* linux_ui = views::LinuxUI::instance();
70 if (linux_ui) {
71 if (ThemeServiceFactory::GetForProfile(profile)->UsingSystemTheme()) {
72 prefs->focus_ring_color = linux_ui->GetFocusRingColor();
73 prefs->thumb_active_color = linux_ui->GetThumbActiveColor();
74 prefs->thumb_inactive_color = linux_ui->GetThumbInactiveColor();
75 prefs->track_color = linux_ui->GetTrackColor();
76 prefs->active_selection_bg_color = linux_ui->GetActiveSelectionBgColor();
77 prefs->active_selection_fg_color = linux_ui->GetActiveSelectionFgColor();
78 prefs->inactive_selection_bg_color =
79 linux_ui->GetInactiveSelectionBgColor();
80 prefs->inactive_selection_fg_color =
81 linux_ui->GetInactiveSelectionFgColor();
84 // If we have a linux_ui object, set the caret blink interval regardless of
85 // whether we're in native theme mode.
86 prefs->caret_blink_interval = linux_ui->GetCursorBlinkInterval();
88 #endif
90 #if defined(OS_LINUX) || defined(OS_ANDROID)
91 CR_DEFINE_STATIC_LOCAL(const gfx::FontRenderParams, params,
92 (gfx::GetFontRenderParams(gfx::FontRenderParamsQuery(true), NULL)));
93 prefs->should_antialias_text = params.antialiasing;
94 prefs->use_subpixel_positioning = params.subpixel_positioning;
95 prefs->hinting = params.hinting;
96 prefs->use_autohinter = params.autohinter;
97 prefs->use_bitmaps = params.use_bitmaps;
98 prefs->subpixel_rendering = params.subpixel_rendering;
99 #endif
101 #if !defined(OS_MACOSX)
102 prefs->plugin_fullscreen_allowed =
103 pref_service->GetBoolean(prefs::kFullscreenAllowed);
104 #endif
107 } // namespace renderer_preferences_util