| Index: chrome/browser/ui/webui/options/browser_options_handler.cc
|
| diff --git a/chrome/browser/ui/webui/options/browser_options_handler.cc b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| index c665f6f309df47ae9dd086717d740b3989342662..6d7162cd4299e1b5fdcd63eaa99a2cf37a8cef0d 100644
|
| --- a/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| +++ b/chrome/browser/ui/webui/options/browser_options_handler.cc
|
| @@ -1066,7 +1066,7 @@ void BrowserOptionsHandler::InitializePage() {
|
| !user_manager::UserManager::Get()->IsLoggedInAsGuest() &&
|
| !user_manager::UserManager::Get()->IsLoggedInAsSupervisedUser();
|
| if (enable_factory_reset_) {
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.enableFactoryResetSection");
|
| }
|
|
|
| @@ -1099,7 +1099,8 @@ void BrowserOptionsHandler::InitializePage() {
|
| !profile->IsLegacySupervised() && user->HasGaiaAccount() &&
|
| !user_manager::UserManager::Get()
|
| ->IsCurrentUserCryptohomeDataEphemeral()) {
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.showAndroidAppsSection");
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.showAndroidAppsSection");
|
| }
|
| OnSystemTimezoneAutomaticDetectionPolicyChanged();
|
| #endif
|
| @@ -1197,9 +1198,9 @@ void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) {
|
| (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT ||
|
| status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT));
|
|
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.updateDefaultBrowserState",
|
| - status_string, is_default, can_be_default);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.updateDefaultBrowserState", status_string, is_default,
|
| + can_be_default);
|
| }
|
| #endif // !defined(OS_CHROMEOS)
|
|
|
| @@ -1227,9 +1228,8 @@ void BrowserOptionsHandler::OnTemplateURLServiceChanged() {
|
| default_index = i;
|
| }
|
|
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.updateSearchEngines",
|
| - search_engines,
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.updateSearchEngines", search_engines,
|
| base::FundamentalValue(default_index),
|
| base::FundamentalValue(
|
| template_url_service_->is_default_search_managed() ||
|
| @@ -1372,8 +1372,8 @@ std::unique_ptr<base::ListValue> BrowserOptionsHandler::GetProfilesInfoList() {
|
| void BrowserOptionsHandler::SendProfilesInfo() {
|
| if (!ShouldShowMultiProfilesUserList())
|
| return;
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setProfilesInfo",
|
| - *GetProfilesInfoList());
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setProfilesInfo",
|
| + *GetProfilesInfoList());
|
| }
|
|
|
| void BrowserOptionsHandler::DeleteProfile(const base::ListValue* args) {
|
| @@ -1405,15 +1405,15 @@ void BrowserOptionsHandler::ObserveThemeChanged() {
|
| is_system_theme = theme_service->UsingSystemTheme();
|
| base::FundamentalValue native_theme_enabled(!is_system_theme &&
|
| !profile_is_supervised);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setNativeThemeButtonEnabled",
|
| - native_theme_enabled);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled);
|
| #endif
|
|
|
| bool is_classic_theme = !is_system_theme &&
|
| theme_service->UsingDefaultTheme();
|
| base::FundamentalValue enabled(!is_classic_theme);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setThemesResetButtonEnabled",
|
| - enabled);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.setThemesResetButtonEnabled", enabled);
|
| }
|
|
|
| void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) {
|
| @@ -1435,28 +1435,29 @@ void BrowserOptionsHandler::UpdateAccountPicture() {
|
| std::string email =
|
| user_manager::UserManager::Get()->GetLoggedInUser()->email();
|
| if (!email.empty()) {
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture");
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.updateAccountPicture");
|
| base::StringValue email_value(email);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.updateAccountPicture",
|
| - email_value);
|
| - web_ui()->CallJavascriptFunction(
|
| - "AccountsOptions.getInstance().updateAccountPicture",
|
| - email_value);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.updateAccountPicture", email_value);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "AccountsOptions.getInstance().updateAccountPicture", email_value);
|
| }
|
| }
|
|
|
| void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) {
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setAccountPictureManaged",
|
| - base::FundamentalValue(managed));
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.setAccountPictureManaged",
|
| + base::FundamentalValue(managed));
|
| }
|
|
|
| void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) {
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setWallpaperManaged",
|
| - base::FundamentalValue(managed));
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged",
|
| + base::FundamentalValue(managed));
|
| }
|
|
|
| void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() {
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setSystemTimezoneManaged",
|
| base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy()));
|
| }
|
| @@ -1472,7 +1473,7 @@ void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() {
|
| prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| const int value =
|
| prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy);
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged",
|
| base::FundamentalValue(is_managed), base::FundamentalValue(value));
|
| }
|
| @@ -1561,12 +1562,14 @@ void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index,
|
| #if defined(OS_CHROMEOS)
|
| void BrowserOptionsHandler::TouchpadExists(bool exists) {
|
| base::FundamentalValue val(exists);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.showTouchpadControls", val);
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls",
|
| + val);
|
| }
|
|
|
| void BrowserOptionsHandler::MouseExists(bool exists) {
|
| base::FundamentalValue val(exists);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.showMouseControls", val);
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls",
|
| + val);
|
| }
|
|
|
| void BrowserOptionsHandler::OnUserImagePolicyChanged(
|
| @@ -1599,19 +1602,19 @@ void BrowserOptionsHandler::OnConsumerManagementStatusChanged() {
|
| const std::string& status = g_browser_process->platform_part()->
|
| browser_policy_connector_chromeos()->GetConsumerManagementService()->
|
| GetStatusString();
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setConsumerManagementStatus", base::StringValue(status));
|
| }
|
|
|
| #endif // defined(OS_CHROMEOS)
|
|
|
| void BrowserOptionsHandler::UpdateSyncState() {
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.updateSyncState",
|
| - *GetSyncStateDictionary());
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState",
|
| + *GetSyncStateDictionary());
|
|
|
| // A change in sign-in state also affects how hotwording and audio history are
|
| // displayed. Hide all hotwording and re-display properly.
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setAllHotwordSectionsVisible",
|
| base::FundamentalValue(false));
|
| HandleRequestHotwordAvailable(nullptr);
|
| @@ -1712,10 +1715,9 @@ void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible(
|
| const base::string16& audio_history_state,
|
| bool success, bool logging_enabled) {
|
| bool visible = logging_enabled && success;
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setAudioHistorySectionVisible",
|
| - base::FundamentalValue(visible),
|
| - base::StringValue(audio_history_state));
|
| + base::FundamentalValue(visible), base::StringValue(audio_history_state));
|
| }
|
|
|
| void BrowserOptionsHandler::HandleRequestGoogleNowAvailable(
|
| @@ -1734,9 +1736,8 @@ void BrowserOptionsHandler::HandleRequestGoogleNowAvailable(
|
| bool has_field_trial = !group.empty() && group != "Disabled";
|
|
|
| bool should_show = is_search_provider_google && has_field_trial;
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.setNowSectionVisible",
|
| - base::FundamentalValue(should_show));
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible",
|
| + base::FundamentalValue(should_show));
|
| }
|
|
|
| void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| @@ -1767,7 +1768,7 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| // provider. In either case it does not make sense to show the hotwording
|
| // options.
|
| if (!is_search_provider_google) {
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setAllHotwordSectionsVisible",
|
| base::FundamentalValue(false));
|
| return;
|
| @@ -1790,7 +1791,7 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| // Show the retrain link if always-on is enabled.
|
| if (profile->GetPrefs()->GetBoolean(
|
| prefs::kHotwordAlwaysOnSearchEnabled)) {
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setHotwordRetrainLinkVisible",
|
| base::FundamentalValue(true));
|
| }
|
| @@ -1821,7 +1822,7 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| }
|
|
|
| if (!error) {
|
| - web_ui()->CallJavascriptFunction(function_name);
|
| + web_ui()->CallJavascriptFunctionUnsafe(function_name);
|
| } else {
|
| base::string16 hotword_help_url =
|
| base::ASCIIToUTF16(chrome::kHotwordLearnMoreURL);
|
| @@ -1830,7 +1831,7 @@ void BrowserOptionsHandler::HandleRequestHotwordAvailable(
|
| error_message = base::StringValue(
|
| l10n_util::GetStringFUTF16(error, hotword_help_url));
|
| }
|
| - web_ui()->CallJavascriptFunction(function_name, error_message);
|
| + web_ui()->CallJavascriptFunctionUnsafe(function_name, error_message);
|
| }
|
| }
|
| }
|
| @@ -1912,7 +1913,7 @@ void BrowserOptionsHandler::SetupAccessibilityFeatures() {
|
| PrefService* pref_service = g_browser_process->local_state();
|
| base::FundamentalValue virtual_keyboard_enabled(
|
| pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled));
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setVirtualKeyboardCheckboxState",
|
| virtual_keyboard_enabled);
|
| }
|
| @@ -1923,7 +1924,7 @@ void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() {
|
| // Don't show the reporting setting if we are in the guest mode.
|
| if (Profile::FromWebUI(web_ui())->IsGuestSession()) {
|
| base::FundamentalValue visible(false);
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setMetricsReportingSettingVisibility", visible);
|
| }
|
| #endif
|
| @@ -1939,8 +1940,8 @@ void BrowserOptionsHandler::SetupNetworkPredictionControl() {
|
| !pref_service->IsUserModifiablePreference(
|
| prefs::kNetworkPredictionOptions));
|
|
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setNetworkPredictionValue",
|
| - dict);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.setNetworkPredictionValue", dict);
|
| }
|
|
|
| void BrowserOptionsHandler::SetupFontSizeSelector() {
|
| @@ -1972,7 +1973,7 @@ void BrowserOptionsHandler::SetupFontSizeSelector() {
|
| dict.SetString("controlledBy", "extension");
|
| }
|
|
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setFontSize", dict);
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setFontSize", dict);
|
| }
|
|
|
| void BrowserOptionsHandler::SetupPageZoomSelector() {
|
| @@ -2007,8 +2008,8 @@ void BrowserOptionsHandler::SetupPageZoomSelector() {
|
| zoom_factors_value.Append(option);
|
| }
|
|
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.setupPageZoomSelector", zoom_factors_value);
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setupPageZoomSelector",
|
| + zoom_factors_value);
|
| }
|
|
|
| void BrowserOptionsHandler::SetupAutoOpenFileTypes() {
|
| @@ -2019,7 +2020,7 @@ void BrowserOptionsHandler::SetupAutoOpenFileTypes() {
|
| bool display = manager &&
|
| DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed();
|
| base::FundamentalValue value(display);
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setAutoOpenFileTypesDisplayed", value);
|
| }
|
|
|
| @@ -2034,8 +2035,9 @@ void BrowserOptionsHandler::SetupProxySettingsSection() {
|
| base::FundamentalValue disabled(proxy_config &&
|
| !proxy_config->IsUserModifiable());
|
| base::FundamentalValue extension_controlled(is_extension_controlled);
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.setupProxySettingsButton",
|
| - disabled, extension_controlled);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.setupProxySettingsButton", disabled,
|
| + extension_controlled);
|
|
|
| #if defined(OS_WIN)
|
| SetupExtensionControlledIndicators();
|
| @@ -2048,17 +2050,15 @@ void BrowserOptionsHandler::SetupManagingSupervisedUsers() {
|
| bool has_users = !Profile::FromWebUI(web_ui())->
|
| GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty();
|
| base::FundamentalValue has_users_value(has_users);
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.updateManagesSupervisedUsers",
|
| - has_users_value);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.updateManagesSupervisedUsers", has_users_value);
|
| }
|
|
|
| void BrowserOptionsHandler::SetupEasyUnlock() {
|
| base::FundamentalValue is_enabled(
|
| EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled());
|
| - web_ui()->CallJavascriptFunction(
|
| - "BrowserOptions.updateEasyUnlock",
|
| - is_enabled);
|
| + web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock",
|
| + is_enabled);
|
| }
|
|
|
| void BrowserOptionsHandler::SetupExtensionControlledIndicators() {
|
| @@ -2103,8 +2103,8 @@ void BrowserOptionsHandler::SetupExtensionControlledIndicators() {
|
| Profile::FromWebUI(web_ui()));
|
| AppendExtensionData("proxy", extension, &extension_controlled);
|
|
|
| - web_ui()->CallJavascriptFunction("BrowserOptions.toggleExtensionIndicators",
|
| - extension_controlled);
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| + "BrowserOptions.toggleExtensionIndicators", extension_controlled);
|
| #endif // defined(OS_WIN)
|
| }
|
|
|
| @@ -2161,7 +2161,7 @@ void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) {
|
| void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked,
|
| bool policy_managed,
|
| bool owner_managed) {
|
| - web_ui()->CallJavascriptFunction(
|
| + web_ui()->CallJavascriptFunctionUnsafe(
|
| "BrowserOptions.setMetricsReportingCheckboxState",
|
| base::FundamentalValue(checked), base::FundamentalValue(policy_managed),
|
| base::FundamentalValue(owner_managed));
|
|
|