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/webui/options/font_settings_handler.h" | 5 #include "chrome/browser/ui/webui/options/font_settings_handler.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 | 57 |
58 const char kAdvancedFontSettingsExtensionId[] = | 58 const char kAdvancedFontSettingsExtensionId[] = |
59 "caclkomlalccbpcdllchkeecicepbmbm"; | 59 "caclkomlalccbpcdllchkeecicepbmbm"; |
60 | 60 |
61 } // namespace | 61 } // namespace |
62 | 62 |
63 | 63 |
64 namespace options { | 64 namespace options { |
65 | 65 |
66 FontSettingsHandler::FontSettingsHandler() | 66 FontSettingsHandler::FontSettingsHandler() |
67 : extension_registry_observer_(this) { | 67 : extension_registry_observer_(this), |
| 68 weak_ptr_factory_(this) { |
68 } | 69 } |
69 | 70 |
70 FontSettingsHandler::~FontSettingsHandler() { | 71 FontSettingsHandler::~FontSettingsHandler() { |
71 } | 72 } |
72 | 73 |
73 void FontSettingsHandler::GetLocalizedValues( | 74 void FontSettingsHandler::GetLocalizedValues( |
74 base::DictionaryValue* localized_strings) { | 75 base::DictionaryValue* localized_strings) { |
75 DCHECK(localized_strings); | 76 DCHECK(localized_strings); |
76 | 77 |
77 static OptionsStringResource resources[] = { | 78 static OptionsStringResource resources[] = { |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 void FontSettingsHandler::OnExtensionUnloaded( | 184 void FontSettingsHandler::OnExtensionUnloaded( |
184 content::BrowserContext* browser_context, | 185 content::BrowserContext* browser_context, |
185 const extensions::Extension* extension, | 186 const extensions::Extension* extension, |
186 extensions::UnloadedExtensionInfo::Reason reason) { | 187 extensions::UnloadedExtensionInfo::Reason reason) { |
187 NotifyAdvancedFontSettingsAvailability(); | 188 NotifyAdvancedFontSettingsAvailability(); |
188 } | 189 } |
189 | 190 |
190 void FontSettingsHandler::HandleFetchFontsData(const base::ListValue* args) { | 191 void FontSettingsHandler::HandleFetchFontsData(const base::ListValue* args) { |
191 content::GetFontListAsync( | 192 content::GetFontListAsync( |
192 base::Bind(&FontSettingsHandler::FontsListHasLoaded, | 193 base::Bind(&FontSettingsHandler::FontsListHasLoaded, |
193 base::Unretained(this))); | 194 weak_ptr_factory_.GetWeakPtr())); |
194 } | 195 } |
195 | 196 |
196 void FontSettingsHandler::FontsListHasLoaded( | 197 void FontSettingsHandler::FontsListHasLoaded( |
197 scoped_ptr<base::ListValue> list) { | 198 scoped_ptr<base::ListValue> list) { |
198 // Selects the directionality for the fonts in the given list. | 199 // Selects the directionality for the fonts in the given list. |
199 for (size_t i = 0; i < list->GetSize(); i++) { | 200 for (size_t i = 0; i < list->GetSize(); i++) { |
200 base::ListValue* font; | 201 base::ListValue* font; |
201 bool has_font = list->GetList(i, &font); | 202 bool has_font = list->GetList(i, &font); |
202 DCHECK(has_font); | 203 DCHECK(has_font); |
203 base::string16 value; | 204 base::string16 value; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
312 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); | 313 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents())); |
313 } | 314 } |
314 | 315 |
315 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() { | 316 void FontSettingsHandler::OnWebKitDefaultFontSizeChanged() { |
316 SetUpStandardFontSample(); | 317 SetUpStandardFontSample(); |
317 SetUpSerifFontSample(); | 318 SetUpSerifFontSample(); |
318 SetUpSansSerifFontSample(); | 319 SetUpSansSerifFontSample(); |
319 } | 320 } |
320 | 321 |
321 } // namespace options | 322 } // namespace options |
OLD | NEW |