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/chromeos/system_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/chromeos/system_options_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/callback.h" | 10 #include "base/callback.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/utf_string_conversions.h" | 12 #include "base/utf_string_conversions.h" |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "content/browser/tab_contents/tab_contents.h" | 14 #include "content/browser/tab_contents/tab_contents.h" |
15 #include "content/common/json_value_serializer.h" | 15 #include "content/common/json_value_serializer.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chromeos/accessibility_util.h" | 17 #include "chrome/browser/chromeos/accessibility_util.h" |
18 #include "chrome/browser/chromeos/cros_settings.h" | |
18 #include "chrome/browser/chromeos/language_preferences.h" | 19 #include "chrome/browser/chromeos/language_preferences.h" |
19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
20 #include "chrome/browser/prefs/pref_service.h" | 21 #include "chrome/browser/prefs/pref_service.h" |
21 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
22 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" | 23 #include "chrome/browser/ui/webui/options/chromeos/system_settings_provider.h" |
23 #include "chrome/common/pref_names.h" | 24 #include "chrome/common/pref_names.h" |
24 #include "chrome/common/extensions/extension.h" | 25 #include "chrome/common/extensions/extension.h" |
25 #include "grit/browser_resources.h" | 26 #include "grit/browser_resources.h" |
26 #include "grit/chromium_strings.h" | 27 #include "grit/chromium_strings.h" |
27 #include "grit/generated_resources.h" | 28 #include "grit/generated_resources.h" |
28 #include "grit/locale_settings.h" | 29 #include "grit/locale_settings.h" |
29 #include "grit/theme_resources.h" | 30 #include "grit/theme_resources.h" |
30 #include "ui/base/l10n/l10n_util.h" | 31 #include "ui/base/l10n/l10n_util.h" |
31 #include "ui/base/resource/resource_bundle.h" | 32 #include "ui/base/resource/resource_bundle.h" |
32 | 33 |
33 SystemOptionsHandler::SystemOptionsHandler() | 34 SystemOptionsHandler::SystemOptionsHandler() { |
34 : chromeos::CrosOptionsPageUIHandler( | |
35 new chromeos::SystemSettingsProvider()) { | |
36 } | 35 } |
37 | 36 |
38 SystemOptionsHandler::~SystemOptionsHandler() { | 37 SystemOptionsHandler::~SystemOptionsHandler() { |
39 } | 38 } |
40 | 39 |
41 void SystemOptionsHandler::GetLocalizedValues( | 40 void SystemOptionsHandler::GetLocalizedValues( |
42 DictionaryValue* localized_strings) { | 41 DictionaryValue* localized_strings) { |
43 DCHECK(localized_strings); | 42 DCHECK(localized_strings); |
44 | 43 |
45 RegisterTitle(localized_strings, "systemPage", IDS_OPTIONS_SYSTEM_TAB_LABEL); | 44 RegisterTitle(localized_strings, "systemPage", IDS_OPTIONS_SYSTEM_TAB_LABEL); |
(...skipping 28 matching lines...) Expand all Loading... | |
74 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); | 73 IDS_OPTIONS_SETTINGS_LANGUAGES_MODIFIER_KEYS_CUSTOMIZE)); |
75 | 74 |
76 localized_strings->SetString("accessibility_title", | 75 localized_strings->SetString("accessibility_title", |
77 l10n_util::GetStringUTF16( | 76 l10n_util::GetStringUTF16( |
78 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); | 77 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY)); |
79 localized_strings->SetString("accessibility", | 78 localized_strings->SetString("accessibility", |
80 l10n_util::GetStringUTF16( | 79 l10n_util::GetStringUTF16( |
81 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); | 80 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION)); |
82 | 81 |
83 localized_strings->Set("timezoneList", | 82 localized_strings->Set("timezoneList", |
84 reinterpret_cast<chromeos::SystemSettingsProvider*>( | 83 reinterpret_cast<chromeos::SystemSettingsProvider*>( |
Denis Lagno
2011/09/20 14:05:22
btw, why not static_cast here?
pastarmovj
2011/09/20 17:11:52
Done.
| |
85 settings_provider_.get())->GetTimezoneList()); | 84 chromeos::CrosSettings::Get()->GetProvider( |
85 chromeos::kSystemTimezone))->GetTimezoneList()); | |
86 } | 86 } |
87 | 87 |
88 void SystemOptionsHandler::Initialize() { | 88 void SystemOptionsHandler::Initialize() { |
89 DCHECK(web_ui_); | 89 DCHECK(web_ui_); |
90 PrefService* pref_service = g_browser_process->local_state(); | 90 PrefService* pref_service = g_browser_process->local_state(); |
91 bool acc_enabled = pref_service->GetBoolean(prefs::kAccessibilityEnabled); | 91 bool acc_enabled = pref_service->GetBoolean(prefs::kAccessibilityEnabled); |
92 base::FundamentalValue checked(acc_enabled); | 92 base::FundamentalValue checked(acc_enabled); |
93 web_ui_->CallJavascriptFunction( | 93 web_ui_->CallJavascriptFunction( |
94 "options.SystemOptions.SetAccessibilityCheckboxState", checked); | 94 "options.SystemOptions.SetAccessibilityCheckboxState", checked); |
95 } | 95 } |
96 | 96 |
97 void SystemOptionsHandler::RegisterMessages() { | 97 void SystemOptionsHandler::RegisterMessages() { |
98 DCHECK(web_ui_); | 98 DCHECK(web_ui_); |
99 web_ui_->RegisterMessageCallback("accessibilityChange", | 99 web_ui_->RegisterMessageCallback("accessibilityChange", |
100 NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); | 100 NewCallback(this, &SystemOptionsHandler::AccessibilityChangeCallback)); |
101 } | 101 } |
102 | 102 |
103 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { | 103 void SystemOptionsHandler::AccessibilityChangeCallback(const ListValue* args) { |
104 std::string checked_str; | 104 std::string checked_str; |
105 args->GetString(0, &checked_str); | 105 args->GetString(0, &checked_str); |
106 bool accessibility_enabled = (checked_str == "true"); | 106 bool accessibility_enabled = (checked_str == "true"); |
107 | 107 |
108 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); | 108 chromeos::accessibility::EnableAccessibility(accessibility_enabled, NULL); |
109 } | 109 } |
OLD | NEW |