| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" | 5 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/prefs/overlay_user_pref_store.h" | 9 #include "base/prefs/overlay_user_pref_store.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 13 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/renderer_preferences_util.h" | 17 #include "chrome/browser/renderer_preferences_util.h" |
| 18 #include "chrome/common/pref_font_webkit_names.h" | 18 #include "chrome/common/pref_font_webkit_names.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/common/pref_names_util.h" | 20 #include "chrome/common/pref_names_util.h" |
| 21 #include "components/pref_registry/pref_registry_syncable.h" | 21 #include "components/pref_registry/pref_registry_syncable.h" |
| 22 #include "content/public/browser/notification_details.h" | 22 #include "content/public/browser/notification_details.h" |
| 23 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 24 #include "content/public/browser/render_view_host.h" | 24 #include "content/public/browser/render_view_host.h" |
| 25 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
| 26 #include "content/public/common/web_preferences.h" |
| 26 #include "grit/locale_settings.h" | 27 #include "grit/locale_settings.h" |
| 27 #include "grit/platform_locale_settings.h" | 28 #include "grit/platform_locale_settings.h" |
| 28 #include "third_party/icu/source/common/unicode/uchar.h" | 29 #include "third_party/icu/source/common/unicode/uchar.h" |
| 29 #include "third_party/icu/source/common/unicode/uscript.h" | 30 #include "third_party/icu/source/common/unicode/uscript.h" |
| 30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
| 31 #include "webkit/common/webpreferences.h" | |
| 32 | 32 |
| 33 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) | 33 #if defined(OS_POSIX) && !defined(OS_MACOSX) && defined(ENABLE_THEMES) |
| 34 #include "chrome/browser/themes/theme_service.h" | 34 #include "chrome/browser/themes/theme_service.h" |
| 35 #include "chrome/browser/themes/theme_service_factory.h" | 35 #include "chrome/browser/themes/theme_service_factory.h" |
| 36 #endif | 36 #endif |
| 37 | 37 |
| 38 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 39 #include "base/win/windows_version.h" | 39 #include "base/win/windows_version.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 using content::WebContents; | 42 using content::WebContents; |
| 43 using content::WebPreferences; |
| 43 | 44 |
| 44 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); | 45 DEFINE_WEB_CONTENTS_USER_DATA_KEY(PrefsTabHelper); |
| 45 | 46 |
| 46 namespace { | 47 namespace { |
| 47 | 48 |
| 48 // The list of prefs we want to observe. | 49 // The list of prefs we want to observe. |
| 49 const char* kPrefsToObserve[] = { | 50 const char* kPrefsToObserve[] = { |
| 50 prefs::kDefaultCharset, | 51 prefs::kDefaultCharset, |
| 51 prefs::kWebKitAllowDisplayingInsecureContent, | 52 prefs::kWebKitAllowDisplayingInsecureContent, |
| 52 prefs::kWebKitAllowRunningInsecureContent, | 53 prefs::kWebKitAllowRunningInsecureContent, |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 if (U_FAILURE(err) && err != U_BUFFER_OVERFLOW_ERROR) | 276 if (U_FAILURE(err) && err != U_BUFFER_OVERFLOW_ERROR) |
| 276 code = USCRIPT_INVALID_CODE; | 277 code = USCRIPT_INVALID_CODE; |
| 277 return GetScriptForFontPrefMatching(code); | 278 return GetScriptForFontPrefMatching(code); |
| 278 } | 279 } |
| 279 | 280 |
| 280 // Sets a font family pref in |prefs| to |pref_value|. | 281 // Sets a font family pref in |prefs| to |pref_value|. |
| 281 void OverrideFontFamily(WebPreferences* prefs, | 282 void OverrideFontFamily(WebPreferences* prefs, |
| 282 const std::string& generic_family, | 283 const std::string& generic_family, |
| 283 const std::string& script, | 284 const std::string& script, |
| 284 const std::string& pref_value) { | 285 const std::string& pref_value) { |
| 285 webkit_glue::ScriptFontFamilyMap* map = NULL; | 286 content::ScriptFontFamilyMap* map = NULL; |
| 286 if (generic_family == "standard") | 287 if (generic_family == "standard") |
| 287 map = &prefs->standard_font_family_map; | 288 map = &prefs->standard_font_family_map; |
| 288 else if (generic_family == "fixed") | 289 else if (generic_family == "fixed") |
| 289 map = &prefs->fixed_font_family_map; | 290 map = &prefs->fixed_font_family_map; |
| 290 else if (generic_family == "serif") | 291 else if (generic_family == "serif") |
| 291 map = &prefs->serif_font_family_map; | 292 map = &prefs->serif_font_family_map; |
| 292 else if (generic_family == "sansserif") | 293 else if (generic_family == "sansserif") |
| 293 map = &prefs->sans_serif_font_family_map; | 294 map = &prefs->sans_serif_font_family_map; |
| 294 else if (generic_family == "cursive") | 295 else if (generic_family == "cursive") |
| 295 map = &prefs->cursive_font_family_map; | 296 map = &prefs->cursive_font_family_map; |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 599 WebPreferences web_prefs = | 600 WebPreferences web_prefs = |
| 600 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); | 601 web_contents_->GetRenderViewHost()->GetWebkitPreferences(); |
| 601 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); | 602 OverrideFontFamily(&web_prefs, generic_family, script, std::string()); |
| 602 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); | 603 web_contents_->GetRenderViewHost()->UpdateWebkitPreferences(web_prefs); |
| 603 return; | 604 return; |
| 604 } | 605 } |
| 605 } | 606 } |
| 606 | 607 |
| 607 UpdateWebPreferences(); | 608 UpdateWebPreferences(); |
| 608 } | 609 } |
| OLD | NEW |