Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(88)

Side by Side Diff: chrome/browser/ui/webui/options2/font_settings_handler2.cc

Issue 9500008: Move font_list_async.h to content/public. Switch to Pass() goodness to simplify code. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix clang Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/options2/font_settings_handler2.h" 5 #include "chrome/browser/ui/webui/options2/font_settings_handler2.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"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/i18n/rtl.h" 12 #include "base/i18n/rtl.h"
13 #include "base/string_number_conversions.h" 13 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/values.h" 15 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/character_encoding.h" 17 #include "chrome/browser/character_encoding.h"
18 #include "chrome/browser/prefs/pref_service.h" 18 #include "chrome/browser/prefs/pref_service.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/webui/options2/font_settings_utils2.h" 20 #include "chrome/browser/ui/webui/options2/font_settings_utils2.h"
21 #include "chrome/common/chrome_notification_types.h" 21 #include "chrome/common/chrome_notification_types.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
23 #include "content/public/browser/font_list_async.h"
23 #include "content/public/browser/notification_details.h" 24 #include "content/public/browser/notification_details.h"
24 #include "content/public/browser/web_ui.h" 25 #include "content/public/browser/web_ui.h"
25 #include "grit/chromium_strings.h" 26 #include "grit/chromium_strings.h"
26 #include "grit/generated_resources.h" 27 #include "grit/generated_resources.h"
27 #include "ui/base/l10n/l10n_util.h" 28 #include "ui/base/l10n/l10n_util.h"
28 29
29 namespace options2 { 30 namespace options2 {
30 31
31 FontSettingsHandler::FontSettingsHandler() { 32 FontSettingsHandler::FontSettingsHandler() {
32 } 33 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 base::Unretained(this))); 102 base::Unretained(this)));
102 } 103 }
103 104
104 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { 105 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) {
105 content::GetFontListAsync( 106 content::GetFontListAsync(
106 base::Bind(&FontSettingsHandler::FontsListHasLoaded, 107 base::Bind(&FontSettingsHandler::FontsListHasLoaded,
107 base::Unretained(this))); 108 base::Unretained(this)));
108 } 109 }
109 110
110 void FontSettingsHandler::FontsListHasLoaded( 111 void FontSettingsHandler::FontsListHasLoaded(
111 scoped_refptr<content::FontListResult> list) { 112 scoped_ptr<base::ListValue> list) {
112 ListValue encoding_list; 113 ListValue encoding_list;
113 const std::vector<CharacterEncoding::EncodingInfo>* encodings; 114 const std::vector<CharacterEncoding::EncodingInfo>* encodings;
114 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 115 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
115 encodings = CharacterEncoding::GetCurrentDisplayEncodings( 116 encodings = CharacterEncoding::GetCurrentDisplayEncodings(
116 g_browser_process->GetApplicationLocale(), 117 g_browser_process->GetApplicationLocale(),
117 pref_service->GetString(prefs::kStaticEncodings), 118 pref_service->GetString(prefs::kStaticEncodings),
118 pref_service->GetString(prefs::kRecentlySelectedEncoding)); 119 pref_service->GetString(prefs::kRecentlySelectedEncoding));
119 DCHECK(encodings); 120 DCHECK(encodings);
120 DCHECK(!encodings->empty()); 121 DCHECK(!encodings->empty());
121 122
(...skipping 17 matching lines...) Expand all
139 } 140 }
140 141
141 ListValue selected_values; 142 ListValue selected_values;
142 selected_values.Append(Value::CreateStringValue(standard_font_.GetValue())); 143 selected_values.Append(Value::CreateStringValue(standard_font_.GetValue()));
143 selected_values.Append(Value::CreateStringValue(serif_font_.GetValue())); 144 selected_values.Append(Value::CreateStringValue(serif_font_.GetValue()));
144 selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue())); 145 selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue()));
145 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue())); 146 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue()));
146 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); 147 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue()));
147 148
148 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", 149 web_ui()->CallJavascriptFunction("FontSettings.setFontsData",
149 *list->list.get(), encoding_list, 150 *list.get(), encoding_list,
150 selected_values); 151 selected_values);
151 } 152 }
152 153
153 void FontSettingsHandler::Observe(int type, 154 void FontSettingsHandler::Observe(int type,
154 const content::NotificationSource& source, 155 const content::NotificationSource& source,
155 const content::NotificationDetails& details) { 156 const content::NotificationDetails& details) {
156 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 157 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
157 std::string* pref_name = content::Details<std::string>(details).ptr(); 158 std::string* pref_name = content::Details<std::string>(details).ptr();
158 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) { 159 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) {
159 SetUpStandardFontSample(); 160 SetUpStandardFontSample();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 "FontSettings.setUpFixedFontSample", font_value, size_value); 203 "FontSettings.setUpFixedFontSample", font_value, size_value);
203 } 204 }
204 205
205 void FontSettingsHandler::SetUpMinimumFontSample() { 206 void FontSettingsHandler::SetUpMinimumFontSample() {
206 base::FundamentalValue size_value(minimum_font_size_.GetValue()); 207 base::FundamentalValue size_value(minimum_font_size_.GetValue());
207 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 208 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
208 size_value); 209 size_value);
209 } 210 }
210 211
211 } // namespace options2 212 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options2/font_settings_handler2.h ('k') | content/browser/font_list_async.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698