| 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 // Font Settings Extension API implementation. | 5 // Font Settings Extension API implementation. |
| 6 | 6 |
| 7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" | 7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { | 91 for (size_t i = 0; i < prefs::kWebKitScriptsForFontFamilyMapsLength; ++i) { |
| 92 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; | 92 const char* script = prefs::kWebKitScriptsForFontFamilyMaps[i]; |
| 93 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); | 93 std::string pref_name = base::StringPrintf("%s.%s", map_name, script); |
| 94 registrar->Add(pref_name.c_str(), obs); | 94 registrar->Add(pref_name.c_str(), obs); |
| 95 } | 95 } |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace | 98 } // namespace |
| 99 | 99 |
| 100 FontSettingsEventRouter::FontSettingsEventRouter( | 100 FontSettingsEventRouter::FontSettingsEventRouter( |
| 101 Profile* profile) : profile_(profile) {} | 101 Profile* profile) : profile_(profile) { |
| 102 | |
| 103 FontSettingsEventRouter::~FontSettingsEventRouter() {} | |
| 104 | |
| 105 void FontSettingsEventRouter::Init() { | |
| 106 registrar_.Init(profile_->GetPrefs()); | 102 registrar_.Init(profile_->GetPrefs()); |
| 107 | 103 |
| 108 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize, | 104 AddPrefToObserve(prefs::kWebKitDefaultFixedFontSize, |
| 109 kOnDefaultFixedFontSizeChanged, | 105 kOnDefaultFixedFontSizeChanged, |
| 110 kPixelSizeKey); | 106 kPixelSizeKey); |
| 111 AddPrefToObserve(prefs::kWebKitDefaultFontSize, | 107 AddPrefToObserve(prefs::kWebKitDefaultFontSize, |
| 112 kOnDefaultFontSizeChanged, | 108 kOnDefaultFontSizeChanged, |
| 113 kPixelSizeKey); | 109 kPixelSizeKey); |
| 114 AddPrefToObserve(prefs::kWebKitMinimumFontSize, | 110 AddPrefToObserve(prefs::kWebKitMinimumFontSize, |
| 115 kOnMinimumFontSizeChanged, | 111 kOnMinimumFontSizeChanged, |
| 116 kPixelSizeKey); | 112 kPixelSizeKey); |
| 117 | 113 |
| 118 RegisterFontFamilyMapObserver(®istrar_, | 114 RegisterFontFamilyMapObserver(®istrar_, |
| 119 prefs::kWebKitStandardFontFamilyMap, this); | 115 prefs::kWebKitStandardFontFamilyMap, this); |
| 120 RegisterFontFamilyMapObserver(®istrar_, | 116 RegisterFontFamilyMapObserver(®istrar_, |
| 121 prefs::kWebKitSerifFontFamilyMap, this); | 117 prefs::kWebKitSerifFontFamilyMap, this); |
| 122 RegisterFontFamilyMapObserver(®istrar_, | 118 RegisterFontFamilyMapObserver(®istrar_, |
| 123 prefs::kWebKitSansSerifFontFamilyMap, this); | 119 prefs::kWebKitSansSerifFontFamilyMap, this); |
| 124 RegisterFontFamilyMapObserver(®istrar_, | 120 RegisterFontFamilyMapObserver(®istrar_, |
| 125 prefs::kWebKitFixedFontFamilyMap, this); | 121 prefs::kWebKitFixedFontFamilyMap, this); |
| 126 RegisterFontFamilyMapObserver(®istrar_, | 122 RegisterFontFamilyMapObserver(®istrar_, |
| 127 prefs::kWebKitCursiveFontFamilyMap, this); | 123 prefs::kWebKitCursiveFontFamilyMap, this); |
| 128 RegisterFontFamilyMapObserver(®istrar_, | 124 RegisterFontFamilyMapObserver(®istrar_, |
| 129 prefs::kWebKitFantasyFontFamilyMap, this); | 125 prefs::kWebKitFantasyFontFamilyMap, this); |
| 130 RegisterFontFamilyMapObserver(®istrar_, | 126 RegisterFontFamilyMapObserver(®istrar_, |
| 131 prefs::kWebKitPictographFontFamilyMap, this); | 127 prefs::kWebKitPictographFontFamilyMap, this); |
| 132 } | 128 } |
| 133 | 129 |
| 130 FontSettingsEventRouter::~FontSettingsEventRouter() {} |
| 131 |
| 134 void FontSettingsEventRouter::AddPrefToObserve(const char* pref_name, | 132 void FontSettingsEventRouter::AddPrefToObserve(const char* pref_name, |
| 135 const char* event_name, | 133 const char* event_name, |
| 136 const char* key) { | 134 const char* key) { |
| 137 registrar_.Add(pref_name, this); | 135 registrar_.Add(pref_name, this); |
| 138 pref_event_map_[pref_name] = std::make_pair(event_name, key); | 136 pref_event_map_[pref_name] = std::make_pair(event_name, key); |
| 139 } | 137 } |
| 140 | 138 |
| 141 void FontSettingsEventRouter::OnPreferenceChanged( | 139 void FontSettingsEventRouter::OnPreferenceChanged( |
| 142 PrefServiceBase* pref_service, | 140 PrefServiceBase* pref_service, |
| 143 const std::string& pref_name) { | 141 const std::string& pref_name) { |
| (...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 | 454 |
| 457 const char* SetMinimumFontSizeFunction::GetPrefName() { | 455 const char* SetMinimumFontSizeFunction::GetPrefName() { |
| 458 return prefs::kWebKitMinimumFontSize; | 456 return prefs::kWebKitMinimumFontSize; |
| 459 } | 457 } |
| 460 | 458 |
| 461 const char* SetMinimumFontSizeFunction::GetKey() { | 459 const char* SetMinimumFontSizeFunction::GetKey() { |
| 462 return kPixelSizeKey; | 460 return kPixelSizeKey; |
| 463 } | 461 } |
| 464 | 462 |
| 465 } // namespace extensions | 463 } // namespace extensions |
| OLD | NEW |