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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_handler.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
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/options/font_settings_utils.h" 20 #include "chrome/browser/ui/webui/options/font_settings_utils.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 FontSettingsHandler::FontSettingsHandler() { 30 FontSettingsHandler::FontSettingsHandler() {
30 } 31 }
31 32
32 FontSettingsHandler::~FontSettingsHandler() { 33 FontSettingsHandler::~FontSettingsHandler() {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 base::Unretained(this))); 100 base::Unretained(this)));
100 } 101 }
101 102
102 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { 103 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) {
103 content::GetFontListAsync( 104 content::GetFontListAsync(
104 base::Bind(&FontSettingsHandler::FontsListHasLoaded, 105 base::Bind(&FontSettingsHandler::FontsListHasLoaded,
105 base::Unretained(this))); 106 base::Unretained(this)));
106 } 107 }
107 108
108 void FontSettingsHandler::FontsListHasLoaded( 109 void FontSettingsHandler::FontsListHasLoaded(
109 scoped_refptr<content::FontListResult> list) { 110 scoped_ptr<base::ListValue> list) {
110 ListValue encoding_list; 111 ListValue encoding_list;
111 const std::vector<CharacterEncoding::EncodingInfo>* encodings; 112 const std::vector<CharacterEncoding::EncodingInfo>* encodings;
112 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 113 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
113 encodings = CharacterEncoding::GetCurrentDisplayEncodings( 114 encodings = CharacterEncoding::GetCurrentDisplayEncodings(
114 g_browser_process->GetApplicationLocale(), 115 g_browser_process->GetApplicationLocale(),
115 pref_service->GetString(prefs::kStaticEncodings), 116 pref_service->GetString(prefs::kStaticEncodings),
116 pref_service->GetString(prefs::kRecentlySelectedEncoding)); 117 pref_service->GetString(prefs::kRecentlySelectedEncoding));
117 DCHECK(encodings); 118 DCHECK(encodings);
118 DCHECK(!encodings->empty()); 119 DCHECK(!encodings->empty());
119 120
(...skipping 17 matching lines...) Expand all
137 } 138 }
138 139
139 ListValue selected_values; 140 ListValue selected_values;
140 selected_values.Append(Value::CreateStringValue(standard_font_.GetValue())); 141 selected_values.Append(Value::CreateStringValue(standard_font_.GetValue()));
141 selected_values.Append(Value::CreateStringValue(serif_font_.GetValue())); 142 selected_values.Append(Value::CreateStringValue(serif_font_.GetValue()));
142 selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue())); 143 selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue()));
143 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue())); 144 selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue()));
144 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); 145 selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue()));
145 146
146 web_ui()->CallJavascriptFunction("FontSettings.setFontsData", 147 web_ui()->CallJavascriptFunction("FontSettings.setFontsData",
147 *list->list.get(), encoding_list, 148 *list.get(), encoding_list,
148 selected_values); 149 selected_values);
149 } 150 }
150 151
151 void FontSettingsHandler::Observe(int type, 152 void FontSettingsHandler::Observe(int type,
152 const content::NotificationSource& source, 153 const content::NotificationSource& source,
153 const content::NotificationDetails& details) { 154 const content::NotificationDetails& details) {
154 if (type == chrome::NOTIFICATION_PREF_CHANGED) { 155 if (type == chrome::NOTIFICATION_PREF_CHANGED) {
155 std::string* pref_name = content::Details<std::string>(details).ptr(); 156 std::string* pref_name = content::Details<std::string>(details).ptr();
156 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) { 157 if (*pref_name == prefs::kWebKitGlobalStandardFontFamily) {
157 SetUpStandardFontSample(); 158 SetUpStandardFontSample();
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 base::FundamentalValue size_value(default_fixed_font_size_.GetValue()); 199 base::FundamentalValue size_value(default_fixed_font_size_.GetValue());
199 web_ui()->CallJavascriptFunction( 200 web_ui()->CallJavascriptFunction(
200 "FontSettings.setUpFixedFontSample", font_value, size_value); 201 "FontSettings.setUpFixedFontSample", font_value, size_value);
201 } 202 }
202 203
203 void FontSettingsHandler::SetUpMinimumFontSample() { 204 void FontSettingsHandler::SetUpMinimumFontSample() {
204 base::FundamentalValue size_value(minimum_font_size_.GetValue()); 205 base::FundamentalValue size_value(minimum_font_size_.GetValue());
205 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 206 web_ui()->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
206 size_value); 207 size_value);
207 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/font_settings_handler.h ('k') | chrome/browser/ui/webui/options2/font_settings_handler2.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698