| 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/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); | 120 const int kPrefsToObserveLength = arraysize(kPrefsToObserve); |
| 121 | 121 |
| 122 // Registers a preference under the path |map_name| for each script used for | 122 // Registers a preference under the path |map_name| for each script used for |
| 123 // per-script font prefs. For example, if |map_name| is "fonts.serif", then | 123 // per-script font prefs. For example, if |map_name| is "fonts.serif", then |
| 124 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. | 124 // "fonts.serif.Arab", "fonts.serif.Hang", etc. are registered. |
| 125 void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) { | 125 void RegisterFontFamilyMap(PrefService* prefs, const char* map_name) { |
| 126 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 126 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| 127 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 127 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| 128 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); | 128 std::string pref_name_str = base::StringPrintf("%s.%s", map_name, script); |
| 129 const char* pref_name = pref_name_str.c_str(); | 129 const char* pref_name = pref_name_str.c_str(); |
| 130 if (!prefs->FindPreference(pref_name)) | 130 prefs->RegisterStringPrefIfNew(pref_name, |
| 131 prefs->RegisterStringPref(pref_name, "", PrefService::UNSYNCABLE_PREF); | 131 "", |
| 132 PrefService::UNSYNCABLE_PREF); |
| 132 } | 133 } |
| 133 } | 134 } |
| 134 | 135 |
| 135 // Registers |obs| to observe per-script font prefs under the path |map_name|. | 136 // Registers |obs| to observe per-script font prefs under the path |map_name|. |
| 136 void RegisterFontFamilyMapObserver(PrefChangeRegistrar* registrar, | 137 void RegisterFontFamilyMapObserver(PrefChangeRegistrar* registrar, |
| 137 const char* map_name, | 138 const char* map_name, |
| 138 content::NotificationObserver* obs) { | 139 content::NotificationObserver* obs) { |
| 139 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 140 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| 140 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 141 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| 141 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); | 142 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 567 | 568 |
| 568 void PrefsTabHelper::UpdateRendererPreferences() { | 569 void PrefsTabHelper::UpdateRendererPreferences() { |
| 569 renderer_preferences_util::UpdateFromSystemSettings( | 570 renderer_preferences_util::UpdateFromSystemSettings( |
| 570 web_contents_->GetMutableRendererPrefs(), GetProfile()); | 571 web_contents_->GetMutableRendererPrefs(), GetProfile()); |
| 571 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); | 572 web_contents_->GetRenderViewHost()->SyncRendererPrefs(); |
| 572 } | 573 } |
| 573 | 574 |
| 574 Profile* PrefsTabHelper::GetProfile() { | 575 Profile* PrefsTabHelper::GetProfile() { |
| 575 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); | 576 return Profile::FromBrowserContext(web_contents_->GetBrowserContext()); |
| 576 } | 577 } |
| OLD | NEW |