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 { "homepageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, | 200 { "homepageUseNewTab", IDS_OPTIONS_HOMEPAGE_USE_NEWTAB }, |
122 { "homepageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, | 201 { "homepageUseURL", IDS_OPTIONS_HOMEPAGE_USE_URL }, |
123 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, | 202 { "instantConfirmMessage", IDS_INSTANT_OPT_IN_MESSAGE }, |
124 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, | 203 { "instantConfirmTitle", IDS_INSTANT_OPT_IN_TITLE }, |
125 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, | 204 { "importData", IDS_OPTIONS_IMPORT_DATA_BUTTON }, |
| 205 { "improveBrowsingExperience", IDS_OPTIONS_IMPROVE_BROWSING_EXPERIENCE }, |
| 206 { "languageAndSpellCheckSettingsButton", |
| 207 #if defined(OS_CHROMEOS) |
| 208 IDS_OPTIONS_SETTINGS_LANGUAGES_CUSTOMIZE }, |
| 209 #else |
| 210 IDS_OPTIONS_LANGUAGE_AND_SPELLCHECK_BUTTON }, |
| 211 #endif |
| 212 { "linkDoctorPref", IDS_OPTIONS_LINKDOCTOR_PREF }, |
| 213 { "manageAutofillSettings", IDS_OPTIONS_MANAGE_AUTOFILL_SETTINGS_LINK }, |
126 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, | 214 { "manageDataDescription", IDS_OPTIONS_MANAGE_DATA_DESCRIPTION }, |
| 215 { "managePasswords", IDS_OPTIONS_PASSWORDS_MANAGE_PASSWORDS_LINK }, |
| 216 { "networkPredictionEnabledDescription", |
| 217 IDS_NETWORK_PREDICTION_ENABLED_DESCRIPTION }, |
| 218 { "passwordsAndAutofillGroupName", |
| 219 IDS_OPTIONS_PASSWORDS_AND_FORMS_GROUP_NAME }, |
| 220 { "passwordManagerEnabled", IDS_OPTIONS_PASSWORD_MANAGER_ENABLE }, |
| 221 { "privacyClearDataButton", IDS_OPTIONS_PRIVACY_CLEAR_DATA_BUTTON }, |
| 222 { "privacyContentSettingsButton", |
| 223 IDS_OPTIONS_PRIVACY_CONTENT_SETTINGS_BUTTON }, |
127 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, | 224 { "profilesCreate", IDS_PROFILES_CREATE_BUTTON_LABEL }, |
128 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, | 225 { "profilesDelete", IDS_PROFILES_DELETE_BUTTON_LABEL }, |
129 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, | 226 { "profilesDeleteSingle", IDS_PROFILES_DELETE_SINGLE_BUTTON_LABEL }, |
130 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, | 227 { "profilesListItemCurrent", IDS_PROFILES_LIST_ITEM_CURRENT }, |
131 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, | 228 { "profilesManage", IDS_PROFILES_MANAGE_BUTTON_LABEL }, |
132 { "sectionTitleAdvanced", IDS_OPTIONS_ADVANCED_TAB_LABEL }, | 229 { "proxiesLabel", IDS_OPTIONS_PROXIES_LABEL }, |
| 230 { "safeBrowsingEnableProtection", |
| 231 IDS_OPTIONS_SAFEBROWSING_ENABLEPROTECTION }, |
133 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME }, | 232 { "sectionTitleAppearance", IDS_APPEARANCE_GROUP_NAME }, |
134 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, | 233 { "sectionTitleDefaultBrowser", IDS_OPTIONS_DEFAULTBROWSER_GROUP_NAME }, |
135 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME }, | 234 { "sectionTitleUsers", IDS_PROFILES_OPTIONS_GROUP_NAME }, |
136 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, | 235 { "sectionTitleSearch", IDS_OPTIONS_DEFAULTSEARCH_GROUP_NAME }, |
137 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME }, | 236 { "sectionTitleStartup", IDS_OPTIONS_STARTUP_GROUP_NAME }, |
138 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME }, | 237 { "sectionTitleSync", IDS_SYNC_OPTIONS_GROUP_NAME }, |
139 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE }, | 238 { "sessionRestoreOverlayMessage", IDS_SESSION_RESTORE_OVERLAY_MESSAGE }, |
140 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE }, | 239 { "sessionRestoreOverlayTitle", IDS_SESSION_RESTORE_OVERLAY_TITLE }, |
141 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION }, | 240 { "startupRestoreLastSession", IDS_OPTIONS_STARTUP_RESTORE_LAST_SESSION }, |
142 { "settingsTitle", IDS_SETTINGS_TITLE }, | 241 { "settingsTitle", IDS_SETTINGS_TITLE }, |
| 242 { "showAdvancedSettings", IDS_SETTINGS_SHOW_ADVANCED_SETTINGS }, |
| 243 { "spellingPref", IDS_OPTIONS_SPELLING_PREF }, |
| 244 { "sslCheckRevocation", IDS_OPTIONS_SSL_CHECKREVOCATION }, |
| 245 { "sslGroupDescription", IDS_OPTIONS_SSL_GROUP_DESCRIPTION }, |
143 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, | 246 { "startupSetPages", IDS_OPTIONS2_STARTUP_SET_PAGES }, |
144 { "startupShowDefaultAndNewTab", | 247 { "startupShowDefaultAndNewTab", |
145 IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB}, | 248 IDS_OPTIONS_STARTUP_SHOW_DEFAULT_AND_NEWTAB }, |
146 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, | 249 { "startupShowLastSession", IDS_OPTIONS_STARTUP_SHOW_LAST_SESSION }, |
147 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, | 250 { "startupShowPages", IDS_OPTIONS2_STARTUP_SHOW_PAGES }, |
| 251 { "suggestPref", IDS_OPTIONS_SUGGEST_PREF }, |
148 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS }, | 252 { "syncButtonTextInProgress", IDS_SYNC_NTP_SETUP_IN_PROGRESS }, |
149 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL }, | 253 { "syncButtonTextStop", IDS_SYNC_STOP_SYNCING_BUTTON_LABEL }, |
150 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, | 254 { "themesGallery", IDS_THEMES_GALLERY_BUTTON }, |
151 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, | 255 { "themesGalleryURL", IDS_THEMES_GALLERY_URL }, |
| 256 { "tabsToLinksPref", IDS_OPTIONS_TABS_TO_LINKS_PREF }, |
152 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, | 257 { "toolbarGroupName", IDS_OPTIONS2_TOOLBAR_GROUP_NAME }, |
153 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, | 258 { "toolbarShowBookmarksBar", IDS_OPTIONS_TOOLBAR_SHOW_BOOKMARKS_BAR }, |
154 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, | 259 { "toolbarShowHomeButton", IDS_OPTIONS_TOOLBAR_SHOW_HOME_BUTTON }, |
| 260 { "translateEnableTranslate", |
| 261 IDS_OPTIONS_TRANSLATE_ENABLE_TRANSLATE }, |
155 #if defined(TOOLKIT_GTK) | 262 #if defined(TOOLKIT_GTK) |
156 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, | 263 { "showWindowDecorations", IDS_SHOW_WINDOW_DECORATIONS }, |
157 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, | 264 { "themesGTKButton", IDS_THEMES_GTK_BUTTON }, |
158 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, | 265 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, |
159 #else | 266 #else |
160 { "themes", IDS_THEMES_GROUP_NAME }, | 267 { "themes", IDS_THEMES_GROUP_NAME }, |
161 { "themesReset", IDS_THEMES_RESET_BUTTON }, | 268 { "themesReset", IDS_THEMES_RESET_BUTTON }, |
162 #endif | 269 #endif |
163 #if defined(OS_CHROMEOS) | 270 #if defined(OS_CHROMEOS) |
| 271 { "accessibilityHighContrast", |
| 272 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, |
| 273 { "accessibilityScreenMagnifier", |
| 274 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_DESCRIPTION }, |
| 275 { "accessibilitySpokenFeedback", |
| 276 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION }, |
| 277 { "accessibilityTitle", |
| 278 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY }, |
| 279 { "accessibilityVirtualKeyboard", |
| 280 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_VIRTUAL_KEYBOARD_DESCRIPTION }, |
164 { "brightnessDecrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE }, | 281 { "brightnessDecrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DECREASE }, |
165 { "brightnessIncrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE }, | 282 { "brightnessIncrease", IDS_OPTIONS_SETTINGS_BRIGHTNESS_INCREASE }, |
166 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, | 283 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, |
| 284 { "datetimeTitle", IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME }, |
167 { "deviceGroupBrightness", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION }, | 285 { "deviceGroupBrightness", IDS_OPTIONS_SETTINGS_BRIGHTNESS_DESCRIPTION }, |
168 { "deviceGroupKeyboard", IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SECTION }, | 286 { "deviceGroupKeyboard", IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SECTION }, |
169 { "deviceGroupPointer", IDS_OPTIONS_DEVICE_GROUP_POINTER_SECTION }, | 287 { "deviceGroupPointer", IDS_OPTIONS_DEVICE_GROUP_POINTER_SECTION }, |
170 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, | 288 { "enableScreenlock", IDS_OPTIONS_ENABLE_SCREENLOCKER_CHECKBOX }, |
171 { "internetOptionsButtonTitle", IDS_OPTIONS_INTERNET_OPTIONS_BUTTON_TITLE }, | 289 { "internetOptionsButtonTitle", IDS_OPTIONS_INTERNET_OPTIONS_BUTTON_TITLE }, |
172 { "keyboardSettingsButtonTitle", | 290 { "keyboardSettingsButtonTitle", |
173 IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SETTINGS_BUTTON_TITLE }, | 291 IDS_OPTIONS_DEVICE_GROUP_KEYBOARD_SETTINGS_BUTTON_TITLE }, |
174 { "manageAccountsButtonTitle", IDS_OPTIONS_ACCOUNTS_BUTTON_TITLE }, | 292 { "manageAccountsButtonTitle", IDS_OPTIONS_ACCOUNTS_BUTTON_TITLE }, |
175 { "pointerSensitivityLess", | 293 { "pointerSensitivityLess", |
176 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION }, | 294 IDS_OPTIONS_SETTINGS_SENSITIVITY_LESS_DESCRIPTION }, |
177 { "pointerSensitivityMore", | 295 { "pointerSensitivityMore", |
178 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION }, | 296 IDS_OPTIONS_SETTINGS_SENSITIVITY_MORE_DESCRIPTION }, |
179 { "pointerSettingsButtonTitle", | 297 { "pointerSettingsButtonTitle", |
180 IDS_OPTIONS_DEVICE_GROUP_POINTER_SETTINGS_BUTTON_TITLE }, | 298 IDS_OPTIONS_DEVICE_GROUP_POINTER_SETTINGS_BUTTON_TITLE }, |
181 { "sectionTitleDevice", IDS_OPTIONS_DEVICE_GROUP_NAME }, | 299 { "sectionTitleDevice", IDS_OPTIONS_DEVICE_GROUP_NAME }, |
182 { "sectionTitleInternet", IDS_OPTIONS_INTERNET_OPTIONS_GROUP_LABEL }, | 300 { "sectionTitleInternet", IDS_OPTIONS_INTERNET_OPTIONS_GROUP_LABEL }, |
| 301 { "timezone", IDS_OPTIONS_SETTINGS_TIMEZONE_DESCRIPTION }, |
| 302 { "use24HourClock", IDS_OPTIONS_SETTINGS_USE_24HOUR_CLOCK_DESCRIPTION }, |
| 303 #else |
| 304 { "cloudPrintConnectorEnabledManageButton", |
| 305 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_MANAGE_BUTTON}, |
| 306 { "cloudPrintConnectorEnablingButton", |
| 307 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLING_BUTTON }, |
| 308 { "proxiesConfigureButton", IDS_OPTIONS_PROXIES_CONFIGURE_BUTTON }, |
| 309 #endif |
| 310 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 311 { "advancedSectionTitleBackground", |
| 312 IDS_OPTIONS_ADVANCED_SECTION_TITLE_BACKGROUND }, |
| 313 { "backgroundModeCheckbox", IDS_OPTIONS_BACKGROUND_ENABLE_BACKGROUND_MODE }, |
183 #endif | 314 #endif |
184 }; | 315 }; |
185 | 316 |
186 RegisterStrings(localized_strings, resources, arraysize(resources)); | 317 RegisterStrings(localized_strings, resources, arraysize(resources)); |
| 318 RegisterCloudPrintStrings(localized_strings); |
187 RegisterTitle(localized_strings, "homePageOverlay", | 319 RegisterTitle(localized_strings, "homePageOverlay", |
188 IDS_OPTIONS2_HOMEPAGE_TITLE); | 320 IDS_OPTIONS2_HOMEPAGE_TITLE); |
189 | 321 |
190 localized_strings->SetString( | 322 localized_strings->SetString( |
191 "syncOverview", | 323 "syncOverview", |
192 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, | 324 l10n_util::GetStringFUTF16(IDS_SYNC_OVERVIEW, |
193 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 325 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
194 localized_strings->SetString( | 326 localized_strings->SetString( |
195 "syncButtonTextStart", | 327 "syncButtonTextStart", |
196 l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, | 328 l10n_util::GetStringFUTF16(IDS_SYNC_START_SYNC_BUTTON_LABEL, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 | 361 |
230 #if defined(OS_CHROMEOS) | 362 #if defined(OS_CHROMEOS) |
231 if (chromeos::UserManager::Get()->user_is_logged_in()) { | 363 if (chromeos::UserManager::Get()->user_is_logged_in()) { |
232 localized_strings->SetString("username", | 364 localized_strings->SetString("username", |
233 chromeos::UserManager::Get()->logged_in_user().email()); | 365 chromeos::UserManager::Get()->logged_in_user().email()); |
234 } | 366 } |
235 #endif | 367 #endif |
236 | 368 |
237 // Pass along sync status early so it will be available during page init. | 369 // Pass along sync status early so it will be available during page init. |
238 localized_strings->Set("syncData", GetSyncStateDictionary()); | 370 localized_strings->Set("syncData", GetSyncStateDictionary()); |
| 371 |
| 372 localized_strings->SetString("privacyLearnMoreURL", |
| 373 chrome::kPrivacyLearnMoreURL); |
| 374 |
| 375 localized_strings->SetString( |
| 376 "languageSectionLabel", |
| 377 l10n_util::GetStringFUTF16( |
| 378 IDS_OPTIONS_ADVANCED_LANGUAGE_LABEL, |
| 379 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_NAME))); |
| 380 |
| 381 #if defined(OS_CHROMEOS) |
| 382 localized_strings->SetString("cloudPrintLearnMoreURL", |
| 383 chrome::kCloudPrintLearnMoreURL); |
| 384 |
| 385 // TODO(pastarmovj): replace this with a call to the CrosSettings list |
| 386 // handling functionality to come. |
| 387 localized_strings->Set("timezoneList", |
| 388 static_cast<chromeos::options2::SystemSettingsProvider*>( |
| 389 chromeos::CrosSettings::Get()->GetProvider( |
| 390 chromeos::kSystemTimezone))->GetTimezoneList()); |
| 391 #endif |
| 392 #if defined(OS_MACOSX) |
| 393 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 394 if (profile_manager->GetNumberOfProfiles() > 1) { |
| 395 localized_strings->SetString("macPasswordsWarning", |
| 396 l10n_util::GetStringUTF16(IDS_OPTIONS_PASSWORDS_MAC_WARNING)); |
| 397 } |
| 398 #endif |
| 399 } |
| 400 |
| 401 void BrowserOptionsHandler::RegisterCloudPrintStrings( |
| 402 DictionaryValue* localized_strings) { |
| 403 #if defined(OS_CHROMEOS) |
| 404 localized_strings->SetString("cloudPrintChromeosOptionLabel", |
| 405 l10n_util::GetStringFUTF16( |
| 406 IDS_CLOUD_PRINT_CHROMEOS_OPTION_LABEL, |
| 407 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 408 localized_strings->SetString("cloudPrintChromeosOptionButton", |
| 409 l10n_util::GetStringFUTF16( |
| 410 IDS_CLOUD_PRINT_CHROMEOS_OPTION_BUTTON, |
| 411 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 412 #else |
| 413 localized_strings->SetString("cloudPrintConnectorDisabledLabel", |
| 414 l10n_util::GetStringFUTF16( |
| 415 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, |
| 416 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 417 localized_strings->SetString("cloudPrintConnectorDisabledButton", |
| 418 l10n_util::GetStringFUTF16( |
| 419 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_BUTTON, |
| 420 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 421 localized_strings->SetString("cloudPrintConnectorEnabledButton", |
| 422 l10n_util::GetStringFUTF16( |
| 423 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_BUTTON, |
| 424 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT))); |
| 425 #endif |
239 } | 426 } |
240 | 427 |
241 void BrowserOptionsHandler::RegisterMessages() { | 428 void BrowserOptionsHandler::RegisterMessages() { |
242 web_ui()->RegisterMessageCallback( | 429 web_ui()->RegisterMessageCallback( |
243 "becomeDefaultBrowser", | 430 "becomeDefaultBrowser", |
244 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, | 431 base::Bind(&BrowserOptionsHandler::BecomeDefaultBrowser, |
245 base::Unretained(this))); | 432 base::Unretained(this))); |
246 web_ui()->RegisterMessageCallback( | 433 web_ui()->RegisterMessageCallback( |
247 "setDefaultSearchEngine", | 434 "setDefaultSearchEngine", |
248 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, | 435 base::Bind(&BrowserOptionsHandler::SetDefaultSearchEngine, |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 #if defined(OS_CHROMEOS) | 467 #if defined(OS_CHROMEOS) |
281 web_ui()->RegisterMessageCallback( | 468 web_ui()->RegisterMessageCallback( |
282 "decreaseScreenBrightness", | 469 "decreaseScreenBrightness", |
283 base::Bind(&BrowserOptionsHandler::DecreaseScreenBrightnessCallback, | 470 base::Bind(&BrowserOptionsHandler::DecreaseScreenBrightnessCallback, |
284 base::Unretained(this))); | 471 base::Unretained(this))); |
285 web_ui()->RegisterMessageCallback( | 472 web_ui()->RegisterMessageCallback( |
286 "increaseScreenBrightness", | 473 "increaseScreenBrightness", |
287 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, | 474 base::Bind(&BrowserOptionsHandler::IncreaseScreenBrightnessCallback, |
288 base::Unretained(this))); | 475 base::Unretained(this))); |
289 #endif | 476 #endif |
| 477 web_ui()->RegisterMessageCallback( |
| 478 "selectDownloadLocation", |
| 479 base::Bind(&BrowserOptionsHandler::HandleSelectDownloadLocation, |
| 480 base::Unretained(this))); |
| 481 web_ui()->RegisterMessageCallback( |
| 482 "autoOpenFileTypesAction", |
| 483 base::Bind(&BrowserOptionsHandler::HandleAutoOpenButton, |
| 484 base::Unretained(this))); |
| 485 web_ui()->RegisterMessageCallback( |
| 486 "defaultFontSizeAction", |
| 487 base::Bind(&BrowserOptionsHandler::HandleDefaultFontSize, |
| 488 base::Unretained(this))); |
| 489 web_ui()->RegisterMessageCallback( |
| 490 "defaultZoomFactorAction", |
| 491 base::Bind(&BrowserOptionsHandler::HandleDefaultZoomFactor, |
| 492 base::Unretained(this))); |
| 493 #if !defined(OS_CHROMEOS) |
| 494 web_ui()->RegisterMessageCallback( |
| 495 "metricsReportingCheckboxAction", |
| 496 base::Bind(&BrowserOptionsHandler::HandleMetricsReportingCheckbox, |
| 497 base::Unretained(this))); |
| 498 #endif |
| 499 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 500 web_ui()->RegisterMessageCallback( |
| 501 "showManageSSLCertificates", |
| 502 base::Bind(&BrowserOptionsHandler::ShowManageSSLCertificates, |
| 503 base::Unretained(this))); |
| 504 #endif |
| 505 web_ui()->RegisterMessageCallback( |
| 506 "showCloudPrintManagePage", |
| 507 base::Bind(&BrowserOptionsHandler::ShowCloudPrintManagePage, |
| 508 base::Unretained(this))); |
| 509 #if !defined(OS_CHROMEOS) |
| 510 if (cloud_print_connector_ui_enabled_) { |
| 511 web_ui()->RegisterMessageCallback( |
| 512 "showCloudPrintSetupDialog", |
| 513 base::Bind(&BrowserOptionsHandler::ShowCloudPrintSetupDialog, |
| 514 base::Unretained(this))); |
| 515 web_ui()->RegisterMessageCallback( |
| 516 "disableCloudPrintConnector", |
| 517 base::Bind(&BrowserOptionsHandler::HandleDisableCloudPrintConnector, |
| 518 base::Unretained(this))); |
| 519 } |
| 520 web_ui()->RegisterMessageCallback( |
| 521 "showNetworkProxySettings", |
| 522 base::Bind(&BrowserOptionsHandler::ShowNetworkProxySettings, |
| 523 base::Unretained(this))); |
| 524 #endif |
| 525 web_ui()->RegisterMessageCallback( |
| 526 "checkRevocationCheckboxAction", |
| 527 base::Bind(&BrowserOptionsHandler::HandleCheckRevocationCheckbox, |
| 528 base::Unretained(this))); |
| 529 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 530 web_ui()->RegisterMessageCallback( |
| 531 "backgroundModeAction", |
| 532 base::Bind(&BrowserOptionsHandler::HandleBackgroundModeCheckbox, |
| 533 base::Unretained(this))); |
| 534 #endif |
| 535 #if defined(OS_CHROMEOS) |
| 536 web_ui()->RegisterMessageCallback( |
| 537 "spokenFeedbackChange", |
| 538 base::Bind(&BrowserOptionsHandler::SpokenFeedbackChangeCallback, |
| 539 base::Unretained(this))); |
| 540 web_ui()->RegisterMessageCallback( |
| 541 "highContrastChange", |
| 542 base::Bind(&BrowserOptionsHandler::HighContrastChangeCallback, |
| 543 base::Unretained(this))); |
| 544 web_ui()->RegisterMessageCallback( |
| 545 "screenMagnifierChange", |
| 546 base::Bind(&BrowserOptionsHandler::ScreenMagnifierChangeCallback, |
| 547 base::Unretained(this))); |
| 548 web_ui()->RegisterMessageCallback( |
| 549 "virtualKeyboardChange", |
| 550 base::Bind(&BrowserOptionsHandler::VirtualKeyboardChangeCallback, |
| 551 base::Unretained(this))); |
| 552 #endif |
290 } | 553 } |
291 | 554 |
292 void BrowserOptionsHandler::OnStateChanged() { | 555 void BrowserOptionsHandler::OnStateChanged() { |
293 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary()); | 556 scoped_ptr<DictionaryValue> value(GetSyncStateDictionary()); |
294 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value); | 557 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", *value); |
295 | 558 |
296 SendProfilesInfo(); | 559 SendProfilesInfo(); |
297 } | 560 } |
298 | 561 |
299 void BrowserOptionsHandler::Initialize() { | 562 void BrowserOptionsHandler::Initialize() { |
300 Profile* profile = Profile::FromWebUI(web_ui()); | 563 Profile* profile = Profile::FromWebUI(web_ui()); |
| 564 PrefService* prefs = profile->GetPrefs(); |
301 | 565 |
302 ProfileSyncService* sync_service(ProfileSyncServiceFactory:: | 566 ProfileSyncService* sync_service( |
303 GetInstance()->GetForProfile(Profile::FromWebUI(web_ui()))); | 567 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile)); |
304 if (sync_service) | 568 if (sync_service) |
305 sync_service->AddObserver(this); | 569 sync_service->AddObserver(this); |
306 OnStateChanged(); | 570 OnStateChanged(); |
307 | 571 |
308 // Create our favicon data source. | 572 // Create our favicon data source. |
309 profile->GetChromeURLDataManager()->AddDataSource( | 573 profile->GetChromeURLDataManager()->AddDataSource( |
310 new FaviconSource(profile, FaviconSource::FAVICON)); | 574 new FaviconSource(profile, FaviconSource::FAVICON)); |
311 | 575 |
312 homepage_.Init(prefs::kHomePage, profile->GetPrefs(), NULL); | 576 homepage_.Init(prefs::kHomePage, prefs, NULL); |
313 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, | 577 default_browser_policy_.Init(prefs::kDefaultBrowserSettingEnabled, |
314 g_browser_process->local_state(), | 578 g_browser_process->local_state(), |
315 this); | 579 this); |
316 UpdateDefaultBrowserState(); | 580 UpdateDefaultBrowserState(); |
317 | 581 |
318 pref_change_registrar_.Init(profile->GetPrefs()); | 582 pref_change_registrar_.Init(prefs); |
319 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); | 583 pref_change_registrar_.Add(prefs::kHomePageIsNewTabPage, this); |
320 pref_change_registrar_.Add(prefs::kHomePage, this); | 584 pref_change_registrar_.Add(prefs::kHomePage, this); |
321 | 585 |
322 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 586 registrar_.Add(this, chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
323 content::NotificationService::AllSources()); | 587 content::NotificationService::AllSources()); |
324 #if defined(OS_CHROMEOS) | 588 #if defined(OS_CHROMEOS) |
325 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, | 589 registrar_.Add(this, chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED, |
326 content::NotificationService::AllSources()); | 590 content::NotificationService::AllSources()); |
327 #endif | 591 #endif |
328 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, | 592 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
(...skipping 11 matching lines...) Expand all Loading... |
340 if (!command_line.HasSwitch(switches::kChromeFrame) && | 604 if (!command_line.HasSwitch(switches::kChromeFrame) && |
341 !command_line.HasSwitch(switches::kUserDataDir)) { | 605 !command_line.HasSwitch(switches::kUserDataDir)) { |
342 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, | 606 BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE, |
343 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, | 607 base::Bind(&BrowserOptionsHandler::CheckAutoLaunch, |
344 weak_ptr_factory_for_ui_.GetWeakPtr(), | 608 weak_ptr_factory_for_ui_.GetWeakPtr(), |
345 weak_ptr_factory_for_file_.GetWeakPtr(), | 609 weak_ptr_factory_for_file_.GetWeakPtr(), |
346 profile->GetPath())); | 610 profile->GetPath())); |
347 weak_ptr_factory_for_ui_.DetachFromThread(); | 611 weak_ptr_factory_for_ui_.DetachFromThread(); |
348 } | 612 } |
349 #endif | 613 #endif |
| 614 |
| 615 #if !defined(OS_CHROMEOS) |
| 616 enable_metrics_recording_.Init(prefs::kMetricsReportingEnabled, |
| 617 g_browser_process->local_state(), this); |
| 618 cloud_print_connector_email_.Init(prefs::kCloudPrintEmail, prefs, this); |
| 619 cloud_print_connector_enabled_.Init(prefs::kCloudPrintProxyEnabled, prefs, |
| 620 this); |
| 621 #endif |
| 622 |
| 623 rev_checking_enabled_.Init(prefs::kCertRevocationCheckingEnabled, |
| 624 g_browser_process->local_state(), this); |
| 625 |
| 626 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 627 background_mode_enabled_.Init(prefs::kBackgroundModeEnabled, |
| 628 g_browser_process->local_state(), this); |
| 629 #endif |
| 630 |
| 631 auto_open_files_.Init(prefs::kDownloadExtensionsToOpen, prefs, this); |
| 632 default_font_size_.Init(prefs::kWebKitGlobalDefaultFontSize, prefs, this); |
| 633 default_zoom_level_.Init(prefs::kDefaultZoomLevel, prefs, this); |
| 634 #if !defined(OS_CHROMEOS) |
| 635 proxy_prefs_.reset( |
| 636 PrefSetObserver::CreateProxyPrefSetObserver(prefs, this)); |
| 637 #endif // !defined(OS_CHROMEOS) |
| 638 |
| 639 SetupMetricsReportingCheckbox(); |
| 640 SetupMetricsReportingSettingVisibility(); |
| 641 SetupFontSizeSelector(); |
| 642 SetupPageZoomSelector(); |
| 643 SetupAutoOpenFileTypesDisabledAttribute(); |
| 644 SetupProxySettingsSection(); |
| 645 SetupSSLConfigSettings(); |
| 646 #if !defined(OS_CHROMEOS) |
| 647 if (cloud_print_connector_ui_enabled_) { |
| 648 SetupCloudPrintConnectorSection(); |
| 649 RefreshCloudPrintStatusFromService(); |
| 650 } else { |
| 651 RemoveCloudPrintConnectorSection(); |
| 652 } |
| 653 #endif |
| 654 #if defined(OS_CHROMEOS) |
| 655 SetupAccessibilityFeatures(); |
| 656 #endif |
| 657 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 658 SetupBackgroundModeSettings(); |
| 659 #endif |
350 } | 660 } |
351 | 661 |
352 void BrowserOptionsHandler::CheckAutoLaunch( | 662 void BrowserOptionsHandler::CheckAutoLaunch( |
353 base::WeakPtr<BrowserOptionsHandler> weak_this, | 663 base::WeakPtr<BrowserOptionsHandler> weak_this, |
354 const FilePath& profile_path) { | 664 const FilePath& profile_path) { |
355 #if defined(OS_WIN) | 665 #if defined(OS_WIN) |
356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 666 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
357 | 667 |
358 // Auto-launch is not supported for secondary profiles yet. | 668 // Auto-launch is not supported for secondary profiles yet. |
359 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile)) | 669 if (profile_path.BaseName().value() != ASCIIToUTF16(chrome::kInitialProfile)) |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
557 int type, | 867 int type, |
558 const content::NotificationSource& source, | 868 const content::NotificationSource& source, |
559 const content::NotificationDetails& details) { | 869 const content::NotificationDetails& details) { |
560 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { | 870 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
561 ObserveThemeChanged(); | 871 ObserveThemeChanged(); |
562 #if defined(OS_CHROMEOS) | 872 #if defined(OS_CHROMEOS) |
563 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { | 873 } else if (type == chrome::NOTIFICATION_LOGIN_USER_IMAGE_CHANGED) { |
564 UpdateAccountPicture(); | 874 UpdateAccountPicture(); |
565 #endif | 875 #endif |
566 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 876 } else if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
567 std::string* pref = content::Details<std::string>(details).ptr(); | 877 std::string* pref_name = content::Details<std::string>(details).ptr(); |
568 if (*pref == prefs::kDefaultBrowserSettingEnabled) { | 878 if (*pref_name == prefs::kDefaultBrowserSettingEnabled) { |
569 UpdateDefaultBrowserState(); | 879 UpdateDefaultBrowserState(); |
570 } else if (*pref == prefs::kHomePageIsNewTabPage || | 880 } else if (*pref_name == prefs::kHomePageIsNewTabPage || |
571 *pref == prefs::kHomePage) { | 881 *pref_name == prefs::kHomePage) { |
572 UpdateHomePageLabel(); | 882 UpdateHomePageLabel(); |
| 883 } else if (*pref_name == prefs::kDownloadExtensionsToOpen) { |
| 884 SetupAutoOpenFileTypesDisabledAttribute(); |
| 885 #if !defined(OS_CHROMEOS) |
| 886 } else if (proxy_prefs_->IsObserved(*pref_name)) { |
| 887 SetupProxySettingsSection(); |
| 888 #endif // !defined(OS_CHROMEOS) |
| 889 } else if ((*pref_name == prefs::kCloudPrintEmail) || |
| 890 (*pref_name == prefs::kCloudPrintProxyEnabled)) { |
| 891 #if !defined(OS_CHROMEOS) |
| 892 if (cloud_print_connector_ui_enabled_) |
| 893 SetupCloudPrintConnectorSection(); |
| 894 #endif |
| 895 } else if (*pref_name == prefs::kWebKitGlobalDefaultFontSize) { |
| 896 SetupFontSizeSelector(); |
| 897 } else if (*pref_name == prefs::kDefaultZoomLevel) { |
| 898 SetupPageZoomSelector(); |
| 899 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 900 } else if (*pref_name == prefs::kBackgroundModeEnabled) { |
| 901 SetupBackgroundModeSettings(); |
| 902 #endif |
573 } else { | 903 } else { |
574 NOTREACHED(); | 904 NOTREACHED(); |
575 } | 905 } |
576 } else if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { | 906 } else if (type == chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED) { |
577 if (multiprofile_) | 907 if (multiprofile_) |
578 SendProfilesInfo(); | 908 SendProfilesInfo(); |
579 } else { | 909 } else { |
580 NOTREACHED(); | 910 NOTREACHED(); |
581 } | 911 } |
582 } | 912 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
779 sync_status->SetBoolean("managed", service->IsManaged()); | 1109 sync_status->SetBoolean("managed", service->IsManaged()); |
780 sync_status->SetBoolean("hasUnrecoverableError", | 1110 sync_status->SetBoolean("hasUnrecoverableError", |
781 service->unrecoverable_error_detected()); | 1111 service->unrecoverable_error_detected()); |
782 sync_status->SetBoolean("autoLoginVisible", | 1112 sync_status->SetBoolean("autoLoginVisible", |
783 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) && | 1113 CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableAutologin) && |
784 service->AreCredentialsAvailable()); | 1114 service->AreCredentialsAvailable()); |
785 | 1115 |
786 return sync_status; | 1116 return sync_status; |
787 } | 1117 } |
788 | 1118 |
| 1119 void BrowserOptionsHandler::HandleSelectDownloadLocation( |
| 1120 const ListValue* args) { |
| 1121 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1122 select_folder_dialog_ = SelectFileDialog::Create(this); |
| 1123 select_folder_dialog_->SelectFile( |
| 1124 SelectFileDialog::SELECT_FOLDER, |
| 1125 l10n_util::GetStringUTF16(IDS_OPTIONS_DOWNLOADLOCATION_BROWSE_TITLE), |
| 1126 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), |
| 1127 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->GetWebContents(), |
| 1128 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); |
| 1129 } |
| 1130 |
| 1131 void BrowserOptionsHandler::FileSelected(const FilePath& path, int index, |
| 1132 void* params) { |
| 1133 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 1134 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1135 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 1136 } |
| 1137 |
| 1138 void BrowserOptionsHandler::OnCloudPrintSetupClosed() { |
| 1139 #if !defined(OS_CHROMEOS) |
| 1140 if (cloud_print_connector_ui_enabled_) |
| 1141 SetupCloudPrintConnectorSection(); |
| 1142 #endif |
| 1143 } |
| 1144 |
| 1145 void BrowserOptionsHandler::HandleAutoOpenButton(const ListValue* args) { |
| 1146 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
| 1147 DownloadManager* manager = |
| 1148 web_ui()->GetWebContents()->GetBrowserContext()->GetDownloadManager(); |
| 1149 if (manager) |
| 1150 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); |
| 1151 } |
| 1152 |
| 1153 void BrowserOptionsHandler::HandleMetricsReportingCheckbox( |
| 1154 const ListValue* args) { |
| 1155 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 1156 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1157 bool enabled = checked_str == "true"; |
| 1158 content::RecordAction( |
| 1159 enabled ? |
| 1160 UserMetricsAction("Options_MetricsReportingCheckbox_Enable") : |
| 1161 UserMetricsAction("Options_MetricsReportingCheckbox_Disable")); |
| 1162 bool is_enabled = OptionsUtil::ResolveMetricsReportingEnabled(enabled); |
| 1163 enable_metrics_recording_.SetValue(is_enabled); |
| 1164 SetupMetricsReportingCheckbox(); |
| 1165 #endif |
| 1166 } |
| 1167 |
| 1168 void BrowserOptionsHandler::HandleDefaultFontSize(const ListValue* args) { |
| 1169 int font_size; |
| 1170 if (ExtractIntegerValue(args, &font_size)) { |
| 1171 if (font_size > 0) { |
| 1172 default_font_size_.SetValue(font_size); |
| 1173 SetupFontSizeSelector(); |
| 1174 } |
| 1175 } |
| 1176 } |
| 1177 |
| 1178 void BrowserOptionsHandler::HandleDefaultZoomFactor(const ListValue* args) { |
| 1179 double zoom_factor; |
| 1180 if (ExtractDoubleValue(args, &zoom_factor)) { |
| 1181 default_zoom_level_.SetValue( |
| 1182 WebKit::WebView::zoomFactorToZoomLevel(zoom_factor)); |
| 1183 } |
| 1184 } |
| 1185 |
| 1186 void BrowserOptionsHandler::HandleCheckRevocationCheckbox( |
| 1187 const ListValue* args) { |
| 1188 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1189 bool enabled = checked_str == "true"; |
| 1190 content::RecordAction( |
| 1191 enabled ? |
| 1192 UserMetricsAction("Options_CheckCertRevocation_Enable") : |
| 1193 UserMetricsAction("Options_CheckCertRevocation_Disable")); |
| 1194 rev_checking_enabled_.SetValue(enabled); |
| 1195 } |
| 1196 |
| 1197 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) |
| 1198 void BrowserOptionsHandler::HandleBackgroundModeCheckbox( |
| 1199 const ListValue* args) { |
| 1200 std::string checked_str = UTF16ToUTF8(ExtractStringValue(args)); |
| 1201 bool enabled = checked_str == "true"; |
| 1202 content::RecordAction(enabled ? |
| 1203 UserMetricsAction("Options_BackgroundMode_Enable") : |
| 1204 UserMetricsAction("Options_BackgroundMode_Disable")); |
| 1205 background_mode_enabled_.SetValue(enabled); |
| 1206 } |
| 1207 |
| 1208 void BrowserOptionsHandler::SetupBackgroundModeSettings() { |
| 1209 base::FundamentalValue checked(background_mode_enabled_.GetValue()); |
| 1210 web_ui()->CallJavascriptFunction( |
| 1211 "BrowserOptions.setBackgroundModeCheckboxState", checked); |
| 1212 } |
| 1213 #endif |
| 1214 |
| 1215 #if !defined(OS_CHROMEOS) |
| 1216 void BrowserOptionsHandler::ShowNetworkProxySettings(const ListValue* args) { |
| 1217 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); |
| 1218 AdvancedOptionsUtilities::ShowNetworkProxySettings( |
| 1219 web_ui()->GetWebContents()); |
| 1220 } |
| 1221 #endif |
| 1222 |
| 1223 #if !defined(USE_NSS) && !defined(USE_OPENSSL) |
| 1224 void BrowserOptionsHandler::ShowManageSSLCertificates(const ListValue* args) { |
| 1225 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); |
| 1226 AdvancedOptionsUtilities::ShowManageSSLCertificates( |
| 1227 web_ui()->GetWebContents()); |
| 1228 } |
| 1229 #endif |
| 1230 |
| 1231 void BrowserOptionsHandler::ShowCloudPrintManagePage(const ListValue* args) { |
| 1232 content::RecordAction(UserMetricsAction("Options_ManageCloudPrinters")); |
| 1233 // Open a new tab in the current window for the management page. |
| 1234 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1235 OpenURLParams params( |
| 1236 CloudPrintURL(profile).GetCloudPrintServiceManageURL(), Referrer(), |
| 1237 NEW_FOREGROUND_TAB, content::PAGE_TRANSITION_LINK, false); |
| 1238 web_ui()->GetWebContents()->OpenURL(params); |
| 1239 } |
| 1240 |
| 1241 #if !defined(OS_CHROMEOS) |
| 1242 void BrowserOptionsHandler::ShowCloudPrintSetupDialog(const ListValue* args) { |
| 1243 content::RecordAction(UserMetricsAction("Options_EnableCloudPrintProxy")); |
| 1244 // Open the connector enable page in the current tab. |
| 1245 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1246 OpenURLParams params( |
| 1247 CloudPrintURL(profile).GetCloudPrintServiceEnableURL( |
| 1248 CloudPrintProxyServiceFactory::GetForProfile(profile)->proxy_id()), |
| 1249 Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 1250 web_ui()->GetWebContents()->OpenURL(params); |
| 1251 } |
| 1252 |
| 1253 void BrowserOptionsHandler::HandleDisableCloudPrintConnector( |
| 1254 const ListValue* args) { |
| 1255 content::RecordAction( |
| 1256 UserMetricsAction("Options_DisableCloudPrintProxy")); |
| 1257 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 1258 DisableForUser(); |
| 1259 } |
| 1260 |
| 1261 void BrowserOptionsHandler::RefreshCloudPrintStatusFromService() { |
| 1262 if (cloud_print_connector_ui_enabled_) |
| 1263 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
| 1264 RefreshStatusFromService(); |
| 1265 } |
| 1266 |
| 1267 void BrowserOptionsHandler::SetupCloudPrintConnectorSection() { |
| 1268 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1269 if (!CloudPrintProxyServiceFactory::GetForProfile(profile)) { |
| 1270 cloud_print_connector_ui_enabled_ = false; |
| 1271 RemoveCloudPrintConnectorSection(); |
| 1272 return; |
| 1273 } |
| 1274 |
| 1275 bool cloud_print_connector_allowed = |
| 1276 !cloud_print_connector_enabled_.IsManaged() || |
| 1277 cloud_print_connector_enabled_.GetValue(); |
| 1278 base::FundamentalValue allowed(cloud_print_connector_allowed); |
| 1279 |
| 1280 std::string email; |
| 1281 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && |
| 1282 cloud_print_connector_allowed) { |
| 1283 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); |
| 1284 } |
| 1285 base::FundamentalValue disabled(email.empty()); |
| 1286 |
| 1287 string16 label_str; |
| 1288 if (email.empty()) { |
| 1289 label_str = l10n_util::GetStringFUTF16( |
| 1290 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, |
| 1291 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); |
| 1292 } else { |
| 1293 label_str = l10n_util::GetStringFUTF16( |
| 1294 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, |
| 1295 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), |
| 1296 UTF8ToUTF16(email)); |
| 1297 } |
| 1298 StringValue label(label_str); |
| 1299 |
| 1300 web_ui()->CallJavascriptFunction( |
| 1301 "BrowserOptions.setupCloudPrintConnectorSection", disabled, label, |
| 1302 allowed); |
| 1303 } |
| 1304 |
| 1305 void BrowserOptionsHandler::RemoveCloudPrintConnectorSection() { |
| 1306 web_ui()->CallJavascriptFunction( |
| 1307 "BrowserOptions.removeCloudPrintConnectorSection"); |
| 1308 } |
| 1309 #endif |
| 1310 |
| 1311 #if defined(OS_CHROMEOS) |
| 1312 void BrowserOptionsHandler::SpokenFeedbackChangeCallback( |
| 1313 const ListValue* args) { |
| 1314 bool enabled = false; |
| 1315 args->GetBoolean(0, &enabled); |
| 1316 |
| 1317 chromeos::accessibility::EnableSpokenFeedback(enabled, NULL); |
| 1318 } |
| 1319 |
| 1320 void BrowserOptionsHandler::HighContrastChangeCallback(const ListValue* args) { |
| 1321 bool enabled = false; |
| 1322 args->GetBoolean(0, &enabled); |
| 1323 |
| 1324 chromeos::accessibility::EnableHighContrast(enabled); |
| 1325 } |
| 1326 |
| 1327 void BrowserOptionsHandler::ScreenMagnifierChangeCallback( |
| 1328 const ListValue* args) { |
| 1329 bool enabled = false; |
| 1330 args->GetBoolean(0, &enabled); |
| 1331 |
| 1332 chromeos::accessibility::EnableScreenMagnifier(enabled); |
| 1333 } |
| 1334 |
| 1335 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( |
| 1336 const ListValue* args) { |
| 1337 bool enabled = false; |
| 1338 args->GetBoolean(0, &enabled); |
| 1339 |
| 1340 chromeos::accessibility::EnableVirtualKeyboard(enabled); |
| 1341 } |
| 1342 |
| 1343 void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
| 1344 PrefService* pref_service = g_browser_process->local_state(); |
| 1345 base::FundamentalValue spoken_feedback_enabled( |
| 1346 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)); |
| 1347 web_ui()->CallJavascriptFunction( |
| 1348 "BrowserOptions.setSpokenFeedbackCheckboxState", |
| 1349 spoken_feedback_enabled); |
| 1350 base::FundamentalValue high_contrast_enabled( |
| 1351 pref_service->GetBoolean(prefs::kHighContrastEnabled)); |
| 1352 web_ui()->CallJavascriptFunction( |
| 1353 "BrowserOptions.setHighContrastCheckboxState", |
| 1354 high_contrast_enabled); |
| 1355 base::FundamentalValue screen_magnifier_enabled( |
| 1356 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)); |
| 1357 web_ui()->CallJavascriptFunction( |
| 1358 "BrowserOptions.setScreenMagnifierCheckboxState", |
| 1359 screen_magnifier_enabled); |
| 1360 base::FundamentalValue virtual_keyboard_enabled( |
| 1361 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)); |
| 1362 web_ui()->CallJavascriptFunction( |
| 1363 "BrowserOptions.setVirtualKeyboardCheckboxState", |
| 1364 virtual_keyboard_enabled); |
| 1365 } |
| 1366 #endif |
| 1367 |
| 1368 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { |
| 1369 #if defined(GOOGLE_CHROME_BUILD) && !defined(OS_CHROMEOS) |
| 1370 base::FundamentalValue checked(enable_metrics_recording_.GetValue()); |
| 1371 base::FundamentalValue disabled(enable_metrics_recording_.IsManaged()); |
| 1372 web_ui()->CallJavascriptFunction( |
| 1373 "BrowserOptions.setMetricsReportingCheckboxState", checked, disabled); |
| 1374 #endif |
| 1375 } |
| 1376 |
| 1377 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 1378 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| 1379 // Don't show the reporting setting if we are in the guest mode. |
| 1380 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kGuestSession)) { |
| 1381 base::FundamentalValue visible(false); |
| 1382 web_ui()->CallJavascriptFunction( |
| 1383 "BrowserOptions.setMetricsReportingSettingVisibility", visible); |
| 1384 } |
| 1385 #endif |
| 1386 } |
| 1387 |
| 1388 void BrowserOptionsHandler::SetupFontSizeSelector() { |
| 1389 // We're only interested in integer values, so convert to int. |
| 1390 base::FundamentalValue font_size(default_font_size_.GetValue()); |
| 1391 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", font_size); |
| 1392 } |
| 1393 |
| 1394 void BrowserOptionsHandler::SetupPageZoomSelector() { |
| 1395 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1396 double default_zoom_level = pref_service->GetDouble(prefs::kDefaultZoomLevel); |
| 1397 double default_zoom_factor = |
| 1398 WebKit::WebView::zoomLevelToZoomFactor(default_zoom_level); |
| 1399 |
| 1400 // Generate a vector of zoom factors from an array of known presets along with |
| 1401 // the default factor added if necessary. |
| 1402 std::vector<double> zoom_factors = |
| 1403 chrome_page_zoom::PresetZoomFactors(default_zoom_factor); |
| 1404 |
| 1405 // Iterate through the zoom factors and and build the contents of the |
| 1406 // selector that will be sent to the javascript handler. |
| 1407 // Each item in the list has the following parameters: |
| 1408 // 1. Title (string). |
| 1409 // 2. Value (double). |
| 1410 // 3. Is selected? (bool). |
| 1411 ListValue zoom_factors_value; |
| 1412 for (std::vector<double>::const_iterator i = zoom_factors.begin(); |
| 1413 i != zoom_factors.end(); ++i) { |
| 1414 ListValue* option = new ListValue(); |
| 1415 double factor = *i; |
| 1416 int percent = static_cast<int>(factor * 100 + 0.5); |
| 1417 option->Append(Value::CreateStringValue( |
| 1418 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); |
| 1419 option->Append(Value::CreateDoubleValue(factor)); |
| 1420 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); |
| 1421 option->Append(Value::CreateBooleanValue(selected)); |
| 1422 zoom_factors_value.Append(option); |
| 1423 } |
| 1424 |
| 1425 web_ui()->CallJavascriptFunction( |
| 1426 "BrowserOptions.setupPageZoomSelector", zoom_factors_value); |
| 1427 } |
| 1428 |
| 1429 void BrowserOptionsHandler::SetupAutoOpenFileTypesDisabledAttribute() { |
| 1430 // Set the enabled state for the AutoOpenFileTypesResetToDefault button. |
| 1431 // We enable the button if the user has any auto-open file types registered. |
| 1432 DownloadManager* manager = |
| 1433 web_ui()->GetWebContents()->GetBrowserContext()->GetDownloadManager(); |
| 1434 bool disabled = !(manager && |
| 1435 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed()); |
| 1436 base::FundamentalValue value(disabled); |
| 1437 web_ui()->CallJavascriptFunction( |
| 1438 "BrowserOptions.setAutoOpenFileTypesDisabledAttribute", value); |
| 1439 } |
| 1440 |
| 1441 void BrowserOptionsHandler::SetupProxySettingsSection() { |
| 1442 #if !defined(OS_CHROMEOS) |
| 1443 // Disable the button if proxy settings are managed by a sysadmin or |
| 1444 // overridden by an extension. |
| 1445 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1446 const PrefService::Preference* proxy_config = |
| 1447 pref_service->FindPreference(prefs::kProxy); |
| 1448 bool is_extension_controlled = (proxy_config && |
| 1449 proxy_config->IsExtensionControlled()); |
| 1450 |
| 1451 base::FundamentalValue disabled(proxy_prefs_->IsManaged() || |
| 1452 is_extension_controlled); |
| 1453 |
| 1454 // Get the appropriate info string to describe the button. |
| 1455 string16 label_str; |
| 1456 if (is_extension_controlled) { |
| 1457 label_str = l10n_util::GetStringUTF16(IDS_OPTIONS_EXTENSION_PROXIES_LABEL); |
| 1458 } else { |
| 1459 label_str = l10n_util::GetStringFUTF16(IDS_OPTIONS_SYSTEM_PROXIES_LABEL, |
| 1460 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 1461 } |
| 1462 StringValue label(label_str); |
| 1463 |
| 1464 web_ui()->CallJavascriptFunction( |
| 1465 "BrowserOptions.setupProxySettingsSection", disabled, label); |
| 1466 #endif // !defined(OS_CHROMEOS) |
| 1467 } |
| 1468 |
| 1469 void BrowserOptionsHandler::SetupSSLConfigSettings() { |
| 1470 base::FundamentalValue checked(rev_checking_enabled_.GetValue()); |
| 1471 base::FundamentalValue disabled(rev_checking_enabled_.IsManaged()); |
| 1472 web_ui()->CallJavascriptFunction( |
| 1473 "BrowserOptions.setCheckRevocationCheckboxState", checked, disabled); |
| 1474 } |
| 1475 |
789 } // namespace options2 | 1476 } // namespace options2 |
OLD | NEW |