Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(661)

Side by Side Diff: chrome/browser/ui/webui/options/browser_options_handler.cc

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

Powered by Google App Engine
This is Rietveld 408576698