| 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/options/browser_options_handler.h" | 5 #include "chrome/browser/ui/webui/options/browser_options_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 | 106 |
| 107 using content::BrowserContext; | 107 using content::BrowserContext; |
| 108 using content::BrowserThread; | 108 using content::BrowserThread; |
| 109 using content::DownloadManager; | 109 using content::DownloadManager; |
| 110 using content::OpenURLParams; | 110 using content::OpenURLParams; |
| 111 using content::Referrer; | 111 using content::Referrer; |
| 112 using content::UserMetricsAction; | 112 using content::UserMetricsAction; |
| 113 | 113 |
| 114 namespace options { | 114 namespace options { |
| 115 | 115 |
| 116 namespace { |
| 117 const char kScreenMagnifierOff[] = "off"; |
| 118 const char kScreenMagnifierFull[] = "full"; |
| 119 const char kScreenMagnifierPartial[] = "partial"; |
| 120 } |
| 121 |
| 116 BrowserOptionsHandler::BrowserOptionsHandler() | 122 BrowserOptionsHandler::BrowserOptionsHandler() |
| 117 : template_url_service_(NULL), | 123 : template_url_service_(NULL), |
| 118 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), | 124 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_file_(this)), |
| 119 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { | 125 ALLOW_THIS_IN_INITIALIZER_LIST(weak_ptr_factory_for_ui_(this)) { |
| 120 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); | 126 multiprofile_ = ProfileManager::IsMultipleProfilesEnabled(); |
| 121 #if !defined(OS_MACOSX) | 127 #if !defined(OS_MACOSX) |
| 122 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); | 128 default_browser_worker_ = new ShellIntegration::DefaultBrowserWorker(this); |
| 123 #endif | 129 #endif |
| 124 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) | 130 #if(!defined(GOOGLE_CHROME_BUILD) && defined(OS_WIN)) |
| 125 // On Windows, we need the PDF plugin which is only guaranteed to exist on | 131 // On Windows, we need the PDF plugin which is only guaranteed to exist on |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, | 282 { "themesSetClassic", IDS_THEMES_SET_CLASSIC }, |
| 277 #else | 283 #else |
| 278 { "themes", IDS_THEMES_GROUP_NAME }, | 284 { "themes", IDS_THEMES_GROUP_NAME }, |
| 279 { "themesReset", IDS_THEMES_RESET_BUTTON }, | 285 { "themesReset", IDS_THEMES_RESET_BUTTON }, |
| 280 #endif | 286 #endif |
| 281 #if defined(OS_CHROMEOS) | 287 #if defined(OS_CHROMEOS) |
| 282 { "accessibilityHighContrast", | 288 { "accessibilityHighContrast", |
| 283 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, | 289 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_HIGH_CONTRAST_DESCRIPTION }, |
| 284 { "accessibilityScreenMagnifier", | 290 { "accessibilityScreenMagnifier", |
| 285 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_DESCRIPTION }, | 291 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_DESCRIPTION }, |
| 292 { "accessibilityScreenMagnifierOff", |
| 293 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_OFF }, |
| 294 { "accessibilityScreenMagnifierFull", |
| 295 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_FULL }, |
| 296 { "accessibilityScreenMagnifierPartial", |
| 297 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_SCREEN_MAGNIFIER_PARTIAL }, |
| 286 { "accessibilitySpokenFeedback", | 298 { "accessibilitySpokenFeedback", |
| 287 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION }, | 299 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_DESCRIPTION }, |
| 288 { "accessibilityTitle", | 300 { "accessibilityTitle", |
| 289 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY }, | 301 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY }, |
| 290 { "accessibilityVirtualKeyboard", | 302 { "accessibilityVirtualKeyboard", |
| 291 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_VIRTUAL_KEYBOARD_DESCRIPTION }, | 303 IDS_OPTIONS_SETTINGS_ACCESSIBILITY_VIRTUAL_KEYBOARD_DESCRIPTION }, |
| 292 { "factoryResetTitle", IDS_OPTIONS_FACTORY_RESET }, | 304 { "factoryResetTitle", IDS_OPTIONS_FACTORY_RESET }, |
| 293 { "factoryResetRestart", IDS_OPTIONS_FACTORY_RESET_BUTTON }, | 305 { "factoryResetRestart", IDS_OPTIONS_FACTORY_RESET_BUTTON }, |
| 294 { "factoryResetDataRestart", IDS_RELAUNCH_BUTTON }, | 306 { "factoryResetDataRestart", IDS_RELAUNCH_BUTTON }, |
| 295 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, | 307 { "changePicture", IDS_OPTIONS_CHANGE_PICTURE_CAPTION }, |
| (...skipping 950 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 | 1258 |
| 1247 void BrowserOptionsHandler::HighContrastChangeCallback(const ListValue* args) { | 1259 void BrowserOptionsHandler::HighContrastChangeCallback(const ListValue* args) { |
| 1248 bool enabled = false; | 1260 bool enabled = false; |
| 1249 args->GetBoolean(0, &enabled); | 1261 args->GetBoolean(0, &enabled); |
| 1250 | 1262 |
| 1251 chromeos::accessibility::EnableHighContrast(enabled); | 1263 chromeos::accessibility::EnableHighContrast(enabled); |
| 1252 } | 1264 } |
| 1253 | 1265 |
| 1254 void BrowserOptionsHandler::ScreenMagnifierChangeCallback( | 1266 void BrowserOptionsHandler::ScreenMagnifierChangeCallback( |
| 1255 const ListValue* args) { | 1267 const ListValue* args) { |
| 1256 bool enabled = false; | 1268 std::string type_name; |
| 1257 args->GetBoolean(0, &enabled); | 1269 args->GetString(0, &type_name); |
| 1258 | 1270 |
| 1259 chromeos::accessibility::EnableScreenMagnifier(enabled); | 1271 chromeos::accessibility::ScreenMagnifierType type = |
| 1272 chromeos::accessibility::MagnifierNone; |
| 1273 |
| 1274 if (type_name == kScreenMagnifierFull) |
| 1275 type = chromeos::accessibility::MagnifierFull; |
| 1276 else if (type_name == kScreenMagnifierPartial) |
| 1277 type = chromeos::accessibility::MagnifierPartial; |
| 1278 |
| 1279 chromeos::accessibility::SetScreenMagnifier(type); |
| 1260 } | 1280 } |
| 1261 | 1281 |
| 1262 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( | 1282 void BrowserOptionsHandler::VirtualKeyboardChangeCallback( |
| 1263 const ListValue* args) { | 1283 const ListValue* args) { |
| 1264 bool enabled = false; | 1284 bool enabled = false; |
| 1265 args->GetBoolean(0, &enabled); | 1285 args->GetBoolean(0, &enabled); |
| 1266 | 1286 |
| 1267 chromeos::accessibility::EnableVirtualKeyboard(enabled); | 1287 chromeos::accessibility::EnableVirtualKeyboard(enabled); |
| 1268 } | 1288 } |
| 1269 | 1289 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1289 base::FundamentalValue spoken_feedback_enabled( | 1309 base::FundamentalValue spoken_feedback_enabled( |
| 1290 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)); | 1310 pref_service->GetBoolean(prefs::kSpokenFeedbackEnabled)); |
| 1291 web_ui()->CallJavascriptFunction( | 1311 web_ui()->CallJavascriptFunction( |
| 1292 "BrowserOptions.setSpokenFeedbackCheckboxState", | 1312 "BrowserOptions.setSpokenFeedbackCheckboxState", |
| 1293 spoken_feedback_enabled); | 1313 spoken_feedback_enabled); |
| 1294 base::FundamentalValue high_contrast_enabled( | 1314 base::FundamentalValue high_contrast_enabled( |
| 1295 pref_service->GetBoolean(prefs::kHighContrastEnabled)); | 1315 pref_service->GetBoolean(prefs::kHighContrastEnabled)); |
| 1296 web_ui()->CallJavascriptFunction( | 1316 web_ui()->CallJavascriptFunction( |
| 1297 "BrowserOptions.setHighContrastCheckboxState", | 1317 "BrowserOptions.setHighContrastCheckboxState", |
| 1298 high_contrast_enabled); | 1318 high_contrast_enabled); |
| 1299 base::FundamentalValue screen_magnifier_enabled( | 1319 |
| 1300 pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)); | 1320 std::string type(kScreenMagnifierOff); |
| 1321 if (pref_service->GetBoolean(prefs::kScreenMagnifierEnabled)) |
| 1322 type = kScreenMagnifierFull; |
| 1323 else if (pref_service->GetBoolean(prefs::kPartialScreenMagnifierEnabled)) |
| 1324 type = kScreenMagnifierPartial; |
| 1325 |
| 1326 base::StringValue magnifier_type(type); |
| 1301 web_ui()->CallJavascriptFunction( | 1327 web_ui()->CallJavascriptFunction( |
| 1302 "BrowserOptions.setScreenMagnifierCheckboxState", | 1328 "BrowserOptions.setScreenMagnifierTypeState", |
| 1303 screen_magnifier_enabled); | 1329 magnifier_type); |
| 1330 |
| 1304 base::FundamentalValue virtual_keyboard_enabled( | 1331 base::FundamentalValue virtual_keyboard_enabled( |
| 1305 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)); | 1332 pref_service->GetBoolean(prefs::kVirtualKeyboardEnabled)); |
| 1306 web_ui()->CallJavascriptFunction( | 1333 web_ui()->CallJavascriptFunction( |
| 1307 "BrowserOptions.setVirtualKeyboardCheckboxState", | 1334 "BrowserOptions.setVirtualKeyboardCheckboxState", |
| 1308 virtual_keyboard_enabled); | 1335 virtual_keyboard_enabled); |
| 1309 } | 1336 } |
| 1310 #endif | 1337 #endif |
| 1311 | 1338 |
| 1312 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { | 1339 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 1313 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) | 1340 #if defined(GOOGLE_CHROME_BUILD) && defined(OS_CHROMEOS) |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1403 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); | 1430 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME)); |
| 1404 } | 1431 } |
| 1405 StringValue label(label_str); | 1432 StringValue label(label_str); |
| 1406 | 1433 |
| 1407 web_ui()->CallJavascriptFunction( | 1434 web_ui()->CallJavascriptFunction( |
| 1408 "BrowserOptions.setupProxySettingsSection", disabled, label); | 1435 "BrowserOptions.setupProxySettingsSection", disabled, label); |
| 1409 #endif // !defined(OS_CHROMEOS) | 1436 #endif // !defined(OS_CHROMEOS) |
| 1410 } | 1437 } |
| 1411 | 1438 |
| 1412 } // namespace options | 1439 } // namespace options |
| OLD | NEW |