OLD | NEW |
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/browser_options_handler2.h" | 5 #include "chrome/browser/ui/webui/options2/browser_options_handler2.h" |
6 | 6 |
| 7 #include <string> |
| 8 |
7 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
8 #include "base/bind.h" | 10 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 12 #include "base/command_line.h" |
11 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
12 #include "base/path_service.h" | 14 #include "base/path_service.h" |
13 #include "base/stl_util.h" | 15 #include "base/stl_util.h" |
14 #include "base/string_number_conversions.h" | 16 #include "base/string_number_conversions.h" |
15 #include "base/utf_string_conversions.h" | 17 #include "base/utf_string_conversions.h" |
16 #include "base/value_conversions.h" | 18 #include "base/value_conversions.h" |
17 #include "base/values.h" | 19 #include "base/values.h" |
18 #include "chrome/browser/auto_launch_trial.h" | 20 #include "chrome/browser/auto_launch_trial.h" |
19 #include "chrome/browser/autocomplete/autocomplete.h" | 21 #include "chrome/browser/autocomplete/autocomplete.h" |
20 #include "chrome/browser/autocomplete/autocomplete_match.h" | 22 #include "chrome/browser/autocomplete/autocomplete_match.h" |
21 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 24 #include "chrome/browser/chrome_page_zoom.h" |
22 #include "chrome/browser/custom_home_pages_table_model.h" | 25 #include "chrome/browser/custom_home_pages_table_model.h" |
| 26 #include "chrome/browser/download/download_prefs.h" |
23 #include "chrome/browser/instant/instant_confirm_dialog.h" | 27 #include "chrome/browser/instant/instant_confirm_dialog.h" |
24 #include "chrome/browser/instant/instant_controller.h" | 28 #include "chrome/browser/instant/instant_controller.h" |
25 #include "chrome/browser/instant/instant_field_trial.h" | 29 #include "chrome/browser/instant/instant_field_trial.h" |
26 #include "chrome/browser/net/url_fixer_upper.h" | 30 #include "chrome/browser/net/url_fixer_upper.h" |
27 #include "chrome/browser/prefs/pref_service.h" | 31 #include "chrome/browser/prefs/pref_service.h" |
28 #include "chrome/browser/prefs/session_startup_pref.h" | 32 #include "chrome/browser/prefs/session_startup_pref.h" |
| 33 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h" |
| 34 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service_factory.
h" |
| 35 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h" |
| 36 #include "chrome/browser/printing/cloud_print/cloud_print_url.h" |
29 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
30 #include "chrome/browser/profiles/profile_info_cache.h" | 38 #include "chrome/browser/profiles/profile_info_cache.h" |
31 #include "chrome/browser/profiles/profile_info_util.h" | 39 #include "chrome/browser/profiles/profile_info_util.h" |
32 #include "chrome/browser/profiles/profile_manager.h" | 40 #include "chrome/browser/profiles/profile_manager.h" |
33 #include "chrome/browser/search_engines/template_url.h" | 41 #include "chrome/browser/search_engines/template_url.h" |
34 #include "chrome/browser/search_engines/template_url_service.h" | 42 #include "chrome/browser/search_engines/template_url_service.h" |
35 #include "chrome/browser/search_engines/template_url_service_factory.h" | 43 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 44 #include "chrome/browser/service/service_process_control.h" |
36 #include "chrome/browser/sync/profile_sync_service.h" | 45 #include "chrome/browser/sync/profile_sync_service.h" |
37 #include "chrome/browser/sync/profile_sync_service_factory.h" | 46 #include "chrome/browser/sync/profile_sync_service_factory.h" |
38 #include "chrome/browser/sync/sync_setup_flow.h" | 47 #include "chrome/browser/sync/sync_setup_flow.h" |
39 #include "chrome/browser/sync/sync_ui_util.h" | 48 #include "chrome/browser/sync/sync_ui_util.h" |
40 #include "chrome/browser/themes/theme_service.h" | 49 #include "chrome/browser/themes/theme_service.h" |
41 #include "chrome/browser/themes/theme_service_factory.h" | 50 #include "chrome/browser/themes/theme_service_factory.h" |
| 51 #include "chrome/browser/ui/options/options_util.h" |
42 #include "chrome/browser/ui/webui/favicon_source.h" | 52 #include "chrome/browser/ui/webui/favicon_source.h" |
43 #include "chrome/browser/ui/webui/web_ui_util.h" | 53 #include "chrome/browser/ui/webui/web_ui_util.h" |
44 #include "chrome/common/chrome_constants.h" | 54 #include "chrome/common/chrome_constants.h" |
45 #include "chrome/common/chrome_notification_types.h" | 55 #include "chrome/common/chrome_notification_types.h" |
46 #include "chrome/common/chrome_paths.h" | 56 #include "chrome/common/chrome_paths.h" |
47 #include "chrome/common/chrome_switches.h" | 57 #include "chrome/common/chrome_switches.h" |
48 #include "chrome/common/net/gaia/google_service_auth_error.h" | 58 #include "chrome/common/net/gaia/google_service_auth_error.h" |
49 #include "chrome/common/pref_names.h" | 59 #include "chrome/common/pref_names.h" |
50 #include "chrome/common/url_constants.h" | 60 #include "chrome/common/url_constants.h" |
51 #include "content/public/browser/browser_thread.h" | 61 #include "content/public/browser/browser_thread.h" |
| 62 #include "content/public/browser/download_manager.h" |
52 #include "content/public/browser/navigation_controller.h" | 63 #include "content/public/browser/navigation_controller.h" |
53 #include "content/public/browser/notification_details.h" | 64 #include "content/public/browser/notification_details.h" |
54 #include "content/public/browser/notification_service.h" | 65 #include "content/public/browser/notification_service.h" |
55 #include "content/public/browser/notification_source.h" | 66 #include "content/public/browser/notification_source.h" |
| 67 #include "content/public/browser/notification_types.h" |
56 #include "content/public/browser/user_metrics.h" | 68 #include "content/public/browser/user_metrics.h" |
57 #include "content/public/browser/web_contents.h" | 69 #include "content/public/browser/web_contents.h" |
| 70 #include "content/public/browser/web_contents_view.h" |
| 71 #include "content/public/common/page_zoom.h" |
58 #include "grit/chromium_strings.h" | 72 #include "grit/chromium_strings.h" |
59 #include "grit/generated_resources.h" | 73 #include "grit/generated_resources.h" |
60 #include "grit/locale_settings.h" | 74 #include "grit/locale_settings.h" |
61 #include "grit/theme_resources.h" | 75 #include "grit/theme_resources.h" |
| 76 #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" |
62 #include "ui/base/l10n/l10n_util.h" | 77 #include "ui/base/l10n/l10n_util.h" |
63 | 78 |
| 79 #if !defined(OS_CHROMEOS) |
| 80 #include "chrome/browser/printing/cloud_print/cloud_print_setup_handler.h" |
| 81 #include "chrome/browser/ui/webui/options2/advanced_options_utils2.h" |
| 82 #endif |
| 83 |
64 #if defined(OS_CHROMEOS) | 84 #if defined(OS_CHROMEOS) |
| 85 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
65 #include "chrome/browser/chromeos/cros_settings.h" | 86 #include "chrome/browser/chromeos/cros_settings.h" |
66 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 87 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
67 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 88 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
68 #include "chrome/browser/chromeos/login/user_manager.h" | 89 #include "chrome/browser/chromeos/login/user_manager.h" |
69 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 90 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
70 #include "chrome/browser/ui/browser_window.h" | 91 #include "chrome/browser/ui/browser_window.h" |
71 #include "chrome/browser/ui/views/window.h" | 92 #include "chrome/browser/ui/views/window.h" |
| 93 #include "chrome/browser/ui/webui/options2/chromeos/system_settings_provider2.h" |
72 #include "third_party/skia/include/core/SkBitmap.h" | 94 #include "third_party/skia/include/core/SkBitmap.h" |
73 #endif // defined(OS_CHROMEOS) | 95 #endif // defined(OS_CHROMEOS) |
74 | 96 |
75 #if defined(OS_WIN) | 97 #if defined(OS_WIN) |
76 #include "chrome/installer/util/auto_launch_util.h" | 98 #include "chrome/installer/util/auto_launch_util.h" |
77 #endif // defined(OS_WIN) | 99 #endif // defined(OS_WIN) |
78 | 100 |
79 #if defined(TOOLKIT_GTK) | 101 #if defined(TOOLKIT_GTK) |
80 #include "chrome/browser/ui/gtk/theme_service_gtk.h" | 102 #include "chrome/browser/ui/gtk/theme_service_gtk.h" |
81 #endif // defined(TOOLKIT_GTK) | 103 #endif // defined(TOOLKIT_GTK) |
82 | 104 |
83 using content::BrowserThread; | 105 using content::BrowserThread; |
| 106 using content::DownloadManager; |
| 107 using content::OpenURLParams; |
| 108 using content::Referrer; |
84 using content::UserMetricsAction; | 109 using content::UserMetricsAction; |
85 | 110 |
86 namespace options2 { | 111 namespace options2 { |
87 | 112 |
88 BrowserOptionsHandler::BrowserOptionsHandler() | 113 BrowserOptionsHandler::BrowserOptionsHandler() |
89 : template_url_service_(NULL), | 114 : template_url_service_(NULL), |
90 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), | 115 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), |
91 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { | 116 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { |
92 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); | 117 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); |
93 #if !defined(OS_MACOSX) | 118 #if !defined(OS_MACOSX) |
94 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 119 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
95 #endif | 120 #endif |
| 121 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| 122 // On Windows, we need the PDF plugin which is only guaranteed to exist on |
| 123 // Google Chrome builds. Use a command-line switch for Windows non-Google |
| 124 // Chrome builds. |
| 125 cloud_print_connector_ui_enabled_ = |
| 126 CommandLine::ForCurrentProcess()->HasSwitch( |
| 127 switches::kEnableCloudPrintProxy); |
| 128 #elif(!defined(OS_CHROMEOS)) |
| 129 // Always enabled for Mac, Linux and Google Chrome Windows builds. |
| 130 // Never enabled for Chrome OS, we don't even need to indicate it. |
| 131 cloud_print_connector_ui_enabled_ = true; |
| 132 #endif |
96 } | 133 } |
97 | 134 |
98 BrowserOptionsHandler::~BrowserOptionsHandler() { | 135 BrowserOptionsHandler::~BrowserOptionsHandler() { |
99 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: | 136 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: |
100 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 137 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); |
101 if (sync_service) | 138 if (sync_service) |
102 sync_service->RemoveObserver(this); | 139 sync_service->RemoveObserver(this); |
103 | 140 |
104 if (default_browser_worker_.get()) | 141 if (default_browser_worker_.get()) |
105 default_browser_worker_->ObserverDestroyed(); | 142 default_browser_worker_->ObserverDestroyed(); |
106 if (template_url_service_) | 143 if (template_url_service_) |
107 template_url_service_->RemoveObserver(this); | 144 template_url_service_->RemoveObserver(this); |
| 145 // There may be pending file dialogs, we need to tell them that we've gone |
| 146 // away so they don't try and call back to us. |
| 147 if (select_folder_dialog_.get()) |
| 148 select_folder_dialog_->ListenerDestroyed(); |
108 } | 149 } |
109 | 150 |
110 void BrowserOptionsHandler::GetLocalizedValues( | 151 void BrowserOptionsHandler::GetLocalizedValues( |
111 DictionaryValue* localized_strings) { | 152 DictionaryValue* localized_strings) { |
112 DCHECK(localized_strings); | 153 DCHECK(localized_strings); |
113 | 154 |
114 static OptionsStringResource resources[] = { | 155 static OptionsStringResource resources[] = { |
115 { "advancedSettings", IDS_OPTIONS_ADVANCED_BUTTON_TITLE }, | 156 { "advancedSectionTitleCloudPrint", IDS_GOOGLE_CLOUD_PRINT }, |
| 157 { "advancedSectionTitleContent", |
| 158 IDS_OPTIONS_ADVANCED_SECTION_TITLE_CONTENT }, |
| 159 { "advancedSectionTitleLanguages", |
| 160 IDS_OPTIONS_ADVANCED_SECTION_TITLE_LANGUAGES }, |
| 161 { "advancedSectionTitleNetwork", |
| 162 IDS_OPTIONS_ADVANCED_SECTION_TITLE_NETWORK }, |
| 163 { "advancedSectionTitlePrivacy", |
| 164 IDS_OPTIONS_ADVANCED_SECTION_TITLE_PRIVACY }, |
| 165 { "advancedSectionTitleSecurity", |
| 166 IDS_OPTIONS_ADVANCED_SECTION_TITLE_SECURITY }, |
| 167 { "autofillEnabled", IDS_OPTIONS_AUTOFILL_ENABLE }, |
116 { "autologinEnabled", IDS_OPTIONS_PASSWORDS_AUTOLOGIN }, | 168 { "autologinEnabled", IDS_OPTIONS_PASSWORDS_AUTOLOGIN }, |
| 169 { "autoOpenFileTypesInfo", IDS_OPTIONS_OPEN_FILE_TYPES_AUTOMATICALLY }, |
| 170 { "autoOpenFileTypesResetToDefault", |
| 171 IDS_OPTIONS_AUTOOPENFILETYPES_RESETTODEFAULT }, |
117 { "browsingData", IDS_OPTIONS_BROWSING_DATA_GROUP_NAME }, // needed? | 172 { "browsingData", IDS_OPTIONS_BROWSING_DATA_GROUP_NAME }, // needed? |
118 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE }, | 173 { "changeHomePage", IDS_OPTIONS_CHANGE_HOME_PAGE }, |
| 174 { "certificatesManageButton", IDS_OPTIONS_CERTIFICATES_MANAGE_BUTTON }, |
119 { "customizeSync", IDS_OPTIONS2_CUSTOMIZE_SYNC_BUTTON_LABEL }, | 175 { "customizeSync", IDS_OPTIONS2_CUSTOMIZE_SYNC_BUTTON_LABEL }, |
| 176 { "defaultFontSizeLabel", IDS_OPTIONS_DEFAULT_FONT_SIZE_LABEL }, |
120 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES }, | 177 { "defaultSearchManageEngines", IDS_OPTIONS_DEFAULTSEARCH_MANAGE_ENGINES }, |
| 178 { "defaultZoomFactorLabel", IDS_OPTIONS_DEFAULT_ZOOM_LEVEL_LABEL }, |
| 179 { "disableWebServices", IDS_OPTIONS_DISABLE_WEB_SERVICES }, |
| 180 { "downloadLocationAskForSaveLocation", |
| 181 IDS_OPTIONS_DOWNLOADLOCATION_ASKFORSAVELOCATION }, |
| 182 { "downloadLocationBrowseTitle", |
| 183 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE }, |
| 184 { "downloadLocationBrowseWindowTitle", |
| 185 IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_WINDOW_TITLE }, |
| 186 { "downloadLocationChangeButton", |
| 187 IDS_OPTIONS_DOWNLOADLOCATION_CHANGE_BUTTON }, |
| 188 { "downloadLocationGroupName", IDS_OPTIONS_DOWNLOADLOCATION_GROUP_NAME }, |
| 189 { "enableLogging", IDS_OPTIONS_ENABLE_LOGGING }, |
| 190 { "fontSettingsCustomizeFontsButton", |
| 191 IDS_OPTIONS_FONTSETTINGS_CUSTOMIZE_FONTS_BUTTON }, |
| 192 { "fontSettingsInfo", IDS_OPTIONS_FONTSETTINGS_INFO }, |
| 193 { "fontSizeLabelCustom", IDS_OPTIONS_FONT_SIZE_LABEL_CUSTOM }, |
| 194 { "fontSizeLabelLarge", IDS_OPTIONS_FONT_SIZE_LABEL_LARGE }, |
| 195 { "fontSizeLabelMedium", IDS_OPTIONS_FONT_SIZE_LABEL_MEDIUM }, |
| 196 { "fontSizeLabelSmall", IDS_OPTIONS_FONT_SIZE_LABEL_SMALL }, |
| 197 { "fontSizeLabelVeryLarge", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_LARGE }, |
| 198 { "fontSizeLabelVerySmall", IDS_OPTIONS_FONT_SIZE_LABEL_VERY_SMALL }, |
| 199 { "hideAdvancedSettings", IDS_SETTINGS_HIDE_ADVANCED_SETTINGS }, |
121 { "homePage", IDS_OPTIONS2_HOMEPAGE }, | 200 { "homePage", IDS_OPTIONS2_HOMEPAGE }, |
122 { "homePageChoose", IDS_OPTIONS2_HOMEPAGE_CHOOSE }, | 201 { "homePageChoose", IDS_OPTIONS2_HOMEPAGE_CHOOSE }, |
123 { "homePageDialogLabel", IDS_OPTIONS2_HOMEPAGE_DIALOG_LABEL }, | 202 { "homePageDialogLabel", IDS_OPTIONS2_HOMEPAGE_DIALOG_LABEL }, |
124 { "homePageTitle", IDS_OPTIONS2_HOMEPAGE_TITLE }, | 203 { "homePageTitle", IDS_OPTIONS2_HOMEPAGE_TITLE }, |
125 { "homePageNone", IDS_OPTIONS2_HOMEPAGE_NONE }, | 204 { "homePageNone", IDS_OPTIONS2_HOMEPAGE_NONE }, |
126 { "homePageNtp", IDS_OPTIONS2_HOMEPAGE_NTP }, | 205 { "homePageNtp", IDS_OPTIONS2_HOMEPAGE_NTP }, |
127 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, | 206 { "homePageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, |
128 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, | 207 { "homePageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, |
129 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, | 208 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, |
130 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, | 209 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, |
131 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, | 210 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, |
| 211 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, |
| 212 { "languageAndSpellCheckSettingsButton", |
| 213 #if defined(OS_CHROMEOS) |
| 214 IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE }, |
| 215 #else |
| 216 IDS_OPTIONS_LANGUAGE_AND_SPELLCHECK_BUTTON }, |
| 217 #endif |
| 218 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, |
| 219 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, |
132 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, | 220 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, |
| 221 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, |
| 222 { "networkPredictionEnabledDescription", |
| 223 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, |
| 224 { "passwordsAndAutofillGroupName", |
| 225 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, |
| 226 { "passwordManagerEnabled", IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, |
| 227 { "privacyClearDataButton", IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON }, |
| 228 { "privacyContentSettingsButton", |
| 229 IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON }, |
133 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, | 230 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, |
134 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, | 231 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, |
135 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, | 232 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, |
136 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, | 233 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, |
137 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, | 234 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, |
138 { "sectionTitleAdvanced", IDS_OPTIONS_ADVANCED_TAB_LABEL }, | 235 { "proxiesLabel", IDS_OPTIONS_PROXIES_LABEL }, |
| 236 { "safeBrowsingEnableProtection", |
| 237 IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION }, |
139 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME }, | 238 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME }, |
140 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, | 239 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, |
141 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME }, | 240 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME }, |
142 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, | 241 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, |
143 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME }, | 242 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME }, |
144 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME }, | 243 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME }, |
145 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE }, | 244 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE }, |
146 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE }, | 245 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE }, |
147 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION }, | 246 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION }, |
148 { "settingsTitle", IDS_SETTINGS_TITLE }, | 247 { "settingsTitle", IDS_SETTINGS_TITLE }, |
| 248 { "showAdvancedSettings", IDS_SETTINGS_SHOW_ADVANCED_SETTINGS }, |
| 249 { "spellingPref", IDS_OPTIONS_SPELLING_PREF }, |
| 250 { "sslCheckRevocation", IDS_OPTIONS_SSL_CHECKREVOCATION }, |
| 251 { "sslGroupDescription", IDS_OPTIONS_SSL_GROUP_DESCRIPTION }, |
149 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, | 252 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, |
150 { "startupShowHomePage", IDS_OPTIONS2_STARTUP_SHOW_HOME_PAGE }, | 253 { "startupShowHomePage", IDS_OPTIONS2_STARTUP_SHOW_HOME_PAGE }, |
151 { "startupShowNewTab", IDS_OPTIONS2_STARTUP_SHOW_NEWTAB }, | 254 { "startupShowNewTab", IDS_OPTIONS2_STARTUP_SHOW_NEWTAB }, |
152 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, | 255 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, |
153 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, | 256 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, |
| 257 { "suggestPref", IDS_OPTIONS_SUGGEST_PREF }, |
154 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS }, | 258 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS }, |
155 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL }, | 259 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL }, |
156 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, | 260 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, |
157 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, | 261 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, |
| 262 { "tabsToLinksPref", IDS_OPTIONS_TABS_TO_LINKS_PREF }, |
158 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, | 263 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, |
159 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, | 264 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, |
160 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, | 265 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, |
| 266 { "translateEnableTranslate", |
| 267 IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE }, |
161 #if defined(TOOLKIT_GTK) | 268 #if defined(TOOLKIT_GTK) |
162 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, | 269 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, |
163 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, | 270 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, |
164 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, | 271 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, |
165 #else | 272 #else |
166 { "themes", IDS_THEMES_GROUP_NAME }, | 273 { "themes", IDS_THEMES_GROUP_NAME }, |
167 { "themesReset", IDS_THEMES_RESET_BUTTON }, | 274 { "themesReset", IDS_THEMES_RESET_BUTTON }, |
168 #endif | 275 #endif |
169 #if defined(OS_CHROMEOS) | 276 #if defined(OS_CHROMEOS) |
| 277 { "accessibilityHighContrast", |
| 278 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, |
| 279 { "accessibilityScreenMagnifier", |
| 280 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_DESCRIPTION }, |
| 281 { "accessibilitySpokenFeedback", |
| 282 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION }, |
| 283 { "accessibilityTitle", |
| 284 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY }, |
| 285 { "accessibilityVirtualKeyboard", |
| 286 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_VIRTUAL_KEYBOARD_DESCRIPTION }, |
170 { "brightnessDecrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE }, | 287 { "brightnessDecrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE }, |
171 { "brightnessIncrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE }, | 288 { "brightnessIncrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE }, |
172 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, | 289 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, |
| 290 { "datetimeTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME }, |
173 { "deviceGroupBrightness", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION }, | 291 { "deviceGroupBrightness", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION }, |
174 { "deviceGroupKeyboard", IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SECTION }, | 292 { "deviceGroupKeyboard", IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SECTION }, |
175 { "deviceGroupPointer", IDS_OPTIONS_DEVICE_GROUP_POINTER_SECTION }, | 293 { "deviceGroupPointer", IDS_OPTIONS_DEVICE_GROUP_POINTER_SECTION }, |
176 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, | 294 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, |
177 { "internetOptionsButtonTitle", IDS_OPTIONS_INTERNET_OPTIONS_BUTTON_TITLE }, | 295 { "internetOptionsButtonTitle", IDS_OPTIONS_INTERNET_OPTIONS_BUTTON_TITLE }, |
178 { "keyboardSettingsButtonTitle", | 296 { "keyboardSettingsButtonTitle", |
179 IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SETTINGS_BUTTON_TITLE }, | 297 IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SETTINGS_BUTTON_TITLE }, |
180 { "manageAccountsButtonTitle", IDS_OPTIONS_ACCOUNTS_BUTTON_TITLE }, | 298 { "manageAccountsButtonTitle", IDS_OPTIONS_ACCOUNTS_BUTTON_TITLE }, |
181 { "pointerSensitivityLess", | 299 { "pointerSensitivityLess", |
182 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION }, | 300 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION }, |
183 { "pointerSensitivityMore", | 301 { "pointerSensitivityMore", |
184 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION }, | 302 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION }, |
185 { "pointerSettingsButtonTitle", | 303 { "pointerSettingsButtonTitle", |
186 IDS_OPTIONS_DEVICE_GROUP_POINTER_SETTINGS_BUTTON_TITLE }, | 304 IDS_OPTIONS_DEVICE_GROUP_POINTER_SETTINGS_BUTTON_TITLE }, |
187 { "sectionTitleDevice", IDS_OPTIONS_DEVICE_GROUP_NAME }, | 305 { "sectionTitleDevice", IDS_OPTIONS_DEVICE_GROUP_NAME }, |
188 { "sectionTitleInternet", IDS_OPTIONS_INTERNET_OPTIONS_GROUP_LABEL }, | 306 { "sectionTitleInternet", IDS_OPTIONS_INTERNET_OPTIONS_GROUP_LABEL }, |
| 307 { "timezone", IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION }, |
| 308 { "use24HourClock", IDS_OPTIONS_SETTINGS_USE_24HOUR_CLOCK_DESCRIPTION }, |
| 309 #else |
| 310 { "cloudPrintConnectorEnabledManageButton", |
| 311 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_MANAGE_BUTTON}, |
| 312 { "cloudPrintConnectorEnablingButton", |
| 313 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON }, |
| 314 { "proxiesConfigureButton", IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON }, |
| 315 #endif |
| 316 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 317 { "advancedSectionTitleBackground", |
| 318 IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND }, |
| 319 { "backgroundModeCheckbox", IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE }, |
189 #endif | 320 #endif |
190 }; | 321 }; |
191 | 322 |
192 RegisterStrings(localized_strings, resources, arraysize(resources)); | 323 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 324 RegisterCloudPrintStrings(localized_strings); |
193 RegisterTitle(localized_strings, "homePageOverlay", | 325 RegisterTitle(localized_strings, "homePageOverlay", |
194 IDS_OPTIONS2_HOMEPAGE_TITLE); | 326 IDS_OPTIONS2_HOMEPAGE_TITLE); |
195 | 327 |
196 localized_strings->SetString( | 328 localized_strings->SetString( |
197 "syncOverview", | 329 "syncOverview", |
198 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, | 330 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, |
199 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 331 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
200 localized_strings->SetString( | 332 localized_strings->SetString( |
201 "syncButtonTextStart", | 333 "syncButtonTextStart", |
202 l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 334 l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 | 367 |
236 #if defined(OS_CHROMEOS) | 368 #if defined(OS_CHROMEOS) |
237 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 369 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
238 localized_strings->SetString("username", | 370 localized_strings->SetString("username", |
239 chromeos::UserManager::Get()->logged_in_user().email()); | 371 chromeos::UserManager::Get()->logged_in_user().email()); |
240 } | 372 } |
241 #endif | 373 #endif |
242 | 374 |
243 // Pass along sync status early so it will be available during page init. | 375 // Pass along sync status early so it will be available during page init. |
244 localized_strings->Set("syncData", GetSyncStateDictionary()); | 376 localized_strings->Set("syncData", GetSyncStateDictionary()); |
| 377 |
| 378 localized_strings->SetString("privacyLearnMoreURL", |
| 379 chrome::kPrivacyLearnMoreURL); |
| 380 |
| 381 localized_strings->SetString( |
| 382 "languageSectionLabel", |
| 383 l10n_util::GetStringFUTF16( |
| 384 IDS_OPTIONS_ADVANCED_LANGUAGE_LABEL, |
| 385 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 386 |
| 387 #if defined(OS_CHROMEOS) |
| 388 localized_strings->SetString("cloudPrintLearnMoreURL", |
| 389 chrome::kCloudPrintLearnMoreURL); |
| 390 |
| 391 // TODO(pastarmovj): replace this with a call to the CrosSettings list |
| 392 // handling functionality to come. |
| 393 localized_strings->Set("timezoneList", |
| 394 static_cast<chromeos::options2::SystemSettingsProvider*>( |
| 395 chromeos::CrosSettings::Get()->GetProvider( |
| 396 chromeos::kSystemTimezone))->GetTimezoneList()); |
| 397 #endif |
| 398 #if defined(OS_MACOSX) |
| 399 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 400 if (profile_manager->GetNumberOfProfiles() > 1) { |
| 401 localized_strings->SetString("macPasswordsWarning", |
| 402 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 403 } |
| 404 #endif |
| 405 } |
| 406 |
| 407 void BrowserOptionsHandler::RegisterCloudPrintStrings( |
| 408 DictionaryValue* localized_strings) { |
| 409 #if defined(OS_CHROMEOS) |
| 410 localized_strings->SetString("cloudPrintChromeosOptionLabel", |
| 411 l10n_util::GetStringFUTF16( |
| 412 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, |
| 413 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 414 localized_strings->SetString("cloudPrintChromeosOptionButton", |
| 415 l10n_util::GetStringFUTF16( |
| 416 IDS_CLOUD_PRINT_CHROMEOS_OPTION_BUTTON, |
| 417 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 418 #else |
| 419 localized_strings->SetString("cloudPrintConnectorDisabledLabel", |
| 420 l10n_util::GetStringFUTF16( |
| 421 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, |
| 422 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 423 localized_strings->SetString("cloudPrintConnectorDisabledButton", |
| 424 l10n_util::GetStringFUTF16( |
| 425 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_BUTTON, |
| 426 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 427 localized_strings->SetString("cloudPrintConnectorEnabledButton", |
| 428 l10n_util::GetStringFUTF16( |
| 429 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_BUTTON, |
| 430 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 431 #endif |
245 } | 432 } |
246 | 433 |
247 void BrowserOptionsHandler::RegisterMessages() { | 434 void BrowserOptionsHandler::RegisterMessages() { |
248 web_ui()->RegisterMessageCallback( | 435 web_ui()->RegisterMessageCallback( |
249 "becomeDefaultBrowser", | 436 "becomeDefaultBrowser", |
250 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, | 437 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, |
251 base::Unretained(this))); | 438 base::Unretained(this))); |
252 web_ui()->RegisterMessageCallback( | 439 web_ui()->RegisterMessageCallback( |
253 "setDefaultSearchEngine", | 440 "setDefaultSearchEngine", |
254 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, | 441 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 #if defined(OS_CHROMEOS) | 473 #if defined(OS_CHROMEOS) |
287 web_ui()->RegisterMessageCallback( | 474 web_ui()->RegisterMessageCallback( |
288 "decreaseScreenBrightness", | 475 "decreaseScreenBrightness", |
289 base::Bind(&BrowserOptionsHandler::DecreaseScreenBrightnessCallback, | 476 base::Bind(&BrowserOptionsHandler::DecreaseScreenBrightnessCallback, |
290 base::Unretained(this))); | 477 base::Unretained(this))); |
291 web_ui()->RegisterMessageCallback( | 478 web_ui()->RegisterMessageCallback( |
292 "increaseScreenBrightness", | 479 "increaseScreenBrightness", |
293 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, | 480 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, |
294 base::Unretained(this))); | 481 base::Unretained(this))); |
295 #endif | 482 #endif |
| 483 web_ui()->RegisterMessageCallback( |
| 484 "selectDownloadLocation", |
| 485 base::Bind(&BrowserOptionsHandler::HandleSelectDownloadLocation, |
| 486 base::Unretained(this))); |
| 487 web_ui()->RegisterMessageCallback( |
| 488 "autoOpenFileTypesAction", |
| 489 base::Bind(&BrowserOptionsHandler::HandleAutoOpenButton, |
| 490 base::Unretained(this))); |
| 491 web_ui()->RegisterMessageCallback( |
| 492 "defaultFontSizeAction", |
| 493 base::Bind(&BrowserOptionsHandler::HandleDefaultFontSize, |
| 494 base::Unretained(this))); |
| 495 web_ui()->RegisterMessageCallback( |
| 496 "defaultZoomFactorAction", |
| 497 base::Bind(&BrowserOptionsHandler::HandleDefaultZoomFactor, |
| 498 base::Unretained(this))); |
| 499 #if !defined(OS_CHROMEOS) |
| 500 web_ui()->RegisterMessageCallback( |
| 501 "metricsReportingCheckboxAction", |
| 502 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingCheckbox, |
| 503 base::Unretained(this))); |
| 504 #endif |
| 505 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 506 web_ui()->RegisterMessageCallback( |
| 507 "showManageSSLCertificates", |
| 508 base::Bind(&BrowserOptionsHandler::ShowManageSSLCertificates, |
| 509 base::Unretained(this))); |
| 510 #endif |
| 511 web_ui()->RegisterMessageCallback( |
| 512 "showCloudPrintManagePage", |
| 513 base::Bind(&BrowserOptionsHandler::ShowCloudPrintManagePage, |
| 514 base::Unretained(this))); |
| 515 #if !defined(OS_CHROMEOS) |
| 516 if (cloud_print_connector_ui_enabled_) { |
| 517 web_ui()->RegisterMessageCallback( |
| 518 "showCloudPrintSetupDialog", |
| 519 base::Bind(&BrowserOptionsHandler::ShowCloudPrintSetupDialog, |
| 520 base::Unretained(this))); |
| 521 web_ui()->RegisterMessageCallback( |
| 522 "disableCloudPrintConnector", |
| 523 base::Bind(&BrowserOptionsHandler::HandleDisableCloudPrintConnector, |
| 524 base::Unretained(this))); |
| 525 } |
| 526 web_ui()->RegisterMessageCallback( |
| 527 "showNetworkProxySettings", |
| 528 base::Bind(&BrowserOptionsHandler::ShowNetworkProxySettings, |
| 529 base::Unretained(this))); |
| 530 #endif |
| 531 web_ui()->RegisterMessageCallback( |
| 532 "checkRevocationCheckboxAction", |
| 533 base::Bind(&BrowserOptionsHandler::HandleCheckRevocationCheckbox, |
| 534 base::Unretained(this))); |
| 535 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 536 web_ui()->RegisterMessageCallback( |
| 537 "backgroundModeAction", |
| 538 base::Bind(&BrowserOptionsHandler::HandleBackgroundModeCheckbox, |
| 539 base::Unretained(this))); |
| 540 #endif |
| 541 #if defined(OS_CHROMEOS) |
| 542 web_ui()->RegisterMessageCallback( |
| 543 "spokenFeedbackChange", |
| 544 base::Bind(&BrowserOptionsHandler::SpokenFeedbackChangeCallback, |
| 545 base::Unretained(this))); |
| 546 web_ui()->RegisterMessageCallback( |
| 547 "highContrastChange", |
| 548 base::Bind(&BrowserOptionsHandler::HighContrastChangeCallback, |
| 549 base::Unretained(this))); |
| 550 web_ui()->RegisterMessageCallback( |
| 551 "screenMagnifierChange", |
| 552 base::Bind(&BrowserOptionsHandler::ScreenMagnifierChangeCallback, |
| 553 base::Unretained(this))); |
| 554 web_ui()->RegisterMessageCallback( |
| 555 "virtualKeyboardChange", |
| 556 base::Bind(&BrowserOptionsHandler::VirtualKeyboardChangeCallback, |
| 557 base::Unretained(this))); |
| 558 #endif |
296 } | 559 } |
297 | 560 |
298 void BrowserOptionsHandler::OnStateChanged() { | 561 void BrowserOptionsHandler::OnStateChanged() { |
299 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary()); | 562 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary()); |
300 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value); | 563 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value); |
301 | 564 |
302 SendProfilesInfo(); | 565 SendProfilesInfo(); |
303 } | 566 } |
304 | 567 |
305 void BrowserOptionsHandler::Initialize() { | 568 void BrowserOptionsHandler::Initialize() { |
306 Profile* profile = Profile::FromWebUI(web_ui()); | 569 Profile* profile = Profile::FromWebUI(web_ui()); |
| 570 PrefService* prefs = profile->GetPrefs(); |
307 | 571 |
308 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: | 572 ProfileSyncService* sync_service( |
309 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 573 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
310 if (sync_service) | 574 if (sync_service) |
311 sync_service->AddObserver(this); | 575 sync_service->AddObserver(this); |
312 OnStateChanged(); | 576 OnStateChanged(); |
313 | 577 |
314 // Create our favicon data source. | 578 // Create our favicon data source. |
315 profile->GetChromeURLDataManager()->AddDataSource( | 579 profile->GetChromeURLDataManager()->AddDataSource( |
316 new FaviconSource(profile, FaviconSource::FAVICON)); | 580 new FaviconSource(profile, FaviconSource::FAVICON)); |
317 | 581 |
318 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); | 582 homepage_.Init(prefs::kHomePage, prefs, NULL); |
319 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, | 583 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, |
320 g_browser_process->local_state(), | 584 g_browser_process->local_state(), |
321 this); | 585 this); |
322 UpdateDefaultBrowserState(); | 586 UpdateDefaultBrowserState(); |
323 | 587 |
324 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 588 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
325 content::NotificationService::AllSources()); | 589 content::NotificationService::AllSources()); |
326 #if defined(OS_CHROMEOS) | 590 #if defined(OS_CHROMEOS) |
327 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 591 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
328 content::NotificationService::AllSources()); | 592 content::NotificationService::AllSources()); |
(...skipping 12 matching lines...) Expand all Loading... |
341 if (!command_line.HasSwitch(switches::kChromeFrame) && | 605 if (!command_line.HasSwitch(switches::kChromeFrame) && |
342 !command_line.HasSwitch(switches::kUserDataDir)) { | 606 !command_line.HasSwitch(switches::kUserDataDir)) { |
343 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 607 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
344 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, | 608 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, |
345 weak_ptr_factory_for_ui_.GetWeakPtr(), | 609 weak_ptr_factory_for_ui_.GetWeakPtr(), |
346 weak_ptr_factory_for_file_.GetWeakPtr(), | 610 weak_ptr_factory_for_file_.GetWeakPtr(), |
347 profile->GetPath())); | 611 profile->GetPath())); |
348 weak_ptr_factory_for_ui_.DetachFromThread(); | 612 weak_ptr_factory_for_ui_.DetachFromThread(); |
349 } | 613 } |
350 #endif | 614 #endif |
| 615 |
| 616 #if !defined(OS_CHROMEOS) |
| 617 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
| 618 g_browser_process->local_state(), this); |
| 619 cloud_print_connector_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
| 620 cloud_print_connector_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, |
| 621 this); |
| 622 #endif |
| 623 |
| 624 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |
| 625 g_browser_process->local_state(), this); |
| 626 |
| 627 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 628 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, |
| 629 g_browser_process->local_state(), this); |
| 630 #endif |
| 631 |
| 632 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
| 633 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this); |
| 634 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); |
| 635 #if !defined(OS_CHROMEOS) |
| 636 proxy_prefs_.reset( |
| 637 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 638 #endif // !defined(OS_CHROMEOS) |
| 639 |
| 640 SetupMetricsReportingCheckbox(); |
| 641 SetupMetricsReportingSettingVisibility(); |
| 642 SetupFontSizeSelector(); |
| 643 SetupPageZoomSelector(); |
| 644 SetupAutoOpenFileTypesDisabledAttribute(); |
| 645 SetupProxySettingsSection(); |
| 646 SetupSSLConfigSettings(); |
| 647 #if !defined(OS_CHROMEOS) |
| 648 if (cloud_print_connector_ui_enabled_) { |
| 649 SetupCloudPrintConnectorSection(); |
| 650 RefreshCloudPrintStatusFromService(); |
| 651 } else { |
| 652 RemoveCloudPrintConnectorSection(); |
| 653 } |
| 654 #endif |
| 655 #if defined(OS_CHROMEOS) |
| 656 SetupAccessibilityFeatures(); |
| 657 #endif |
| 658 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 659 SetupBackgroundModeSettings(); |
| 660 #endif |
351 } | 661 } |
352 | 662 |
353 void BrowserOptionsHandler::CheckAutoLaunch( | 663 void BrowserOptionsHandler::CheckAutoLaunch( |
354 base::WeakPtr<BrowserOptionsHandler> weak_this, | 664 base::WeakPtr<BrowserOptionsHandler> weak_this, |
355 const FilePath& profile_path) { | 665 const FilePath& profile_path) { |
356 #if defined(OS_WIN) | 666 #if defined(OS_WIN) |
357 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 667 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
358 | 668 |
359 // Auto-launch is not supported for secondary profiles yet. | 669 // Auto-launch is not supported for secondary profiles yet. |
360 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile)) | 670 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile)) |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
539 int type, | 849 int type, |
540 const content::NotificationSource& source, | 850 const content::NotificationSource& source, |
541 const content::NotificationDetails& details) { | 851 const content::NotificationDetails& details) { |
542 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 852 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
543 ObserveThemeChanged(); | 853 ObserveThemeChanged(); |
544 #if defined(OS_CHROMEOS) | 854 #if defined(OS_CHROMEOS) |
545 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { | 855 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { |
546 UpdateAccountPicture(); | 856 UpdateAccountPicture(); |
547 #endif | 857 #endif |
548 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 858 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
549 std::string* pref = content::Details<std::string>(details).ptr(); | 859 std::string* pref_name = content::Details<std::string>(details).ptr(); |
550 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 860 if (*pref_name == prefs::kDefaultBrowserSettingEnabled) { |
551 UpdateDefaultBrowserState(); | 861 UpdateDefaultBrowserState(); |
| 862 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
| 863 SetupAutoOpenFileTypesDisabledAttribute(); |
| 864 #if !defined(OS_CHROMEOS) |
| 865 } else if (proxy_prefs_->IsObserved(*pref_name)) { |
| 866 SetupProxySettingsSection(); |
| 867 #endif // !defined(OS_CHROMEOS) |
| 868 } else if ((*pref_name == prefs::kCloudPrintEmail) || |
| 869 (*pref_name == prefs::kCloudPrintProxyEnabled)) { |
| 870 #if !defined(OS_CHROMEOS) |
| 871 if (cloud_print_connector_ui_enabled_) |
| 872 SetupCloudPrintConnectorSection(); |
| 873 #endif |
| 874 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { |
| 875 SetupFontSizeSelector(); |
| 876 } else if (*pref_name == prefs::kDefaultZoomLevel) { |
| 877 SetupPageZoomSelector(); |
| 878 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 879 } else if (*pref_name == prefs::kBackgroundModeEnabled) { |
| 880 SetupBackgroundModeSettings(); |
| 881 #endif |
552 } else { | 882 } else { |
553 NOTREACHED(); | 883 NOTREACHED(); |
554 } | 884 } |
555 } else if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { | 885 } else if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { |
556 if (multiprofile_) | 886 if (multiprofile_) |
557 SendProfilesInfo(); | 887 SendProfilesInfo(); |
558 } else { | 888 } else { |
559 NOTREACHED(); | 889 NOTREACHED(); |
560 } | 890 } |
561 } | 891 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 sync_status->SetBoolean("managed", service->IsManaged()); | 1088 sync_status->SetBoolean("managed", service->IsManaged()); |
759 sync_status->SetBoolean("hasUnrecoverableError", | 1089 sync_status->SetBoolean("hasUnrecoverableError", |
760 service->unrecoverable_error_detected()); | 1090 service->unrecoverable_error_detected()); |
761 sync_status->SetBoolean("autoLoginVisible", | 1091 sync_status->SetBoolean("autoLoginVisible", |
762 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) && | 1092 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) && |
763 service->AreCredentialsAvailable()); | 1093 service->AreCredentialsAvailable()); |
764 | 1094 |
765 return sync_status; | 1095 return sync_status; |
766 } | 1096 } |
767 | 1097 |
| 1098 void BrowserOptionsHandler::HandleSelectDownloadLocation( |
| 1099 const ListValue* args) { |
| 1100 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1101 select_folder_dialog_ = SelectFileDialog::Create(this); |
| 1102 select_folder_dialog_->SelectFile( |
| 1103 SelectFileDialog::SELECT_FOLDER, |
| 1104 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), |
| 1105 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), |
| 1106 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->GetWebContents(), |
| 1107 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); |
| 1108 } |
| 1109 |
| 1110 void BrowserOptionsHandler::FileSelected(const FilePath& path, int index, |
| 1111 void* params) { |
| 1112 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 1113 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1114 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 1115 } |
| 1116 |
| 1117 void BrowserOptionsHandler::OnCloudPrintSetupClosed() { |
| 1118 #if !defined(OS_CHROMEOS) |
| 1119 if (cloud_print_connector_ui_enabled_) |
| 1120 SetupCloudPrintConnectorSection(); |
| 1121 #endif |
| 1122 } |
| 1123 |
| 1124 void BrowserOptionsHandler::HandleAutoOpenButton(const ListValue* args) { |
| 1125 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
| 1126 DownloadManager* manager = |
| 1127 web_ui()->GetWebContents()->GetBrowserContext()->GetDownloadManager(); |
| 1128 if (manager) |
| 1129 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 1130 } |
| 1131 |
| 1132 void BrowserOptionsHandler::HandleMetricsReportingCheckbox( |
| 1133 const ListValue* args) { |
| 1134 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 1135 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1136 bool enabled = checked_str == "true"; |
| 1137 content::RecordAction( |
| 1138 enabled ? |
| 1139 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : |
| 1140 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); |
| 1141 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); |
| 1142 enable_metrics_recording_.SetValue(is_enabled); |
| 1143 SetupMetricsReportingCheckbox(); |
| 1144 #endif |
| 1145 } |
| 1146 |
| 1147 void BrowserOptionsHandler::HandleDefaultFontSize(const ListValue* args) { |
| 1148 int font_size; |
| 1149 if (ExtractIntegerValue(args, &font_size)) { |
| 1150 if (font_size > 0) { |
| 1151 default_font_size_.SetValue(font_size); |
| 1152 SetupFontSizeSelector(); |
| 1153 } |
| 1154 } |
| 1155 } |
| 1156 |
| 1157 void BrowserOptionsHandler::HandleDefaultZoomFactor(const ListValue* args) { |
| 1158 double zoom_factor; |
| 1159 if (ExtractDoubleValue(args, &zoom_factor)) { |
| 1160 default_zoom_level_.SetValue( |
| 1161 WebKit::WebView::zoomFactorToZoomLevel(zoom_factor)); |
| 1162 } |
| 1163 } |
| 1164 |
| 1165 void BrowserOptionsHandler::HandleCheckRevocationCheckbox( |
| 1166 const ListValue* args) { |
| 1167 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1168 bool enabled = checked_str == "true"; |
| 1169 content::RecordAction( |
| 1170 enabled ? |
| 1171 UserMetricsAction("Options_CheckCertRevocation_Enable") : |
| 1172 UserMetricsAction("Options_CheckCertRevocation_Disable")); |
| 1173 rev_checking_enabled_.SetValue(enabled); |
| 1174 } |
| 1175 |
| 1176 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 1177 void BrowserOptionsHandler::HandleBackgroundModeCheckbox( |
| 1178 const ListValue* args) { |
| 1179 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1180 bool enabled = checked_str == "true"; |
| 1181 content::RecordAction(enabled ? |
| 1182 UserMetricsAction("Options_BackgroundMode_Enable") : |
| 1183 UserMetricsAction("Options_BackgroundMode_Disable")); |
| 1184 background_mode_enabled_.SetValue(enabled); |
| 1185 } |
| 1186 |
| 1187 void BrowserOptionsHandler::SetupBackgroundModeSettings() { |
| 1188 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
| 1189 web_ui()->CallJavascriptFunction( |
| 1190 "BrowserOptions.setBackgroundModeCheckboxState", checked); |
| 1191 } |
| 1192 #endif |
| 1193 |
| 1194 #if !defined(OS_CHROMEOS) |
| 1195 void BrowserOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
| 1196 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
| 1197 AdvancedOptionsUtilities::ShowNetworkProxySettings( |
| 1198 web_ui()->GetWebContents()); |
| 1199 } |
| 1200 #endif |
| 1201 |
| 1202 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 1203 void BrowserOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
| 1204 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
| 1205 AdvancedOptionsUtilities::ShowManageSSLCertificates( |
| 1206 web_ui()->GetWebContents()); |
| 1207 } |
| 1208 #endif |
| 1209 |
| 1210 void BrowserOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { |
| 1211 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); |
| 1212 // Open a new tab in the current window for the management page. |
| 1213 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1214 OpenURLParams params( |
| 1215 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), |
| 1216 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 1217 web_ui()->GetWebContents()->OpenURL(params); |
| 1218 } |
| 1219 |
| 1220 #if !defined(OS_CHROMEOS) |
| 1221 void BrowserOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { |
| 1222 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); |
| 1223 // Open the connector enable page in the current tab. |
| 1224 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1225 OpenURLParams params( |
| 1226 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( |
| 1227 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
| 1228 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 1229 web_ui()->GetWebContents()->OpenURL(params); |
| 1230 } |
| 1231 |
| 1232 void BrowserOptionsHandler::HandleDisableCloudPrintConnector( |
| 1233 const ListValue* args) { |
| 1234 content::RecordAction( |
| 1235 UserMetricsAction("Options_DisableCloudPrintProxy")); |
| 1236 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 1237 DisableForUser(); |
| 1238 } |
| 1239 |
| 1240 void BrowserOptionsHandler::RefreshCloudPrintStatusFromService() { |
| 1241 if (cloud_print_connector_ui_enabled_) |
| 1242 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 1243 RefreshStatusFromService(); |
| 1244 } |
| 1245 |
| 1246 void BrowserOptionsHandler::SetupCloudPrintConnectorSection() { |
| 1247 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1248 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) { |
| 1249 cloud_print_connector_ui_enabled_ = false; |
| 1250 RemoveCloudPrintConnectorSection(); |
| 1251 return; |
| 1252 } |
| 1253 |
| 1254 bool cloud_print_connector_allowed = |
| 1255 !cloud_print_connector_enabled_.IsManaged() || |
| 1256 cloud_print_connector_enabled_.GetValue(); |
| 1257 base::FundamentalValue allowed(cloud_print_connector_allowed); |
| 1258 |
| 1259 std::string email; |
| 1260 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && |
| 1261 cloud_print_connector_allowed) { |
| 1262 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); |
| 1263 } |
| 1264 base::FundamentalValue disabled(email.empty()); |
| 1265 |
| 1266 string16 label_str; |
| 1267 if (email.empty()) { |
| 1268 label_str = l10n_util::GetStringFUTF16( |
| 1269 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, |
| 1270 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); |
| 1271 } else { |
| 1272 label_str = l10n_util::GetStringFUTF16( |
| 1273 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, |
| 1274 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), |
| 1275 UTF8ToUTF16(email)); |
| 1276 } |
| 1277 StringValue label(label_str); |
| 1278 |
| 1279 web_ui()->CallJavascriptFunction( |
| 1280 "BrowserOptions.setupCloudPrintConnectorSection", disabled, label, |
| 1281 allowed); |
| 1282 } |
| 1283 |
| 1284 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() { |
| 1285 web_ui()->CallJavascriptFunction( |
| 1286 "BrowserOptions.removeCloudPrintConnectorSection"); |
| 1287 } |
| 1288 #endif |
| 1289 |
| 1290 #if defined(OS_CHROMEOS) |
| 1291 void BrowserOptionsHandler::SpokenFeedbackChangeCallback( |
| 1292 const ListValue* args) { |
| 1293 bool enabled = false; |
| 1294 args->GetBoolean(0, &enabled); |
| 1295 |
| 1296 chromeos::accessibility::EnableSpokenFeedback(enabled, NULL); |
| 1297 } |
| 1298 |
| 1299 void BrowserOptionsHandler::HighContrastChangeCallback(const ListValue* args) { |
| 1300 bool enabled = false; |
| 1301 args->GetBoolean(0, &enabled); |
| 1302 |
| 1303 chromeos::accessibility::EnableHighContrast(enabled); |
| 1304 } |
| 1305 |
| 1306 void BrowserOptionsHandler::ScreenMagnifierChangeCallback( |
| 1307 const ListValue* args) { |
| 1308 bool enabled = false; |
| 1309 args->GetBoolean(0, &enabled); |
| 1310 |
| 1311 chromeos::accessibility::EnableScreenMagnifier(enabled); |
| 1312 } |
| 1313 |
| 1314 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( |
| 1315 const ListValue* args) { |
| 1316 bool enabled = false; |
| 1317 args->GetBoolean(0, &enabled); |
| 1318 |
| 1319 chromeos::accessibility::EnableVirtualKeyboard(enabled); |
| 1320 } |
| 1321 |
| 1322 void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
| 1323 PrefService* pref_service = g_browser_process->local_state(); |
| 1324 base::FundamentalValue spoken_feedback_enabled( |
| 1325 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)); |
| 1326 web_ui()->CallJavascriptFunction( |
| 1327 "BrowserOptions.setSpokenFeedbackCheckboxState", |
| 1328 spoken_feedback_enabled); |
| 1329 base::FundamentalValue high_contrast_enabled( |
| 1330 pref_service->GetBoolean(prefs::kHighContrastEnabled)); |
| 1331 web_ui()->CallJavascriptFunction( |
| 1332 "BrowserOptions.setHighContrastCheckboxState", |
| 1333 high_contrast_enabled); |
| 1334 base::FundamentalValue screen_magnifier_enabled( |
| 1335 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)); |
| 1336 web_ui()->CallJavascriptFunction( |
| 1337 "BrowserOptions.setScreenMagnifierCheckboxState", |
| 1338 screen_magnifier_enabled); |
| 1339 base::FundamentalValue virtual_keyboard_enabled( |
| 1340 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)); |
| 1341 web_ui()->CallJavascriptFunction( |
| 1342 "BrowserOptions.setVirtualKeyboardCheckboxState", |
| 1343 virtual_keyboard_enabled); |
| 1344 } |
| 1345 #endif |
| 1346 |
| 1347 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { |
| 1348 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 1349 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); |
| 1350 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); |
| 1351 web_ui()->CallJavascriptFunction( |
| 1352 "BrowserOptions.setMetricsReportingCheckboxState", checked, disabled); |
| 1353 #endif |
| 1354 } |
| 1355 |
| 1356 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 1357 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| 1358 // Don't show the reporting setting if we are in the guest mode. |
| 1359 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 1360 base::FundamentalValue visible(false); |
| 1361 web_ui()->CallJavascriptFunction( |
| 1362 "BrowserOptions.setMetricsReportingSettingVisibility", visible); |
| 1363 } |
| 1364 #endif |
| 1365 } |
| 1366 |
| 1367 void BrowserOptionsHandler::SetupFontSizeSelector() { |
| 1368 // We're only interested in integer values, so convert to int. |
| 1369 base::FundamentalValue font_size(default_font_size_.GetValue()); |
| 1370 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", font_size); |
| 1371 } |
| 1372 |
| 1373 void BrowserOptionsHandler::SetupPageZoomSelector() { |
| 1374 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1375 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); |
| 1376 double default_zoom_factor = |
| 1377 WebKit::WebView::zoomLevelToZoomFactor(default_zoom_level); |
| 1378 |
| 1379 // Generate a vector of zoom factors from an array of known presets along with |
| 1380 // the default factor added if necessary. |
| 1381 std::vector<double> zoom_factors = |
| 1382 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); |
| 1383 |
| 1384 // Iterate through the zoom factors and and build the contents of the |
| 1385 // selector that will be sent to the javascript handler. |
| 1386 // Each item in the list has the following parameters: |
| 1387 // 1. Title (string). |
| 1388 // 2. Value (double). |
| 1389 // 3. Is selected? (bool). |
| 1390 ListValue zoom_factors_value; |
| 1391 for (std::vector<double>::const_iterator i = zoom_factors.begin(); |
| 1392 i != zoom_factors.end(); ++i) { |
| 1393 ListValue* option = new ListValue(); |
| 1394 double factor = *i; |
| 1395 int percent = static_cast<int>(factor * 100 + 0.5); |
| 1396 option->Append(Value::CreateStringValue( |
| 1397 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); |
| 1398 option->Append(Value::CreateDoubleValue(factor)); |
| 1399 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); |
| 1400 option->Append(Value::CreateBooleanValue(selected)); |
| 1401 zoom_factors_value.Append(option); |
| 1402 } |
| 1403 |
| 1404 web_ui()->CallJavascriptFunction( |
| 1405 "BrowserOptions.setupPageZoomSelector", zoom_factors_value); |
| 1406 } |
| 1407 |
| 1408 void BrowserOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
| 1409 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
| 1410 // We enable the button if the user has any auto-open file types registered. |
| 1411 DownloadManager* manager = |
| 1412 web_ui()->GetWebContents()->GetBrowserContext()->GetDownloadManager(); |
| 1413 bool disabled = !(manager && |
| 1414 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
| 1415 base::FundamentalValue value(disabled); |
| 1416 web_ui()->CallJavascriptFunction( |
| 1417 "BrowserOptions.setAutoOpenFileTypesDisabledAttribute", value); |
| 1418 } |
| 1419 |
| 1420 void BrowserOptionsHandler::SetupProxySettingsSection() { |
| 1421 #if !defined(OS_CHROMEOS) |
| 1422 // Disable the button if proxy settings are managed by a sysadmin or |
| 1423 // overridden by an extension. |
| 1424 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1425 const PrefService::Preference* proxy_config = |
| 1426 pref_service->FindPreference(prefs::kProxy); |
| 1427 bool is_extension_controlled = (proxy_config && |
| 1428 proxy_config->IsExtensionControlled()); |
| 1429 |
| 1430 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || |
| 1431 is_extension_controlled); |
| 1432 |
| 1433 // Get the appropriate info string to describe the button. |
| 1434 string16 label_str; |
| 1435 if (is_extension_controlled) { |
| 1436 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); |
| 1437 } else { |
| 1438 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, |
| 1439 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 1440 } |
| 1441 StringValue label(label_str); |
| 1442 |
| 1443 web_ui()->CallJavascriptFunction( |
| 1444 "BrowserOptions.setupProxySettingsSection", disabled, label); |
| 1445 #endif // !defined(OS_CHROMEOS) |
| 1446 } |
| 1447 |
| 1448 void BrowserOptionsHandler::SetupSSLConfigSettings() { |
| 1449 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 1450 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 1451 web_ui()->CallJavascriptFunction( |
| 1452 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); |
| 1453 } |
| 1454 |
768 } // namespace options2 | 1455 } // namespace options2 |
OLD | NEW |