| OLD | NEW | 
|    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/i18n/rtl.h" |   11 #include "base/i18n/rtl.h" | 
|   12 #include "base/string_number_conversions.h" |   12 #include "base/string_number_conversions.h" | 
|   13 #include "base/string_util.h" |   13 #include "base/string_util.h" | 
|   14 #include "base/values.h" |   14 #include "base/values.h" | 
|   15 #include "chrome/browser/browser_process.h" |   15 #include "chrome/browser/browser_process.h" | 
|   16 #include "chrome/browser/character_encoding.h" |   16 #include "chrome/browser/character_encoding.h" | 
|   17 #include "chrome/browser/prefs/pref_service.h" |   17 #include "chrome/browser/prefs/pref_service.h" | 
|   18 #include "chrome/browser/profiles/profile.h" |   18 #include "chrome/browser/profiles/profile.h" | 
|   19 #include "chrome/browser/ui/webui/options/font_settings_utils.h" |   19 #include "chrome/browser/ui/webui/options/font_settings_utils.h" | 
 |   20 #include "chrome/common/chrome_notification_types.h" | 
|   20 #include "chrome/common/pref_names.h" |   21 #include "chrome/common/pref_names.h" | 
|   21 #include "content/common/notification_details.h" |   22 #include "content/common/notification_details.h" | 
|   22 #include "content/common/notification_type.h" |  | 
|   23 #include "grit/chromium_strings.h" |   23 #include "grit/chromium_strings.h" | 
|   24 #include "grit/generated_resources.h" |   24 #include "grit/generated_resources.h" | 
|   25 #include "ui/base/l10n/l10n_util.h" |   25 #include "ui/base/l10n/l10n_util.h" | 
|   26  |   26  | 
|   27 FontSettingsHandler::FontSettingsHandler() { |   27 FontSettingsHandler::FontSettingsHandler() { | 
|   28 } |   28 } | 
|   29  |   29  | 
|   30 FontSettingsHandler::~FontSettingsHandler() { |   30 FontSettingsHandler::~FontSettingsHandler() { | 
|   31 } |   31 } | 
|   32  |   32  | 
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  142   selected_values.Append(Value::CreateStringValue(serif_font_.GetValue())); |  142   selected_values.Append(Value::CreateStringValue(serif_font_.GetValue())); | 
|  143   selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue())); |  143   selected_values.Append(Value::CreateStringValue(sans_serif_font_.GetValue())); | 
|  144   selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue())); |  144   selected_values.Append(Value::CreateStringValue(fixed_font_.GetValue())); | 
|  145   selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); |  145   selected_values.Append(Value::CreateStringValue(font_encoding_.GetValue())); | 
|  146  |  146  | 
|  147   web_ui_->CallJavascriptFunction("FontSettings.setFontsData", |  147   web_ui_->CallJavascriptFunction("FontSettings.setFontsData", | 
|  148                                   *list->list.get(), encoding_list, |  148                                   *list->list.get(), encoding_list, | 
|  149                                   selected_values); |  149                                   selected_values); | 
|  150 } |  150 } | 
|  151  |  151  | 
|  152 void FontSettingsHandler::Observe(NotificationType type, |  152 void FontSettingsHandler::Observe(int type, | 
|  153                                   const NotificationSource& source, |  153                                   const NotificationSource& source, | 
|  154                                   const NotificationDetails& details) { |  154                                   const NotificationDetails& details) { | 
|  155   if (type == NotificationType::PREF_CHANGED) { |  155   if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 
|  156     std::string* pref_name = Details<std::string>(details).ptr(); |  156     std::string* pref_name = Details<std::string>(details).ptr(); | 
|  157     if (*pref_name == prefs::kWebKitStandardFontFamily) { |  157     if (*pref_name == prefs::kWebKitStandardFontFamily) { | 
|  158       SetUpStandardFontSample(); |  158       SetUpStandardFontSample(); | 
|  159     } else if (*pref_name == prefs::kWebKitSerifFontFamily) { |  159     } else if (*pref_name == prefs::kWebKitSerifFontFamily) { | 
|  160       SetUpSerifFontSample(); |  160       SetUpSerifFontSample(); | 
|  161     } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { |  161     } else if (*pref_name == prefs::kWebKitSansSerifFontFamily) { | 
|  162       SetUpSansSerifFontSample(); |  162       SetUpSansSerifFontSample(); | 
|  163     } else if (*pref_name == prefs::kWebKitFixedFontFamily || |  163     } else if (*pref_name == prefs::kWebKitFixedFontFamily || | 
|  164                *pref_name == prefs::kWebKitDefaultFixedFontSize) { |  164                *pref_name == prefs::kWebKitDefaultFixedFontSize) { | 
|  165       SetUpFixedFontSample(); |  165       SetUpFixedFontSample(); | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  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 } | 
| OLD | NEW |