| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 1048 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1059 SetupExtensionControlledIndicators(); | 1059 SetupExtensionControlledIndicators(); |
| 1060 | 1060 |
| 1061 #if defined(OS_CHROMEOS) | 1061 #if defined(OS_CHROMEOS) |
| 1062 SetupAccessibilityFeatures(); | 1062 SetupAccessibilityFeatures(); |
| 1063 policy::BrowserPolicyConnectorChromeOS* connector = | 1063 policy::BrowserPolicyConnectorChromeOS* connector = |
| 1064 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 1064 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 1065 enable_factory_reset_ = !connector->IsEnterpriseManaged() && | 1065 enable_factory_reset_ = !connector->IsEnterpriseManaged() && |
| 1066 !user_manager::UserManager::Get()->IsLoggedInAsGuest() && | 1066 !user_manager::UserManager::Get()->IsLoggedInAsGuest() && |
| 1067 !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser(); | 1067 !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser(); |
| 1068 if (enable_factory_reset_) { | 1068 if (enable_factory_reset_) { |
| 1069 web_ui()->CallJavascriptFunction( | 1069 web_ui()->CallJavascriptFunctionUnsafe( |
| 1070 "BrowserOptions.enableFactoryResetSection"); | 1070 "BrowserOptions.enableFactoryResetSection"); |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 Profile* const profile = Profile::FromWebUI(web_ui()); | 1073 Profile* const profile = Profile::FromWebUI(web_ui()); |
| 1074 user_manager::User const* const user = | 1074 user_manager::User const* const user = |
| 1075 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 1075 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 1076 | 1076 |
| 1077 OnAccountPictureManagedChanged( | 1077 OnAccountPictureManagedChanged( |
| 1078 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile) | 1078 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile) |
| 1079 ->policy_service() | 1079 ->policy_service() |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1092 OnConsumerManagementStatusChanged(); | 1092 OnConsumerManagementStatusChanged(); |
| 1093 consumer_management->AddObserver(this); | 1093 consumer_management->AddObserver(this); |
| 1094 } | 1094 } |
| 1095 | 1095 |
| 1096 if (arc::ArcBridgeService::GetEnabled( | 1096 if (arc::ArcBridgeService::GetEnabled( |
| 1097 base::CommandLine::ForCurrentProcess()) && | 1097 base::CommandLine::ForCurrentProcess()) && |
| 1098 !arc::ArcAuthService::IsOptInVerificationDisabled() && | 1098 !arc::ArcAuthService::IsOptInVerificationDisabled() && |
| 1099 !profile->IsLegacySupervised() && user->HasGaiaAccount() && | 1099 !profile->IsLegacySupervised() && user->HasGaiaAccount() && |
| 1100 !user_manager::UserManager::Get() | 1100 !user_manager::UserManager::Get() |
| 1101 ->IsCurrentUserCryptohomeDataEphemeral()) { | 1101 ->IsCurrentUserCryptohomeDataEphemeral()) { |
| 1102 web_ui()->CallJavascriptFunction("BrowserOptions.showAndroidAppsSection"); | 1102 web_ui()->CallJavascriptFunctionUnsafe( |
| 1103 "BrowserOptions.showAndroidAppsSection"); |
| 1103 } | 1104 } |
| 1104 OnSystemTimezoneAutomaticDetectionPolicyChanged(); | 1105 OnSystemTimezoneAutomaticDetectionPolicyChanged(); |
| 1105 #endif | 1106 #endif |
| 1106 } | 1107 } |
| 1107 | 1108 |
| 1108 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { | 1109 bool BrowserOptionsHandler::ShouldShowSetDefaultBrowser() { |
| 1109 #if defined(OS_CHROMEOS) | 1110 #if defined(OS_CHROMEOS) |
| 1110 // We're always the default browser on ChromeOS. | 1111 // We're always the default browser on ChromeOS. |
| 1111 return false; | 1112 return false; |
| 1112 #else | 1113 #else |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1190 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 1191 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
| 1191 | 1192 |
| 1192 base::FundamentalValue is_default( | 1193 base::FundamentalValue is_default( |
| 1193 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); | 1194 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); |
| 1194 | 1195 |
| 1195 base::FundamentalValue can_be_default( | 1196 base::FundamentalValue can_be_default( |
| 1196 !IsDisabledByPolicy(default_browser_policy_) && | 1197 !IsDisabledByPolicy(default_browser_policy_) && |
| 1197 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || | 1198 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || |
| 1198 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); | 1199 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); |
| 1199 | 1200 |
| 1200 web_ui()->CallJavascriptFunction( | 1201 web_ui()->CallJavascriptFunctionUnsafe( |
| 1201 "BrowserOptions.updateDefaultBrowserState", | 1202 "BrowserOptions.updateDefaultBrowserState", status_string, is_default, |
| 1202 status_string, is_default, can_be_default); | 1203 can_be_default); |
| 1203 } | 1204 } |
| 1204 #endif // !defined(OS_CHROMEOS) | 1205 #endif // !defined(OS_CHROMEOS) |
| 1205 | 1206 |
| 1206 void BrowserOptionsHandler::OnTemplateURLServiceChanged() { | 1207 void BrowserOptionsHandler::OnTemplateURLServiceChanged() { |
| 1207 if (!template_url_service_ || !template_url_service_->loaded()) | 1208 if (!template_url_service_ || !template_url_service_->loaded()) |
| 1208 return; | 1209 return; |
| 1209 | 1210 |
| 1210 const TemplateURL* default_url = | 1211 const TemplateURL* default_url = |
| 1211 template_url_service_->GetDefaultSearchProvider(); | 1212 template_url_service_->GetDefaultSearchProvider(); |
| 1212 | 1213 |
| 1213 int default_index = -1; | 1214 int default_index = -1; |
| 1214 base::ListValue search_engines; | 1215 base::ListValue search_engines; |
| 1215 TemplateURLService::TemplateURLVector model_urls( | 1216 TemplateURLService::TemplateURLVector model_urls( |
| 1216 template_url_service_->GetTemplateURLs()); | 1217 template_url_service_->GetTemplateURLs()); |
| 1217 for (size_t i = 0; i < model_urls.size(); ++i) { | 1218 for (size_t i = 0; i < model_urls.size(); ++i) { |
| 1218 if (!model_urls[i]->ShowInDefaultList( | 1219 if (!model_urls[i]->ShowInDefaultList( |
| 1219 template_url_service_->search_terms_data())) | 1220 template_url_service_->search_terms_data())) |
| 1220 continue; | 1221 continue; |
| 1221 | 1222 |
| 1222 base::DictionaryValue* entry = new base::DictionaryValue(); | 1223 base::DictionaryValue* entry = new base::DictionaryValue(); |
| 1223 entry->SetString("name", model_urls[i]->short_name()); | 1224 entry->SetString("name", model_urls[i]->short_name()); |
| 1224 entry->SetInteger("index", i); | 1225 entry->SetInteger("index", i); |
| 1225 search_engines.Append(entry); | 1226 search_engines.Append(entry); |
| 1226 if (model_urls[i] == default_url) | 1227 if (model_urls[i] == default_url) |
| 1227 default_index = i; | 1228 default_index = i; |
| 1228 } | 1229 } |
| 1229 | 1230 |
| 1230 web_ui()->CallJavascriptFunction( | 1231 web_ui()->CallJavascriptFunctionUnsafe( |
| 1231 "BrowserOptions.updateSearchEngines", | 1232 "BrowserOptions.updateSearchEngines", search_engines, |
| 1232 search_engines, | |
| 1233 base::FundamentalValue(default_index), | 1233 base::FundamentalValue(default_index), |
| 1234 base::FundamentalValue( | 1234 base::FundamentalValue( |
| 1235 template_url_service_->is_default_search_managed() || | 1235 template_url_service_->is_default_search_managed() || |
| 1236 template_url_service_->IsExtensionControlledDefaultSearch())); | 1236 template_url_service_->IsExtensionControlledDefaultSearch())); |
| 1237 | 1237 |
| 1238 SetupExtensionControlledIndicators(); | 1238 SetupExtensionControlledIndicators(); |
| 1239 | 1239 |
| 1240 HandleRequestHotwordAvailable(nullptr); | 1240 HandleRequestHotwordAvailable(nullptr); |
| 1241 HandleRequestGoogleNowAvailable(nullptr); | 1241 HandleRequestGoogleNowAvailable(nullptr); |
| 1242 } | 1242 } |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1365 | 1365 |
| 1366 profile_info_list->Append(profile_value); | 1366 profile_info_list->Append(profile_value); |
| 1367 } | 1367 } |
| 1368 | 1368 |
| 1369 return profile_info_list; | 1369 return profile_info_list; |
| 1370 } | 1370 } |
| 1371 | 1371 |
| 1372 void BrowserOptionsHandler::SendProfilesInfo() { | 1372 void BrowserOptionsHandler::SendProfilesInfo() { |
| 1373 if (!ShouldShowMultiProfilesUserList()) | 1373 if (!ShouldShowMultiProfilesUserList()) |
| 1374 return; | 1374 return; |
| 1375 web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo", | 1375 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setProfilesInfo", |
| 1376 *GetProfilesInfoList()); | 1376 *GetProfilesInfoList()); |
| 1377 } | 1377 } |
| 1378 | 1378 |
| 1379 void BrowserOptionsHandler::DeleteProfile(const base::ListValue* args) { | 1379 void BrowserOptionsHandler::DeleteProfile(const base::ListValue* args) { |
| 1380 DCHECK(args); | 1380 DCHECK(args); |
| 1381 const base::Value* file_path_value; | 1381 const base::Value* file_path_value; |
| 1382 if (!args->Get(0, &file_path_value)) { | 1382 if (!args->Get(0, &file_path_value)) { |
| 1383 NOTREACHED(); | 1383 NOTREACHED(); |
| 1384 return; | 1384 return; |
| 1385 } | 1385 } |
| 1386 | 1386 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1398 void BrowserOptionsHandler::ObserveThemeChanged() { | 1398 void BrowserOptionsHandler::ObserveThemeChanged() { |
| 1399 Profile* profile = Profile::FromWebUI(web_ui()); | 1399 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1400 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 1400 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
| 1401 bool is_system_theme = false; | 1401 bool is_system_theme = false; |
| 1402 | 1402 |
| 1403 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1403 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1404 bool profile_is_supervised = profile->IsSupervised(); | 1404 bool profile_is_supervised = profile->IsSupervised(); |
| 1405 is_system_theme = theme_service->UsingSystemTheme(); | 1405 is_system_theme = theme_service->UsingSystemTheme(); |
| 1406 base::FundamentalValue native_theme_enabled(!is_system_theme && | 1406 base::FundamentalValue native_theme_enabled(!is_system_theme && |
| 1407 !profile_is_supervised); | 1407 !profile_is_supervised); |
| 1408 web_ui()->CallJavascriptFunction("BrowserOptions.setNativeThemeButtonEnabled", | 1408 web_ui()->CallJavascriptFunctionUnsafe( |
| 1409 native_theme_enabled); | 1409 "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled); |
| 1410 #endif | 1410 #endif |
| 1411 | 1411 |
| 1412 bool is_classic_theme = !is_system_theme && | 1412 bool is_classic_theme = !is_system_theme && |
| 1413 theme_service->UsingDefaultTheme(); | 1413 theme_service->UsingDefaultTheme(); |
| 1414 base::FundamentalValue enabled(!is_classic_theme); | 1414 base::FundamentalValue enabled(!is_classic_theme); |
| 1415 web_ui()->CallJavascriptFunction("BrowserOptions.setThemesResetButtonEnabled", | 1415 web_ui()->CallJavascriptFunctionUnsafe( |
| 1416 enabled); | 1416 "BrowserOptions.setThemesResetButtonEnabled", enabled); |
| 1417 } | 1417 } |
| 1418 | 1418 |
| 1419 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { | 1419 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { |
| 1420 Profile* profile = Profile::FromWebUI(web_ui()); | 1420 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1421 content::RecordAction(UserMetricsAction("Options_ThemesReset")); | 1421 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
| 1422 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); | 1422 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); |
| 1423 } | 1423 } |
| 1424 | 1424 |
| 1425 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1425 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
| 1426 void BrowserOptionsHandler::ThemesSetNative(const base::ListValue* args) { | 1426 void BrowserOptionsHandler::ThemesSetNative(const base::ListValue* args) { |
| 1427 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); | 1427 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); |
| 1428 Profile* profile = Profile::FromWebUI(web_ui()); | 1428 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1429 ThemeServiceFactory::GetForProfile(profile)->UseSystemTheme(); | 1429 ThemeServiceFactory::GetForProfile(profile)->UseSystemTheme(); |
| 1430 } | 1430 } |
| 1431 #endif | 1431 #endif |
| 1432 | 1432 |
| 1433 #if defined(OS_CHROMEOS) | 1433 #if defined(OS_CHROMEOS) |
| 1434 void BrowserOptionsHandler::UpdateAccountPicture() { | 1434 void BrowserOptionsHandler::UpdateAccountPicture() { |
| 1435 std::string email = | 1435 std::string email = |
| 1436 user_manager::UserManager::Get()->GetLoggedInUser()->email(); | 1436 user_manager::UserManager::Get()->GetLoggedInUser()->email(); |
| 1437 if (!email.empty()) { | 1437 if (!email.empty()) { |
| 1438 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture"); | 1438 web_ui()->CallJavascriptFunctionUnsafe( |
| 1439 "BrowserOptions.updateAccountPicture"); |
| 1439 base::StringValue email_value(email); | 1440 base::StringValue email_value(email); |
| 1440 web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture", | 1441 web_ui()->CallJavascriptFunctionUnsafe( |
| 1441 email_value); | 1442 "BrowserOptions.updateAccountPicture", email_value); |
| 1442 web_ui()->CallJavascriptFunction( | 1443 web_ui()->CallJavascriptFunctionUnsafe( |
| 1443 "AccountsOptions.getInstance().updateAccountPicture", | 1444 "AccountsOptions.getInstance().updateAccountPicture", email_value); |
| 1444 email_value); | |
| 1445 } | 1445 } |
| 1446 } | 1446 } |
| 1447 | 1447 |
| 1448 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { | 1448 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { |
| 1449 web_ui()->CallJavascriptFunction("BrowserOptions.setAccountPictureManaged", | 1449 web_ui()->CallJavascriptFunctionUnsafe( |
| 1450 base::FundamentalValue(managed)); | 1450 "BrowserOptions.setAccountPictureManaged", |
| 1451 base::FundamentalValue(managed)); |
| 1451 } | 1452 } |
| 1452 | 1453 |
| 1453 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { | 1454 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { |
| 1454 web_ui()->CallJavascriptFunction("BrowserOptions.setWallpaperManaged", | 1455 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged", |
| 1455 base::FundamentalValue(managed)); | 1456 base::FundamentalValue(managed)); |
| 1456 } | 1457 } |
| 1457 | 1458 |
| 1458 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { | 1459 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { |
| 1459 web_ui()->CallJavascriptFunction( | 1460 web_ui()->CallJavascriptFunctionUnsafe( |
| 1460 "BrowserOptions.setSystemTimezoneManaged", | 1461 "BrowserOptions.setSystemTimezoneManaged", |
| 1461 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); | 1462 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); |
| 1462 } | 1463 } |
| 1463 | 1464 |
| 1464 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { | 1465 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { |
| 1465 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 1466 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1466 chromeos::switches::kEnableSystemTimezoneAutomaticDetectionPolicy)) { | 1467 chromeos::switches::kEnableSystemTimezoneAutomaticDetectionPolicy)) { |
| 1467 return; | 1468 return; |
| 1468 } | 1469 } |
| 1469 | 1470 |
| 1470 PrefService* prefs = g_browser_process->local_state(); | 1471 PrefService* prefs = g_browser_process->local_state(); |
| 1471 const bool is_managed = prefs->IsManagedPreference( | 1472 const bool is_managed = prefs->IsManagedPreference( |
| 1472 prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1473 prefs::kSystemTimezoneAutomaticDetectionPolicy); |
| 1473 const int value = | 1474 const int value = |
| 1474 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1475 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); |
| 1475 web_ui()->CallJavascriptFunction( | 1476 web_ui()->CallJavascriptFunctionUnsafe( |
| 1476 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", | 1477 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", |
| 1477 base::FundamentalValue(is_managed), base::FundamentalValue(value)); | 1478 base::FundamentalValue(is_managed), base::FundamentalValue(value)); |
| 1478 } | 1479 } |
| 1479 #endif | 1480 #endif |
| 1480 | 1481 |
| 1481 std::unique_ptr<base::DictionaryValue> | 1482 std::unique_ptr<base::DictionaryValue> |
| 1482 BrowserOptionsHandler::GetSyncStateDictionary() { | 1483 BrowserOptionsHandler::GetSyncStateDictionary() { |
| 1483 // The items which are to be written into |sync_status| are also described in | 1484 // The items which are to be written into |sync_status| are also described in |
| 1484 // chrome/browser/resources/options/browser_options.js in @typedef | 1485 // chrome/browser/resources/options/browser_options.js in @typedef |
| 1485 // for SyncStatus. Please update it whenever you add or remove any keys here. | 1486 // for SyncStatus. Please update it whenever you add or remove any keys here. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 void* params) { | 1555 void* params) { |
| 1555 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 1556 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
| 1556 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1557 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1557 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 1558 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
| 1558 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); | 1559 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); |
| 1559 } | 1560 } |
| 1560 | 1561 |
| 1561 #if defined(OS_CHROMEOS) | 1562 #if defined(OS_CHROMEOS) |
| 1562 void BrowserOptionsHandler::TouchpadExists(bool exists) { | 1563 void BrowserOptionsHandler::TouchpadExists(bool exists) { |
| 1563 base::FundamentalValue val(exists); | 1564 base::FundamentalValue val(exists); |
| 1564 web_ui()->CallJavascriptFunction("BrowserOptions.showTouchpadControls", val); | 1565 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", |
| 1566 val); |
| 1565 } | 1567 } |
| 1566 | 1568 |
| 1567 void BrowserOptionsHandler::MouseExists(bool exists) { | 1569 void BrowserOptionsHandler::MouseExists(bool exists) { |
| 1568 base::FundamentalValue val(exists); | 1570 base::FundamentalValue val(exists); |
| 1569 web_ui()->CallJavascriptFunction("BrowserOptions.showMouseControls", val); | 1571 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls", |
| 1572 val); |
| 1570 } | 1573 } |
| 1571 | 1574 |
| 1572 void BrowserOptionsHandler::OnUserImagePolicyChanged( | 1575 void BrowserOptionsHandler::OnUserImagePolicyChanged( |
| 1573 const base::Value* previous_policy, | 1576 const base::Value* previous_policy, |
| 1574 const base::Value* current_policy) { | 1577 const base::Value* current_policy) { |
| 1575 const bool had_policy = previous_policy; | 1578 const bool had_policy = previous_policy; |
| 1576 const bool has_policy = current_policy; | 1579 const bool has_policy = current_policy; |
| 1577 if (had_policy != has_policy) | 1580 if (had_policy != has_policy) |
| 1578 OnAccountPictureManagedChanged(has_policy); | 1581 OnAccountPictureManagedChanged(has_policy); |
| 1579 } | 1582 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1592 UMA_HISTOGRAM_ENUMERATION( | 1595 UMA_HISTOGRAM_ENUMERATION( |
| 1593 "Reset.ChromeOS.PowerwashDialogShown", | 1596 "Reset.ChromeOS.PowerwashDialogShown", |
| 1594 chromeos::reset::DIALOG_FROM_OPTIONS, | 1597 chromeos::reset::DIALOG_FROM_OPTIONS, |
| 1595 chromeos::reset::DIALOG_VIEW_TYPE_SIZE); | 1598 chromeos::reset::DIALOG_VIEW_TYPE_SIZE); |
| 1596 } | 1599 } |
| 1597 | 1600 |
| 1598 void BrowserOptionsHandler::OnConsumerManagementStatusChanged() { | 1601 void BrowserOptionsHandler::OnConsumerManagementStatusChanged() { |
| 1599 const std::string& status = g_browser_process->platform_part()-> | 1602 const std::string& status = g_browser_process->platform_part()-> |
| 1600 browser_policy_connector_chromeos()->GetConsumerManagementService()-> | 1603 browser_policy_connector_chromeos()->GetConsumerManagementService()-> |
| 1601 GetStatusString(); | 1604 GetStatusString(); |
| 1602 web_ui()->CallJavascriptFunction( | 1605 web_ui()->CallJavascriptFunctionUnsafe( |
| 1603 "BrowserOptions.setConsumerManagementStatus", base::StringValue(status)); | 1606 "BrowserOptions.setConsumerManagementStatus", base::StringValue(status)); |
| 1604 } | 1607 } |
| 1605 | 1608 |
| 1606 #endif // defined(OS_CHROMEOS) | 1609 #endif // defined(OS_CHROMEOS) |
| 1607 | 1610 |
| 1608 void BrowserOptionsHandler::UpdateSyncState() { | 1611 void BrowserOptionsHandler::UpdateSyncState() { |
| 1609 web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState", | 1612 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState", |
| 1610 *GetSyncStateDictionary()); | 1613 *GetSyncStateDictionary()); |
| 1611 | 1614 |
| 1612 // A change in sign-in state also affects how hotwording and audio history are | 1615 // A change in sign-in state also affects how hotwording and audio history are |
| 1613 // displayed. Hide all hotwording and re-display properly. | 1616 // displayed. Hide all hotwording and re-display properly. |
| 1614 web_ui()->CallJavascriptFunction( | 1617 web_ui()->CallJavascriptFunctionUnsafe( |
| 1615 "BrowserOptions.setAllHotwordSectionsVisible", | 1618 "BrowserOptions.setAllHotwordSectionsVisible", |
| 1616 base::FundamentalValue(false)); | 1619 base::FundamentalValue(false)); |
| 1617 HandleRequestHotwordAvailable(nullptr); | 1620 HandleRequestHotwordAvailable(nullptr); |
| 1618 } | 1621 } |
| 1619 | 1622 |
| 1620 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { | 1623 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { |
| 1621 UpdateSyncState(); | 1624 UpdateSyncState(); |
| 1622 } | 1625 } |
| 1623 | 1626 |
| 1624 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { | 1627 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1705 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false); | 1708 CURRENT_TAB, ui::PAGE_TRANSITION_LINK, false); |
| 1706 web_ui()->GetWebContents()->OpenURL(params); | 1709 web_ui()->GetWebContents()->OpenURL(params); |
| 1707 } | 1710 } |
| 1708 | 1711 |
| 1709 #endif | 1712 #endif |
| 1710 | 1713 |
| 1711 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( | 1714 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( |
| 1712 const base::string16& audio_history_state, | 1715 const base::string16& audio_history_state, |
| 1713 bool success, bool logging_enabled) { | 1716 bool success, bool logging_enabled) { |
| 1714 bool visible = logging_enabled && success; | 1717 bool visible = logging_enabled && success; |
| 1715 web_ui()->CallJavascriptFunction( | 1718 web_ui()->CallJavascriptFunctionUnsafe( |
| 1716 "BrowserOptions.setAudioHistorySectionVisible", | 1719 "BrowserOptions.setAudioHistorySectionVisible", |
| 1717 base::FundamentalValue(visible), | 1720 base::FundamentalValue(visible), base::StringValue(audio_history_state)); |
| 1718 base::StringValue(audio_history_state)); | |
| 1719 } | 1721 } |
| 1720 | 1722 |
| 1721 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( | 1723 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( |
| 1722 const base::ListValue* args) { | 1724 const base::ListValue* args) { |
| 1723 bool is_search_provider_google = false; | 1725 bool is_search_provider_google = false; |
| 1724 if (template_url_service_ && template_url_service_->loaded()) { | 1726 if (template_url_service_ && template_url_service_->loaded()) { |
| 1725 const TemplateURL* default_url = | 1727 const TemplateURL* default_url = |
| 1726 template_url_service_->GetDefaultSearchProvider(); | 1728 template_url_service_->GetDefaultSearchProvider(); |
| 1727 if (default_url && default_url->HasGoogleBaseURLs( | 1729 if (default_url && default_url->HasGoogleBaseURLs( |
| 1728 template_url_service_->search_terms_data())) { | 1730 template_url_service_->search_terms_data())) { |
| 1729 is_search_provider_google = true; | 1731 is_search_provider_google = true; |
| 1730 } | 1732 } |
| 1731 } | 1733 } |
| 1732 | 1734 |
| 1733 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); | 1735 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); |
| 1734 bool has_field_trial = !group.empty() && group != "Disabled"; | 1736 bool has_field_trial = !group.empty() && group != "Disabled"; |
| 1735 | 1737 |
| 1736 bool should_show = is_search_provider_google && has_field_trial; | 1738 bool should_show = is_search_provider_google && has_field_trial; |
| 1737 web_ui()->CallJavascriptFunction( | 1739 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible", |
| 1738 "BrowserOptions.setNowSectionVisible", | 1740 base::FundamentalValue(should_show)); |
| 1739 base::FundamentalValue(should_show)); | |
| 1740 } | 1741 } |
| 1741 | 1742 |
| 1742 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1743 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
| 1743 const base::ListValue* args) { | 1744 const base::ListValue* args) { |
| 1744 Profile* profile = Profile::FromWebUI(web_ui()); | 1745 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1745 | 1746 |
| 1746 bool is_search_provider_google = false; | 1747 bool is_search_provider_google = false; |
| 1747 // The check for default search provider is only valid if the | 1748 // The check for default search provider is only valid if the |
| 1748 // |template_url_service_| has loaded already. | 1749 // |template_url_service_| has loaded already. |
| 1749 if (template_url_service_ && template_url_service_->loaded()) { | 1750 if (template_url_service_ && template_url_service_->loaded()) { |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1760 if (hotword_service) | 1761 if (hotword_service) |
| 1761 hotword_service->DisableHotwordPreferences(); | 1762 hotword_service->DisableHotwordPreferences(); |
| 1762 } | 1763 } |
| 1763 } | 1764 } |
| 1764 | 1765 |
| 1765 // |is_search_provider_google| may be false because |template_url_service_| | 1766 // |is_search_provider_google| may be false because |template_url_service_| |
| 1766 // does not exist yet or because the user selected a different search | 1767 // does not exist yet or because the user selected a different search |
| 1767 // provider. In either case it does not make sense to show the hotwording | 1768 // provider. In either case it does not make sense to show the hotwording |
| 1768 // options. | 1769 // options. |
| 1769 if (!is_search_provider_google) { | 1770 if (!is_search_provider_google) { |
| 1770 web_ui()->CallJavascriptFunction( | 1771 web_ui()->CallJavascriptFunctionUnsafe( |
| 1771 "BrowserOptions.setAllHotwordSectionsVisible", | 1772 "BrowserOptions.setAllHotwordSectionsVisible", |
| 1772 base::FundamentalValue(false)); | 1773 base::FundamentalValue(false)); |
| 1773 return; | 1774 return; |
| 1774 } | 1775 } |
| 1775 | 1776 |
| 1776 // Don't need to check the field trial here since |IsHotwordAllowed| also | 1777 // Don't need to check the field trial here since |IsHotwordAllowed| also |
| 1777 // checks it. | 1778 // checks it. |
| 1778 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1779 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
| 1779 // Update the current error value. | 1780 // Update the current error value. |
| 1780 HotwordServiceFactory::IsServiceAvailable(profile); | 1781 HotwordServiceFactory::IsServiceAvailable(profile); |
| 1781 int error = HotwordServiceFactory::GetCurrentError(profile); | 1782 int error = HotwordServiceFactory::GetCurrentError(profile); |
| 1782 | 1783 |
| 1783 std::string function_name; | 1784 std::string function_name; |
| 1784 bool always_on = false; | 1785 bool always_on = false; |
| 1785 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 1786 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
| 1786 bool authenticated = signin && signin->IsAuthenticated(); | 1787 bool authenticated = signin && signin->IsAuthenticated(); |
| 1787 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { | 1788 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { |
| 1788 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; | 1789 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; |
| 1789 always_on = true; | 1790 always_on = true; |
| 1790 // Show the retrain link if always-on is enabled. | 1791 // Show the retrain link if always-on is enabled. |
| 1791 if (profile->GetPrefs()->GetBoolean( | 1792 if (profile->GetPrefs()->GetBoolean( |
| 1792 prefs::kHotwordAlwaysOnSearchEnabled)) { | 1793 prefs::kHotwordAlwaysOnSearchEnabled)) { |
| 1793 web_ui()->CallJavascriptFunction( | 1794 web_ui()->CallJavascriptFunctionUnsafe( |
| 1794 "BrowserOptions.setHotwordRetrainLinkVisible", | 1795 "BrowserOptions.setHotwordRetrainLinkVisible", |
| 1795 base::FundamentalValue(true)); | 1796 base::FundamentalValue(true)); |
| 1796 } | 1797 } |
| 1797 } else { | 1798 } else { |
| 1798 function_name = "BrowserOptions.showHotwordNoDspSection"; | 1799 function_name = "BrowserOptions.showHotwordNoDspSection"; |
| 1799 } | 1800 } |
| 1800 | 1801 |
| 1801 // Audio history should be displayed if it's enabled regardless of the | 1802 // Audio history should be displayed if it's enabled regardless of the |
| 1802 // hotword error state if the user is signed in. If the user is not signed | 1803 // hotword error state if the user is signed in. If the user is not signed |
| 1803 // in, audio history is meaningless. This is only displayed if always-on | 1804 // in, audio history is meaningless. This is only displayed if always-on |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1814 if (hotword_service) { | 1815 if (hotword_service) { |
| 1815 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled( | 1816 hotword_service->GetAudioHistoryHandler()->GetAudioHistoryEnabled( |
| 1816 base::Bind( | 1817 base::Bind( |
| 1817 &BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible, | 1818 &BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible, |
| 1818 weak_ptr_factory_.GetWeakPtr(), | 1819 weak_ptr_factory_.GetWeakPtr(), |
| 1819 audio_history_state)); | 1820 audio_history_state)); |
| 1820 } | 1821 } |
| 1821 } | 1822 } |
| 1822 | 1823 |
| 1823 if (!error) { | 1824 if (!error) { |
| 1824 web_ui()->CallJavascriptFunction(function_name); | 1825 web_ui()->CallJavascriptFunctionUnsafe(function_name); |
| 1825 } else { | 1826 } else { |
| 1826 base::string16 hotword_help_url = | 1827 base::string16 hotword_help_url = |
| 1827 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); | 1828 base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL); |
| 1828 base::StringValue error_message(l10n_util::GetStringUTF16(error)); | 1829 base::StringValue error_message(l10n_util::GetStringUTF16(error)); |
| 1829 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { | 1830 if (error == IDS_HOTWORD_GENERIC_ERROR_MESSAGE) { |
| 1830 error_message = base::StringValue( | 1831 error_message = base::StringValue( |
| 1831 l10n_util::GetStringFUTF16(error, hotword_help_url)); | 1832 l10n_util::GetStringFUTF16(error, hotword_help_url)); |
| 1832 } | 1833 } |
| 1833 web_ui()->CallJavascriptFunction(function_name, error_message); | 1834 web_ui()->CallJavascriptFunctionUnsafe(function_name, error_message); |
| 1834 } | 1835 } |
| 1835 } | 1836 } |
| 1836 } | 1837 } |
| 1837 | 1838 |
| 1838 void BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp( | 1839 void BrowserOptionsHandler::HandleLaunchHotwordAudioVerificationApp( |
| 1839 const base::ListValue* args) { | 1840 const base::ListValue* args) { |
| 1840 Profile* profile = Profile::FromWebUI(web_ui()); | 1841 Profile* profile = Profile::FromWebUI(web_ui()); |
| 1841 | 1842 |
| 1842 bool retrain = false; | 1843 bool retrain = false; |
| 1843 bool success = args->GetBoolean(0, &retrain); | 1844 bool success = args->GetBoolean(0, &retrain); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1905 | 1906 |
| 1906 // Perform sign out. Current chrome process will then terminate, new one will | 1907 // Perform sign out. Current chrome process will then terminate, new one will |
| 1907 // be launched (as if it was a restart). | 1908 // be launched (as if it was a restart). |
| 1908 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 1909 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 1909 } | 1910 } |
| 1910 | 1911 |
| 1911 void BrowserOptionsHandler::SetupAccessibilityFeatures() { | 1912 void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
| 1912 PrefService* pref_service = g_browser_process->local_state(); | 1913 PrefService* pref_service = g_browser_process->local_state(); |
| 1913 base::FundamentalValue virtual_keyboard_enabled( | 1914 base::FundamentalValue virtual_keyboard_enabled( |
| 1914 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); | 1915 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); |
| 1915 web_ui()->CallJavascriptFunction( | 1916 web_ui()->CallJavascriptFunctionUnsafe( |
| 1916 "BrowserOptions.setVirtualKeyboardCheckboxState", | 1917 "BrowserOptions.setVirtualKeyboardCheckboxState", |
| 1917 virtual_keyboard_enabled); | 1918 virtual_keyboard_enabled); |
| 1918 } | 1919 } |
| 1919 #endif | 1920 #endif |
| 1920 | 1921 |
| 1921 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { | 1922 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
| 1922 #if defined(GOOGLE_CHROME_BUILD) | 1923 #if defined(GOOGLE_CHROME_BUILD) |
| 1923 // Don't show the reporting setting if we are in the guest mode. | 1924 // Don't show the reporting setting if we are in the guest mode. |
| 1924 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { | 1925 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { |
| 1925 base::FundamentalValue visible(false); | 1926 base::FundamentalValue visible(false); |
| 1926 web_ui()->CallJavascriptFunction( | 1927 web_ui()->CallJavascriptFunctionUnsafe( |
| 1927 "BrowserOptions.setMetricsReportingSettingVisibility", visible); | 1928 "BrowserOptions.setMetricsReportingSettingVisibility", visible); |
| 1928 } | 1929 } |
| 1929 #endif | 1930 #endif |
| 1930 } | 1931 } |
| 1931 | 1932 |
| 1932 void BrowserOptionsHandler::SetupNetworkPredictionControl() { | 1933 void BrowserOptionsHandler::SetupNetworkPredictionControl() { |
| 1933 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1934 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1934 | 1935 |
| 1935 base::DictionaryValue dict; | 1936 base::DictionaryValue dict; |
| 1936 dict.SetInteger("value", | 1937 dict.SetInteger("value", |
| 1937 pref_service->GetInteger(prefs::kNetworkPredictionOptions)); | 1938 pref_service->GetInteger(prefs::kNetworkPredictionOptions)); |
| 1938 dict.SetBoolean("disabled", | 1939 dict.SetBoolean("disabled", |
| 1939 !pref_service->IsUserModifiablePreference( | 1940 !pref_service->IsUserModifiablePreference( |
| 1940 prefs::kNetworkPredictionOptions)); | 1941 prefs::kNetworkPredictionOptions)); |
| 1941 | 1942 |
| 1942 web_ui()->CallJavascriptFunction("BrowserOptions.setNetworkPredictionValue", | 1943 web_ui()->CallJavascriptFunctionUnsafe( |
| 1943 dict); | 1944 "BrowserOptions.setNetworkPredictionValue", dict); |
| 1944 } | 1945 } |
| 1945 | 1946 |
| 1946 void BrowserOptionsHandler::SetupFontSizeSelector() { | 1947 void BrowserOptionsHandler::SetupFontSizeSelector() { |
| 1947 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1948 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 1948 const PrefService::Preference* default_font_size = | 1949 const PrefService::Preference* default_font_size = |
| 1949 pref_service->FindPreference(prefs::kWebKitDefaultFontSize); | 1950 pref_service->FindPreference(prefs::kWebKitDefaultFontSize); |
| 1950 const PrefService::Preference* default_fixed_font_size = | 1951 const PrefService::Preference* default_fixed_font_size = |
| 1951 pref_service->FindPreference(prefs::kWebKitDefaultFixedFontSize); | 1952 pref_service->FindPreference(prefs::kWebKitDefaultFixedFontSize); |
| 1952 | 1953 |
| 1953 base::DictionaryValue dict; | 1954 base::DictionaryValue dict; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1965 // This is a poor man's version of CoreOptionsHandler::CreateValueForPref, | 1966 // This is a poor man's version of CoreOptionsHandler::CreateValueForPref, |
| 1966 // adapted to consider two prefs. It may be better to refactor | 1967 // adapted to consider two prefs. It may be better to refactor |
| 1967 // CreateValueForPref so it can be called from here. | 1968 // CreateValueForPref so it can be called from here. |
| 1968 if (default_font_size->IsManaged() || default_fixed_font_size->IsManaged()) { | 1969 if (default_font_size->IsManaged() || default_fixed_font_size->IsManaged()) { |
| 1969 dict.SetString("controlledBy", "policy"); | 1970 dict.SetString("controlledBy", "policy"); |
| 1970 } else if (default_font_size->IsExtensionControlled() || | 1971 } else if (default_font_size->IsExtensionControlled() || |
| 1971 default_fixed_font_size->IsExtensionControlled()) { | 1972 default_fixed_font_size->IsExtensionControlled()) { |
| 1972 dict.SetString("controlledBy", "extension"); | 1973 dict.SetString("controlledBy", "extension"); |
| 1973 } | 1974 } |
| 1974 | 1975 |
| 1975 web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict); | 1976 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setFontSize", dict); |
| 1976 } | 1977 } |
| 1977 | 1978 |
| 1978 void BrowserOptionsHandler::SetupPageZoomSelector() { | 1979 void BrowserOptionsHandler::SetupPageZoomSelector() { |
| 1979 double default_zoom_level = | 1980 double default_zoom_level = |
| 1980 content::HostZoomMap::GetDefaultForBrowserContext( | 1981 content::HostZoomMap::GetDefaultForBrowserContext( |
| 1981 Profile::FromWebUI(web_ui()))->GetDefaultZoomLevel(); | 1982 Profile::FromWebUI(web_ui()))->GetDefaultZoomLevel(); |
| 1982 double default_zoom_factor = | 1983 double default_zoom_factor = |
| 1983 content::ZoomLevelToZoomFactor(default_zoom_level); | 1984 content::ZoomLevelToZoomFactor(default_zoom_level); |
| 1984 | 1985 |
| 1985 // Generate a vector of zoom factors from an array of known presets along with | 1986 // Generate a vector of zoom factors from an array of known presets along with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 2000 double factor = *i; | 2001 double factor = *i; |
| 2001 int percent = static_cast<int>(factor * 100 + 0.5); | 2002 int percent = static_cast<int>(factor * 100 + 0.5); |
| 2002 option->Append(new base::StringValue( | 2003 option->Append(new base::StringValue( |
| 2003 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); | 2004 l10n_util::GetStringFUTF16Int(IDS_ZOOM_PERCENT, percent))); |
| 2004 option->Append(new base::FundamentalValue(factor)); | 2005 option->Append(new base::FundamentalValue(factor)); |
| 2005 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); | 2006 bool selected = content::ZoomValuesEqual(factor, default_zoom_factor); |
| 2006 option->Append(new base::FundamentalValue(selected)); | 2007 option->Append(new base::FundamentalValue(selected)); |
| 2007 zoom_factors_value.Append(option); | 2008 zoom_factors_value.Append(option); |
| 2008 } | 2009 } |
| 2009 | 2010 |
| 2010 web_ui()->CallJavascriptFunction( | 2011 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setupPageZoomSelector", |
| 2011 "BrowserOptions.setupPageZoomSelector", zoom_factors_value); | 2012 zoom_factors_value); |
| 2012 } | 2013 } |
| 2013 | 2014 |
| 2014 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { | 2015 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { |
| 2015 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. | 2016 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. |
| 2016 // We show the button if the user has any auto-open file types registered. | 2017 // We show the button if the user has any auto-open file types registered. |
| 2017 DownloadManager* manager = BrowserContext::GetDownloadManager( | 2018 DownloadManager* manager = BrowserContext::GetDownloadManager( |
| 2018 web_ui()->GetWebContents()->GetBrowserContext()); | 2019 web_ui()->GetWebContents()->GetBrowserContext()); |
| 2019 bool display = manager && | 2020 bool display = manager && |
| 2020 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); | 2021 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); |
| 2021 base::FundamentalValue value(display); | 2022 base::FundamentalValue value(display); |
| 2022 web_ui()->CallJavascriptFunction( | 2023 web_ui()->CallJavascriptFunctionUnsafe( |
| 2023 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); | 2024 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); |
| 2024 } | 2025 } |
| 2025 | 2026 |
| 2026 void BrowserOptionsHandler::SetupProxySettingsSection() { | 2027 void BrowserOptionsHandler::SetupProxySettingsSection() { |
| 2027 #if !defined(OS_CHROMEOS) | 2028 #if !defined(OS_CHROMEOS) |
| 2028 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 2029 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
| 2029 const PrefService::Preference* proxy_config = | 2030 const PrefService::Preference* proxy_config = |
| 2030 pref_service->FindPreference(proxy_config::prefs::kProxy); | 2031 pref_service->FindPreference(proxy_config::prefs::kProxy); |
| 2031 bool is_extension_controlled = (proxy_config && | 2032 bool is_extension_controlled = (proxy_config && |
| 2032 proxy_config->IsExtensionControlled()); | 2033 proxy_config->IsExtensionControlled()); |
| 2033 | 2034 |
| 2034 base::FundamentalValue disabled(proxy_config && | 2035 base::FundamentalValue disabled(proxy_config && |
| 2035 !proxy_config->IsUserModifiable()); | 2036 !proxy_config->IsUserModifiable()); |
| 2036 base::FundamentalValue extension_controlled(is_extension_controlled); | 2037 base::FundamentalValue extension_controlled(is_extension_controlled); |
| 2037 web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsButton", | 2038 web_ui()->CallJavascriptFunctionUnsafe( |
| 2038 disabled, extension_controlled); | 2039 "BrowserOptions.setupProxySettingsButton", disabled, |
| 2040 extension_controlled); |
| 2039 | 2041 |
| 2040 #if defined(OS_WIN) | 2042 #if defined(OS_WIN) |
| 2041 SetupExtensionControlledIndicators(); | 2043 SetupExtensionControlledIndicators(); |
| 2042 #endif // defined(OS_WIN) | 2044 #endif // defined(OS_WIN) |
| 2043 | 2045 |
| 2044 #endif // !defined(OS_CHROMEOS) | 2046 #endif // !defined(OS_CHROMEOS) |
| 2045 } | 2047 } |
| 2046 | 2048 |
| 2047 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 2049 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
| 2048 bool has_users = !Profile::FromWebUI(web_ui())-> | 2050 bool has_users = !Profile::FromWebUI(web_ui())-> |
| 2049 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 2051 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
| 2050 base::FundamentalValue has_users_value(has_users); | 2052 base::FundamentalValue has_users_value(has_users); |
| 2051 web_ui()->CallJavascriptFunction( | 2053 web_ui()->CallJavascriptFunctionUnsafe( |
| 2052 "BrowserOptions.updateManagesSupervisedUsers", | 2054 "BrowserOptions.updateManagesSupervisedUsers", has_users_value); |
| 2053 has_users_value); | |
| 2054 } | 2055 } |
| 2055 | 2056 |
| 2056 void BrowserOptionsHandler::SetupEasyUnlock() { | 2057 void BrowserOptionsHandler::SetupEasyUnlock() { |
| 2057 base::FundamentalValue is_enabled( | 2058 base::FundamentalValue is_enabled( |
| 2058 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); | 2059 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); |
| 2059 web_ui()->CallJavascriptFunction( | 2060 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", |
| 2060 "BrowserOptions.updateEasyUnlock", | 2061 is_enabled); |
| 2061 is_enabled); | |
| 2062 } | 2062 } |
| 2063 | 2063 |
| 2064 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { | 2064 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { |
| 2065 #if defined(OS_WIN) | 2065 #if defined(OS_WIN) |
| 2066 base::DictionaryValue extension_controlled; | 2066 base::DictionaryValue extension_controlled; |
| 2067 | 2067 |
| 2068 // Check if an extension is overriding the Search Engine. | 2068 // Check if an extension is overriding the Search Engine. |
| 2069 const extensions::Extension* extension = | 2069 const extensions::Extension* extension = |
| 2070 extensions::GetExtensionOverridingSearchEngine( | 2070 extensions::GetExtensionOverridingSearchEngine( |
| 2071 Profile::FromWebUI(web_ui())); | 2071 Profile::FromWebUI(web_ui())); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2096 extension = registry->GetExtensionById(ntp_url.host(), | 2096 extension = registry->GetExtensionById(ntp_url.host(), |
| 2097 ExtensionRegistry::ENABLED); | 2097 ExtensionRegistry::ENABLED); |
| 2098 } | 2098 } |
| 2099 AppendExtensionData("newTabPage", extension, &extension_controlled); | 2099 AppendExtensionData("newTabPage", extension, &extension_controlled); |
| 2100 | 2100 |
| 2101 // Check if an extension is overwriting the proxy setting. | 2101 // Check if an extension is overwriting the proxy setting. |
| 2102 extension = extensions::GetExtensionOverridingProxy( | 2102 extension = extensions::GetExtensionOverridingProxy( |
| 2103 Profile::FromWebUI(web_ui())); | 2103 Profile::FromWebUI(web_ui())); |
| 2104 AppendExtensionData("proxy", extension, &extension_controlled); | 2104 AppendExtensionData("proxy", extension, &extension_controlled); |
| 2105 | 2105 |
| 2106 web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators", | 2106 web_ui()->CallJavascriptFunctionUnsafe( |
| 2107 extension_controlled); | 2107 "BrowserOptions.toggleExtensionIndicators", extension_controlled); |
| 2108 #endif // defined(OS_WIN) | 2108 #endif // defined(OS_WIN) |
| 2109 } | 2109 } |
| 2110 | 2110 |
| 2111 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { | 2111 void BrowserOptionsHandler::SetupMetricsReportingCheckbox() { |
| 2112 // As the metrics and crash reporting checkbox only exists for official builds | 2112 // As the metrics and crash reporting checkbox only exists for official builds |
| 2113 // it doesn't need to be set up for non-official builds. | 2113 // it doesn't need to be set up for non-official builds. |
| 2114 #if defined(GOOGLE_CHROME_BUILD) | 2114 #if defined(GOOGLE_CHROME_BUILD) |
| 2115 bool checked = | 2115 bool checked = |
| 2116 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); | 2116 ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled(); |
| 2117 bool policy_managed = IsMetricsReportingPolicyManaged(); | 2117 bool policy_managed = IsMetricsReportingPolicyManaged(); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 } | 2154 } |
| 2155 | 2155 |
| 2156 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { | 2156 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { |
| 2157 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), | 2157 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
| 2158 !IsDeviceOwnerProfile()); | 2158 !IsDeviceOwnerProfile()); |
| 2159 } | 2159 } |
| 2160 | 2160 |
| 2161 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 2161 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
| 2162 bool policy_managed, | 2162 bool policy_managed, |
| 2163 bool owner_managed) { | 2163 bool owner_managed) { |
| 2164 web_ui()->CallJavascriptFunction( | 2164 web_ui()->CallJavascriptFunctionUnsafe( |
| 2165 "BrowserOptions.setMetricsReportingCheckboxState", | 2165 "BrowserOptions.setMetricsReportingCheckboxState", |
| 2166 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), | 2166 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), |
| 2167 base::FundamentalValue(owner_managed)); | 2167 base::FundamentalValue(owner_managed)); |
| 2168 } | 2168 } |
| 2169 | 2169 |
| 2170 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, | 2170 void BrowserOptionsHandler::OnPolicyUpdated(const policy::PolicyNamespace& ns, |
| 2171 const policy::PolicyMap& previous, | 2171 const policy::PolicyMap& previous, |
| 2172 const policy::PolicyMap& current) { | 2172 const policy::PolicyMap& current) { |
| 2173 std::set<std::string> different_keys; | 2173 std::set<std::string> different_keys; |
| 2174 current.GetDifferingKeys(previous, &different_keys); | 2174 current.GetDifferingKeys(previous, &different_keys); |
| 2175 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) | 2175 if (ContainsKey(different_keys, policy::key::kMetricsReportingEnabled)) |
| 2176 SetupMetricsReportingCheckbox(); | 2176 SetupMetricsReportingCheckbox(); |
| 2177 } | 2177 } |
| 2178 | 2178 |
| 2179 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2179 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
| 2180 #if defined(OS_CHROMEOS) | 2180 #if defined(OS_CHROMEOS) |
| 2181 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2181 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
| 2182 #else | 2182 #else |
| 2183 return true; | 2183 return true; |
| 2184 #endif | 2184 #endif |
| 2185 } | 2185 } |
| 2186 | 2186 |
| 2187 } // namespace options | 2187 } // namespace options |
| OLD | NEW |