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

Side by Side Diff: chrome/browser/ui/webui/options/font_settings_handler.cc

Issue 7554008: Removal of Profile from content part 6. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Profile helper function, rebase Created 9 years, 4 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"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 SetUpFixedFontSample(); 71 SetUpFixedFontSample();
72 SetUpMinimumFontSample(); 72 SetUpMinimumFontSample();
73 } 73 }
74 74
75 WebUIMessageHandler* FontSettingsHandler::Attach(WebUI* web_ui) { 75 WebUIMessageHandler* FontSettingsHandler::Attach(WebUI* web_ui) {
76 // Call through to superclass. 76 // Call through to superclass.
77 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui); 77 WebUIMessageHandler* handler = OptionsPageUIHandler::Attach(web_ui);
78 78
79 // Perform validation for saved fonts. 79 // Perform validation for saved fonts.
80 DCHECK(web_ui_); 80 DCHECK(web_ui_);
81 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); 81 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
82 FontSettingsUtilities::ValidateSavedFonts(pref_service); 82 FontSettingsUtilities::ValidateSavedFonts(pref_service);
83 83
84 // Register for preferences that we need to observe manually. 84 // Register for preferences that we need to observe manually.
85 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this); 85 standard_font_.Init(prefs::kWebKitStandardFontFamily, pref_service, this);
86 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this); 86 serif_font_.Init(prefs::kWebKitSerifFontFamily, pref_service, this);
87 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this); 87 sans_serif_font_.Init(prefs::kWebKitSansSerifFontFamily, pref_service, this);
88 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this); 88 fixed_font_.Init(prefs::kWebKitFixedFontFamily, pref_service, this);
89 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this); 89 font_encoding_.Init(prefs::kDefaultCharset, pref_service, this);
90 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this); 90 default_font_size_.Init(prefs::kWebKitDefaultFontSize, pref_service, this);
91 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize, 91 default_fixed_font_size_.Init(prefs::kWebKitDefaultFixedFontSize,
(...skipping 11 matching lines...) Expand all
103 103
104 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) { 104 void FontSettingsHandler::HandleFetchFontsData(const ListValue* args) {
105 content::GetFontListAsync( 105 content::GetFontListAsync(
106 base::Bind(&FontSettingsHandler::FontsListHasLoaded, AsWeakPtr())); 106 base::Bind(&FontSettingsHandler::FontsListHasLoaded, AsWeakPtr()));
107 } 107 }
108 108
109 void FontSettingsHandler::FontsListHasLoaded( 109 void FontSettingsHandler::FontsListHasLoaded(
110 scoped_refptr<content::FontListResult> list) { 110 scoped_refptr<content::FontListResult> list) {
111 ListValue encoding_list; 111 ListValue encoding_list;
112 const std::vector<CharacterEncoding::EncodingInfo>* encodings; 112 const std::vector<CharacterEncoding::EncodingInfo>* encodings;
113 PrefService* pref_service = web_ui_->GetProfile()->GetPrefs(); 113 PrefService* pref_service = Profile::FromWebUI(web_ui_)->GetPrefs();
114 encodings = CharacterEncoding::GetCurrentDisplayEncodings( 114 encodings = CharacterEncoding::GetCurrentDisplayEncodings(
115 g_browser_process->GetApplicationLocale(), 115 g_browser_process->GetApplicationLocale(),
116 pref_service->GetString(prefs::kStaticEncodings), 116 pref_service->GetString(prefs::kStaticEncodings),
117 pref_service->GetString(prefs::kRecentlySelectedEncoding)); 117 pref_service->GetString(prefs::kRecentlySelectedEncoding));
118 DCHECK(encodings); 118 DCHECK(encodings);
119 DCHECK(!encodings->empty()); 119 DCHECK(!encodings->empty());
120 120
121 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it; 121 std::vector<CharacterEncoding::EncodingInfo>::const_iterator it;
122 for (it = encodings->begin(); it != encodings->end(); ++it) { 122 for (it = encodings->begin(); it != encodings->end(); ++it) {
123 ListValue* option = new ListValue(); 123 ListValue* option = new ListValue();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 FundamentalValue size_value(default_fixed_font_size_.GetValue()); 199 FundamentalValue size_value(default_fixed_font_size_.GetValue());
200 web_ui_->CallJavascriptFunction( 200 web_ui_->CallJavascriptFunction(
201 "FontSettings.setUpFixedFontSample", font_value, size_value); 201 "FontSettings.setUpFixedFontSample", font_value, size_value);
202 } 202 }
203 203
204 void FontSettingsHandler::SetUpMinimumFontSample() { 204 void FontSettingsHandler::SetUpMinimumFontSample() {
205 FundamentalValue size_value(minimum_font_size_.GetValue()); 205 FundamentalValue size_value(minimum_font_size_.GetValue());
206 web_ui_->CallJavascriptFunction("FontSettings.setUpMinimumFontSample", 206 web_ui_->CallJavascriptFunction("FontSettings.setUpMinimumFontSample",
207 size_value); 207 size_value);
208 } 208 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/core_options_handler.cc ('k') | chrome/browser/ui/webui/options/handler_options_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698