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 #include <utility> | 10 #include <utility> |
(...skipping 1199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1210 ->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 1210 ->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
1211 std::string())) | 1211 std::string())) |
1212 .Get(policy::key::kUserAvatarImage)); | 1212 .Get(policy::key::kUserAvatarImage)); |
1213 | 1213 |
1214 OnWallpaperManagedChanged( | 1214 OnWallpaperManagedChanged( |
1215 chromeos::WallpaperManager::Get()->IsPolicyControlled( | 1215 chromeos::WallpaperManager::Get()->IsPolicyControlled( |
1216 user->GetAccountId())); | 1216 user->GetAccountId())); |
1217 | 1217 |
1218 if (arc::IsArcAllowedForProfile(profile) && | 1218 if (arc::IsArcAllowedForProfile(profile) && |
1219 !arc::IsArcOptInVerificationDisabled()) { | 1219 !arc::IsArcOptInVerificationDisabled()) { |
1220 base::FundamentalValue is_arc_enabled( | 1220 base::Value is_arc_enabled(arc::IsArcPlayStoreEnabledForProfile(profile)); |
1221 arc::IsArcPlayStoreEnabledForProfile(profile)); | |
1222 web_ui()->CallJavascriptFunctionUnsafe( | 1221 web_ui()->CallJavascriptFunctionUnsafe( |
1223 "BrowserOptions.showAndroidAppsSection", | 1222 "BrowserOptions.showAndroidAppsSection", |
1224 is_arc_enabled); | 1223 is_arc_enabled); |
1225 // Get the initial state of Android Settings app readiness. | 1224 // Get the initial state of Android Settings app readiness. |
1226 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 1225 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
1227 ArcAppListPrefs::Get(profile)->GetApp(arc::kSettingsAppId); | 1226 ArcAppListPrefs::Get(profile)->GetApp(arc::kSettingsAppId); |
1228 if (app_info && app_info->ready) | 1227 if (app_info && app_info->ready) |
1229 UpdateAndroidSettingsAppState(app_info->ready); | 1228 UpdateAndroidSettingsAppState(app_info->ready); |
1230 } | 1229 } |
1231 | 1230 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1308 } | 1307 } |
1309 | 1308 |
1310 SetDefaultBrowserUIString(status_string_id); | 1309 SetDefaultBrowserUIString(status_string_id); |
1311 } | 1310 } |
1312 | 1311 |
1313 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { | 1312 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { |
1314 base::StringValue status_string( | 1313 base::StringValue status_string( |
1315 l10n_util::GetStringFUTF16(status_string_id, | 1314 l10n_util::GetStringFUTF16(status_string_id, |
1316 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 1315 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
1317 | 1316 |
1318 base::FundamentalValue is_default( | 1317 base::Value is_default(status_string_id == |
1319 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); | 1318 IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); |
1320 | 1319 |
1321 base::FundamentalValue can_be_default( | 1320 base::Value can_be_default( |
1322 !IsDisabledByPolicy(default_browser_policy_) && | 1321 !IsDisabledByPolicy(default_browser_policy_) && |
1323 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || | 1322 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || |
1324 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); | 1323 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); |
1325 | 1324 |
1326 web_ui()->CallJavascriptFunctionUnsafe( | 1325 web_ui()->CallJavascriptFunctionUnsafe( |
1327 "BrowserOptions.updateDefaultBrowserState", status_string, is_default, | 1326 "BrowserOptions.updateDefaultBrowserState", status_string, is_default, |
1328 can_be_default); | 1327 can_be_default); |
1329 } | 1328 } |
1330 #endif // !defined(OS_CHROMEOS) | 1329 #endif // !defined(OS_CHROMEOS) |
1331 | 1330 |
(...skipping 16 matching lines...) Expand all Loading... |
1348 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 1347 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
1349 entry->SetString("name", t_url->short_name()); | 1348 entry->SetString("name", t_url->short_name()); |
1350 entry->SetInteger("index", i); | 1349 entry->SetInteger("index", i); |
1351 search_engines.Append(std::move(entry)); | 1350 search_engines.Append(std::move(entry)); |
1352 if (t_url == default_url) | 1351 if (t_url == default_url) |
1353 default_index = i; | 1352 default_index = i; |
1354 } | 1353 } |
1355 | 1354 |
1356 web_ui()->CallJavascriptFunctionUnsafe( | 1355 web_ui()->CallJavascriptFunctionUnsafe( |
1357 "BrowserOptions.updateSearchEngines", search_engines, | 1356 "BrowserOptions.updateSearchEngines", search_engines, |
1358 base::FundamentalValue(default_index), | 1357 base::Value(default_index), |
1359 base::FundamentalValue( | 1358 base::Value(template_url_service_->is_default_search_managed() || |
1360 template_url_service_->is_default_search_managed() || | 1359 template_url_service_->IsExtensionControlledDefaultSearch())); |
1361 template_url_service_->IsExtensionControlledDefaultSearch())); | |
1362 | 1360 |
1363 SetupExtensionControlledIndicators(); | 1361 SetupExtensionControlledIndicators(); |
1364 | 1362 |
1365 HandleRequestHotwordAvailable(nullptr); | 1363 HandleRequestHotwordAvailable(nullptr); |
1366 HandleRequestGoogleNowAvailable(nullptr); | 1364 HandleRequestGoogleNowAvailable(nullptr); |
1367 } | 1365 } |
1368 | 1366 |
1369 void BrowserOptionsHandler::SetDefaultSearchEngine( | 1367 void BrowserOptionsHandler::SetDefaultSearchEngine( |
1370 const base::ListValue* args) { | 1368 const base::ListValue* args) { |
1371 int selected_index = -1; | 1369 int selected_index = -1; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1517 } | 1515 } |
1518 | 1516 |
1519 void BrowserOptionsHandler::ObserveThemeChanged() { | 1517 void BrowserOptionsHandler::ObserveThemeChanged() { |
1520 Profile* profile = Profile::FromWebUI(web_ui()); | 1518 Profile* profile = Profile::FromWebUI(web_ui()); |
1521 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 1519 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
1522 bool is_system_theme = false; | 1520 bool is_system_theme = false; |
1523 | 1521 |
1524 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1522 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1525 bool profile_is_supervised = profile->IsSupervised(); | 1523 bool profile_is_supervised = profile->IsSupervised(); |
1526 is_system_theme = theme_service->UsingSystemTheme(); | 1524 is_system_theme = theme_service->UsingSystemTheme(); |
1527 base::FundamentalValue native_theme_enabled(!is_system_theme && | 1525 base::Value native_theme_enabled(!is_system_theme && !profile_is_supervised); |
1528 !profile_is_supervised); | |
1529 web_ui()->CallJavascriptFunctionUnsafe( | 1526 web_ui()->CallJavascriptFunctionUnsafe( |
1530 "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled); | 1527 "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled); |
1531 #endif | 1528 #endif |
1532 | 1529 |
1533 bool is_classic_theme = !is_system_theme && | 1530 bool is_classic_theme = !is_system_theme && |
1534 theme_service->UsingDefaultTheme(); | 1531 theme_service->UsingDefaultTheme(); |
1535 base::FundamentalValue enabled(!is_classic_theme); | 1532 base::Value enabled(!is_classic_theme); |
1536 web_ui()->CallJavascriptFunctionUnsafe( | 1533 web_ui()->CallJavascriptFunctionUnsafe( |
1537 "BrowserOptions.setThemesResetButtonEnabled", enabled); | 1534 "BrowserOptions.setThemesResetButtonEnabled", enabled); |
1538 } | 1535 } |
1539 | 1536 |
1540 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { | 1537 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { |
1541 Profile* profile = Profile::FromWebUI(web_ui()); | 1538 Profile* profile = Profile::FromWebUI(web_ui()); |
1542 content::RecordAction(UserMetricsAction("Options_ThemesReset")); | 1539 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
1543 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); | 1540 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); |
1544 } | 1541 } |
1545 | 1542 |
(...skipping 17 matching lines...) Expand all Loading... |
1563 base::StringValue email_value(email); | 1560 base::StringValue email_value(email); |
1564 web_ui()->CallJavascriptFunctionUnsafe( | 1561 web_ui()->CallJavascriptFunctionUnsafe( |
1565 "BrowserOptions.updateAccountPicture", email_value); | 1562 "BrowserOptions.updateAccountPicture", email_value); |
1566 web_ui()->CallJavascriptFunctionUnsafe( | 1563 web_ui()->CallJavascriptFunctionUnsafe( |
1567 "AccountsOptions.getInstance().updateAccountPicture", email_value); | 1564 "AccountsOptions.getInstance().updateAccountPicture", email_value); |
1568 } | 1565 } |
1569 } | 1566 } |
1570 | 1567 |
1571 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { | 1568 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { |
1572 web_ui()->CallJavascriptFunctionUnsafe( | 1569 web_ui()->CallJavascriptFunctionUnsafe( |
1573 "BrowserOptions.setAccountPictureManaged", | 1570 "BrowserOptions.setAccountPictureManaged", base::Value(managed)); |
1574 base::FundamentalValue(managed)); | |
1575 } | 1571 } |
1576 | 1572 |
1577 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { | 1573 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { |
1578 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged", | 1574 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged", |
1579 base::FundamentalValue(managed)); | 1575 base::Value(managed)); |
1580 } | 1576 } |
1581 | 1577 |
1582 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { | 1578 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { |
1583 web_ui()->CallJavascriptFunctionUnsafe( | 1579 web_ui()->CallJavascriptFunctionUnsafe( |
1584 "BrowserOptions.setSystemTimezoneManaged", | 1580 "BrowserOptions.setSystemTimezoneManaged", |
1585 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); | 1581 base::Value(chromeos::system::HasSystemTimezonePolicy())); |
1586 } | 1582 } |
1587 | 1583 |
1588 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { | 1584 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { |
1589 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1585 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1590 chromeos::switches::kDisableSystemTimezoneAutomaticDetectionPolicy)) { | 1586 chromeos::switches::kDisableSystemTimezoneAutomaticDetectionPolicy)) { |
1591 return; | 1587 return; |
1592 } | 1588 } |
1593 | 1589 |
1594 PrefService* prefs = g_browser_process->local_state(); | 1590 PrefService* prefs = g_browser_process->local_state(); |
1595 const bool is_managed = prefs->IsManagedPreference( | 1591 const bool is_managed = prefs->IsManagedPreference( |
1596 prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1592 prefs::kSystemTimezoneAutomaticDetectionPolicy); |
1597 const int value = | 1593 const int value = |
1598 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1594 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); |
1599 web_ui()->CallJavascriptFunctionUnsafe( | 1595 web_ui()->CallJavascriptFunctionUnsafe( |
1600 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", | 1596 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", |
1601 base::FundamentalValue(is_managed), base::FundamentalValue(value)); | 1597 base::Value(is_managed), base::Value(value)); |
1602 } | 1598 } |
1603 #endif | 1599 #endif |
1604 | 1600 |
1605 std::unique_ptr<base::DictionaryValue> | 1601 std::unique_ptr<base::DictionaryValue> |
1606 BrowserOptionsHandler::GetSyncStateDictionary() { | 1602 BrowserOptionsHandler::GetSyncStateDictionary() { |
1607 // The items which are to be written into |sync_status| are also described in | 1603 // The items which are to be written into |sync_status| are also described in |
1608 // chrome/browser/resources/options/browser_options.js in @typedef | 1604 // chrome/browser/resources/options/browser_options.js in @typedef |
1609 // for SyncStatus. Please update it whenever you add or remove any keys here. | 1605 // for SyncStatus. Please update it whenever you add or remove any keys here. |
1610 std::unique_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); | 1606 std::unique_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); |
1611 Profile* profile = Profile::FromWebUI(web_ui()); | 1607 Profile* profile = Profile::FromWebUI(web_ui()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1683 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index, | 1679 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index, |
1684 void* params) { | 1680 void* params) { |
1685 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 1681 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
1686 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1682 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
1687 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 1683 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
1688 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); | 1684 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); |
1689 } | 1685 } |
1690 | 1686 |
1691 #if defined(OS_CHROMEOS) | 1687 #if defined(OS_CHROMEOS) |
1692 void BrowserOptionsHandler::TouchpadExists(bool exists) { | 1688 void BrowserOptionsHandler::TouchpadExists(bool exists) { |
1693 base::FundamentalValue val(exists); | 1689 base::Value val(exists); |
1694 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", | 1690 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", |
1695 val); | 1691 val); |
1696 } | 1692 } |
1697 | 1693 |
1698 void BrowserOptionsHandler::MouseExists(bool exists) { | 1694 void BrowserOptionsHandler::MouseExists(bool exists) { |
1699 base::FundamentalValue val(exists); | 1695 base::Value val(exists); |
1700 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls", | 1696 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls", |
1701 val); | 1697 val); |
1702 } | 1698 } |
1703 | 1699 |
1704 void BrowserOptionsHandler::OnUserImagePolicyChanged( | 1700 void BrowserOptionsHandler::OnUserImagePolicyChanged( |
1705 const base::Value* previous_policy, | 1701 const base::Value* previous_policy, |
1706 const base::Value* current_policy) { | 1702 const base::Value* current_policy) { |
1707 const bool had_policy = previous_policy; | 1703 const bool had_policy = previous_policy; |
1708 const bool has_policy = current_policy; | 1704 const bool has_policy = current_policy; |
1709 if (had_policy != has_policy) | 1705 if (had_policy != has_policy) |
(...skipping 19 matching lines...) Expand all Loading... |
1729 | 1725 |
1730 #endif // defined(OS_CHROMEOS) | 1726 #endif // defined(OS_CHROMEOS) |
1731 | 1727 |
1732 void BrowserOptionsHandler::UpdateSyncState() { | 1728 void BrowserOptionsHandler::UpdateSyncState() { |
1733 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState", | 1729 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState", |
1734 *GetSyncStateDictionary()); | 1730 *GetSyncStateDictionary()); |
1735 | 1731 |
1736 // A change in sign-in state also affects how hotwording and audio history are | 1732 // A change in sign-in state also affects how hotwording and audio history are |
1737 // displayed. Hide all hotwording and re-display properly. | 1733 // displayed. Hide all hotwording and re-display properly. |
1738 web_ui()->CallJavascriptFunctionUnsafe( | 1734 web_ui()->CallJavascriptFunctionUnsafe( |
1739 "BrowserOptions.setAllHotwordSectionsVisible", | 1735 "BrowserOptions.setAllHotwordSectionsVisible", base::Value(false)); |
1740 base::FundamentalValue(false)); | |
1741 HandleRequestHotwordAvailable(nullptr); | 1736 HandleRequestHotwordAvailable(nullptr); |
1742 } | 1737 } |
1743 | 1738 |
1744 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { | 1739 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { |
1745 UpdateSyncState(); | 1740 UpdateSyncState(); |
1746 } | 1741 } |
1747 | 1742 |
1748 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { | 1743 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { |
1749 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 1744 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
1750 DownloadManager* manager = BrowserContext::GetDownloadManager( | 1745 DownloadManager* manager = BrowserContext::GetDownloadManager( |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1822 ui::PAGE_TRANSITION_LINK, false); | 1817 ui::PAGE_TRANSITION_LINK, false); |
1823 web_ui()->GetWebContents()->OpenURL(params); | 1818 web_ui()->GetWebContents()->OpenURL(params); |
1824 } | 1819 } |
1825 #endif | 1820 #endif |
1826 | 1821 |
1827 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( | 1822 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( |
1828 const base::string16& audio_history_state, | 1823 const base::string16& audio_history_state, |
1829 bool success, bool logging_enabled) { | 1824 bool success, bool logging_enabled) { |
1830 bool visible = logging_enabled && success; | 1825 bool visible = logging_enabled && success; |
1831 web_ui()->CallJavascriptFunctionUnsafe( | 1826 web_ui()->CallJavascriptFunctionUnsafe( |
1832 "BrowserOptions.setAudioHistorySectionVisible", | 1827 "BrowserOptions.setAudioHistorySectionVisible", base::Value(visible), |
1833 base::FundamentalValue(visible), base::StringValue(audio_history_state)); | 1828 base::StringValue(audio_history_state)); |
1834 } | 1829 } |
1835 | 1830 |
1836 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( | 1831 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( |
1837 const base::ListValue* args) { | 1832 const base::ListValue* args) { |
1838 bool is_search_provider_google = false; | 1833 bool is_search_provider_google = false; |
1839 if (template_url_service_ && template_url_service_->loaded()) { | 1834 if (template_url_service_ && template_url_service_->loaded()) { |
1840 const TemplateURL* default_url = | 1835 const TemplateURL* default_url = |
1841 template_url_service_->GetDefaultSearchProvider(); | 1836 template_url_service_->GetDefaultSearchProvider(); |
1842 if (default_url && default_url->HasGoogleBaseURLs( | 1837 if (default_url && default_url->HasGoogleBaseURLs( |
1843 template_url_service_->search_terms_data())) { | 1838 template_url_service_->search_terms_data())) { |
1844 is_search_provider_google = true; | 1839 is_search_provider_google = true; |
1845 } | 1840 } |
1846 } | 1841 } |
1847 | 1842 |
1848 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); | 1843 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); |
1849 bool has_field_trial = !group.empty() && group != "Disabled"; | 1844 bool has_field_trial = !group.empty() && group != "Disabled"; |
1850 | 1845 |
1851 bool should_show = is_search_provider_google && has_field_trial; | 1846 bool should_show = is_search_provider_google && has_field_trial; |
1852 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible", | 1847 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible", |
1853 base::FundamentalValue(should_show)); | 1848 base::Value(should_show)); |
1854 } | 1849 } |
1855 | 1850 |
1856 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1851 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
1857 const base::ListValue* args) { | 1852 const base::ListValue* args) { |
1858 Profile* profile = Profile::FromWebUI(web_ui()); | 1853 Profile* profile = Profile::FromWebUI(web_ui()); |
1859 | 1854 |
1860 bool is_search_provider_google = false; | 1855 bool is_search_provider_google = false; |
1861 // The check for default search provider is only valid if the | 1856 // The check for default search provider is only valid if the |
1862 // |template_url_service_| has loaded already. | 1857 // |template_url_service_| has loaded already. |
1863 if (template_url_service_ && template_url_service_->loaded()) { | 1858 if (template_url_service_ && template_url_service_->loaded()) { |
(...skipping 11 matching lines...) Expand all Loading... |
1875 hotword_service->DisableHotwordPreferences(); | 1870 hotword_service->DisableHotwordPreferences(); |
1876 } | 1871 } |
1877 } | 1872 } |
1878 | 1873 |
1879 // |is_search_provider_google| may be false because |template_url_service_| | 1874 // |is_search_provider_google| may be false because |template_url_service_| |
1880 // does not exist yet or because the user selected a different search | 1875 // does not exist yet or because the user selected a different search |
1881 // provider. In either case it does not make sense to show the hotwording | 1876 // provider. In either case it does not make sense to show the hotwording |
1882 // options. | 1877 // options. |
1883 if (!is_search_provider_google) { | 1878 if (!is_search_provider_google) { |
1884 web_ui()->CallJavascriptFunctionUnsafe( | 1879 web_ui()->CallJavascriptFunctionUnsafe( |
1885 "BrowserOptions.setAllHotwordSectionsVisible", | 1880 "BrowserOptions.setAllHotwordSectionsVisible", base::Value(false)); |
1886 base::FundamentalValue(false)); | |
1887 return; | 1881 return; |
1888 } | 1882 } |
1889 | 1883 |
1890 // Don't need to check the field trial here since |IsHotwordAllowed| also | 1884 // Don't need to check the field trial here since |IsHotwordAllowed| also |
1891 // checks it. | 1885 // checks it. |
1892 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1886 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
1893 // Update the current error value. | 1887 // Update the current error value. |
1894 HotwordServiceFactory::IsServiceAvailable(profile); | 1888 HotwordServiceFactory::IsServiceAvailable(profile); |
1895 int error = HotwordServiceFactory::GetCurrentError(profile); | 1889 int error = HotwordServiceFactory::GetCurrentError(profile); |
1896 | 1890 |
1897 std::string function_name; | 1891 std::string function_name; |
1898 bool always_on = false; | 1892 bool always_on = false; |
1899 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 1893 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
1900 bool authenticated = signin && signin->IsAuthenticated(); | 1894 bool authenticated = signin && signin->IsAuthenticated(); |
1901 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { | 1895 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { |
1902 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; | 1896 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; |
1903 always_on = true; | 1897 always_on = true; |
1904 // Show the retrain link if always-on is enabled. | 1898 // Show the retrain link if always-on is enabled. |
1905 if (profile->GetPrefs()->GetBoolean( | 1899 if (profile->GetPrefs()->GetBoolean( |
1906 prefs::kHotwordAlwaysOnSearchEnabled)) { | 1900 prefs::kHotwordAlwaysOnSearchEnabled)) { |
1907 web_ui()->CallJavascriptFunctionUnsafe( | 1901 web_ui()->CallJavascriptFunctionUnsafe( |
1908 "BrowserOptions.setHotwordRetrainLinkVisible", | 1902 "BrowserOptions.setHotwordRetrainLinkVisible", base::Value(true)); |
1909 base::FundamentalValue(true)); | |
1910 } | 1903 } |
1911 } else { | 1904 } else { |
1912 function_name = "BrowserOptions.showHotwordNoDspSection"; | 1905 function_name = "BrowserOptions.showHotwordNoDspSection"; |
1913 } | 1906 } |
1914 | 1907 |
1915 // Audio history should be displayed if it's enabled regardless of the | 1908 // Audio history should be displayed if it's enabled regardless of the |
1916 // hotword error state if the user is signed in. If the user is not signed | 1909 // hotword error state if the user is signed in. If the user is not signed |
1917 // in, audio history is meaningless. This is only displayed if always-on | 1910 // in, audio history is meaningless. This is only displayed if always-on |
1918 // hotwording is available. | 1911 // hotwording is available. |
1919 if (authenticated && always_on) { | 1912 if (authenticated && always_on) { |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2038 if (app_id == arc::kSettingsAppId) { | 2031 if (app_id == arc::kSettingsAppId) { |
2039 UpdateAndroidSettingsAppState(ready); | 2032 UpdateAndroidSettingsAppState(ready); |
2040 } | 2033 } |
2041 } | 2034 } |
2042 | 2035 |
2043 void BrowserOptionsHandler::OnUserImageChanged(const user_manager::User& user) { | 2036 void BrowserOptionsHandler::OnUserImageChanged(const user_manager::User& user) { |
2044 UpdateAccountPicture(); | 2037 UpdateAccountPicture(); |
2045 } | 2038 } |
2046 | 2039 |
2047 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) { | 2040 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) { |
2048 base::FundamentalValue is_visible(visible); | 2041 base::Value is_visible(visible); |
2049 web_ui()->CallJavascriptFunctionUnsafe( | 2042 web_ui()->CallJavascriptFunctionUnsafe( |
2050 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible); | 2043 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible); |
2051 } | 2044 } |
2052 | 2045 |
2053 void BrowserOptionsHandler::ShowAndroidAppsSettings( | 2046 void BrowserOptionsHandler::ShowAndroidAppsSettings( |
2054 const base::ListValue* args) { | 2047 const base::ListValue* args) { |
2055 Profile* profile = Profile::FromWebUI(web_ui()); | 2048 Profile* profile = Profile::FromWebUI(web_ui()); |
2056 // Settings in secondary profile cannot access ARC. | 2049 // Settings in secondary profile cannot access ARC. |
2057 if (!arc::IsArcAllowedForProfile(profile)) { | 2050 if (!arc::IsArcAllowedForProfile(profile)) { |
2058 LOG(ERROR) << "Settings can't be invoked for non-primary profile"; | 2051 LOG(ERROR) << "Settings can't be invoked for non-primary profile"; |
(...skipping 29 matching lines...) Expand all Loading... |
2088 if (!arc::IsArcAllowedForProfile(profile)) { | 2081 if (!arc::IsArcAllowedForProfile(profile)) { |
2089 LOG(WARNING) << "Settings can't be invoked for non-primary profile"; | 2082 LOG(WARNING) << "Settings can't be invoked for non-primary profile"; |
2090 return; | 2083 return; |
2091 } | 2084 } |
2092 | 2085 |
2093 arc::ShowTalkBackSettings(); | 2086 arc::ShowTalkBackSettings(); |
2094 } | 2087 } |
2095 | 2088 |
2096 void BrowserOptionsHandler::SetupAccessibilityFeatures() { | 2089 void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
2097 PrefService* pref_service = g_browser_process->local_state(); | 2090 PrefService* pref_service = g_browser_process->local_state(); |
2098 base::FundamentalValue virtual_keyboard_enabled( | 2091 base::Value virtual_keyboard_enabled( |
2099 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); | 2092 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); |
2100 web_ui()->CallJavascriptFunctionUnsafe( | 2093 web_ui()->CallJavascriptFunctionUnsafe( |
2101 "BrowserOptions.setVirtualKeyboardCheckboxState", | 2094 "BrowserOptions.setVirtualKeyboardCheckboxState", |
2102 virtual_keyboard_enabled); | 2095 virtual_keyboard_enabled); |
2103 } | 2096 } |
2104 #endif | 2097 #endif |
2105 | 2098 |
2106 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { | 2099 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
2107 #if defined(GOOGLE_CHROME_BUILD) | 2100 #if defined(GOOGLE_CHROME_BUILD) |
2108 // Don't show the reporting setting if we are in the guest mode. | 2101 // Don't show the reporting setting if we are in the guest mode. |
2109 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { | 2102 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { |
2110 base::FundamentalValue visible(false); | 2103 base::Value visible(false); |
2111 web_ui()->CallJavascriptFunctionUnsafe( | 2104 web_ui()->CallJavascriptFunctionUnsafe( |
2112 "BrowserOptions.setMetricsReportingSettingVisibility", visible); | 2105 "BrowserOptions.setMetricsReportingSettingVisibility", visible); |
2113 } | 2106 } |
2114 #endif | 2107 #endif |
2115 } | 2108 } |
2116 | 2109 |
2117 void BrowserOptionsHandler::SetupNetworkPredictionControl() { | 2110 void BrowserOptionsHandler::SetupNetworkPredictionControl() { |
2118 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 2111 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
2119 | 2112 |
2120 base::DictionaryValue dict; | 2113 base::DictionaryValue dict; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2195 zoom_factors_value); | 2188 zoom_factors_value); |
2196 } | 2189 } |
2197 | 2190 |
2198 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { | 2191 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { |
2199 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. | 2192 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. |
2200 // We show the button if the user has any auto-open file types registered. | 2193 // We show the button if the user has any auto-open file types registered. |
2201 DownloadManager* manager = BrowserContext::GetDownloadManager( | 2194 DownloadManager* manager = BrowserContext::GetDownloadManager( |
2202 web_ui()->GetWebContents()->GetBrowserContext()); | 2195 web_ui()->GetWebContents()->GetBrowserContext()); |
2203 bool display = manager && | 2196 bool display = manager && |
2204 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); | 2197 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); |
2205 base::FundamentalValue value(display); | 2198 base::Value value(display); |
2206 web_ui()->CallJavascriptFunctionUnsafe( | 2199 web_ui()->CallJavascriptFunctionUnsafe( |
2207 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); | 2200 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); |
2208 } | 2201 } |
2209 | 2202 |
2210 void BrowserOptionsHandler::SetupProxySettingsSection() { | 2203 void BrowserOptionsHandler::SetupProxySettingsSection() { |
2211 #if !defined(OS_CHROMEOS) | 2204 #if !defined(OS_CHROMEOS) |
2212 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 2205 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
2213 const PrefService::Preference* proxy_config = | 2206 const PrefService::Preference* proxy_config = |
2214 pref_service->FindPreference(proxy_config::prefs::kProxy); | 2207 pref_service->FindPreference(proxy_config::prefs::kProxy); |
2215 bool is_extension_controlled = (proxy_config && | 2208 bool is_extension_controlled = (proxy_config && |
2216 proxy_config->IsExtensionControlled()); | 2209 proxy_config->IsExtensionControlled()); |
2217 | 2210 |
2218 base::FundamentalValue disabled(proxy_config && | 2211 base::Value disabled(proxy_config && !proxy_config->IsUserModifiable()); |
2219 !proxy_config->IsUserModifiable()); | 2212 base::Value extension_controlled(is_extension_controlled); |
2220 base::FundamentalValue extension_controlled(is_extension_controlled); | |
2221 web_ui()->CallJavascriptFunctionUnsafe( | 2213 web_ui()->CallJavascriptFunctionUnsafe( |
2222 "BrowserOptions.setupProxySettingsButton", disabled, | 2214 "BrowserOptions.setupProxySettingsButton", disabled, |
2223 extension_controlled); | 2215 extension_controlled); |
2224 | 2216 |
2225 #if defined(OS_WIN) | 2217 #if defined(OS_WIN) |
2226 SetupExtensionControlledIndicators(); | 2218 SetupExtensionControlledIndicators(); |
2227 #endif // defined(OS_WIN) | 2219 #endif // defined(OS_WIN) |
2228 | 2220 |
2229 #endif // !defined(OS_CHROMEOS) | 2221 #endif // !defined(OS_CHROMEOS) |
2230 } | 2222 } |
2231 | 2223 |
2232 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 2224 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
2233 bool has_users = !Profile::FromWebUI(web_ui())-> | 2225 bool has_users = !Profile::FromWebUI(web_ui())-> |
2234 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 2226 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
2235 base::FundamentalValue has_users_value(has_users); | 2227 base::Value has_users_value(has_users); |
2236 web_ui()->CallJavascriptFunctionUnsafe( | 2228 web_ui()->CallJavascriptFunctionUnsafe( |
2237 "BrowserOptions.updateManagesSupervisedUsers", has_users_value); | 2229 "BrowserOptions.updateManagesSupervisedUsers", has_users_value); |
2238 } | 2230 } |
2239 | 2231 |
2240 void BrowserOptionsHandler::SetupEasyUnlock() { | 2232 void BrowserOptionsHandler::SetupEasyUnlock() { |
2241 base::FundamentalValue is_enabled( | 2233 base::Value is_enabled( |
2242 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); | 2234 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); |
2243 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", | 2235 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", |
2244 is_enabled); | 2236 is_enabled); |
2245 } | 2237 } |
2246 | 2238 |
2247 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { | 2239 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { |
2248 base::DictionaryValue extension_controlled; | 2240 base::DictionaryValue extension_controlled; |
2249 | 2241 |
2250 Profile* profile = Profile::FromWebUI(web_ui()); | 2242 Profile* profile = Profile::FromWebUI(web_ui()); |
2251 | 2243 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2321 | 2313 |
2322 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { | 2314 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { |
2323 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), | 2315 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
2324 !IsDeviceOwnerProfile()); | 2316 !IsDeviceOwnerProfile()); |
2325 } | 2317 } |
2326 | 2318 |
2327 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 2319 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
2328 bool policy_managed, | 2320 bool policy_managed, |
2329 bool owner_managed) { | 2321 bool owner_managed) { |
2330 web_ui()->CallJavascriptFunctionUnsafe( | 2322 web_ui()->CallJavascriptFunctionUnsafe( |
2331 "BrowserOptions.setMetricsReportingCheckboxState", | 2323 "BrowserOptions.setMetricsReportingCheckboxState", base::Value(checked), |
2332 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), | 2324 base::Value(policy_managed), base::Value(owner_managed)); |
2333 base::FundamentalValue(owner_managed)); | |
2334 } | 2325 } |
2335 | 2326 |
2336 void BrowserOptionsHandler::SetupSafeBrowsingExtendedReporting() { | 2327 void BrowserOptionsHandler::SetupSafeBrowsingExtendedReporting() { |
2337 base::FundamentalValue is_enabled(safe_browsing::IsExtendedReportingEnabled( | 2328 base::Value is_enabled(safe_browsing::IsExtendedReportingEnabled( |
2338 *Profile::FromWebUI(web_ui())->GetPrefs())); | 2329 *Profile::FromWebUI(web_ui())->GetPrefs())); |
2339 web_ui()->CallJavascriptFunctionUnsafe( | 2330 web_ui()->CallJavascriptFunctionUnsafe( |
2340 "BrowserOptions.setExtendedReportingEnabledCheckboxState", is_enabled); | 2331 "BrowserOptions.setExtendedReportingEnabledCheckboxState", is_enabled); |
2341 } | 2332 } |
2342 | 2333 |
2343 void BrowserOptionsHandler::HandleSafeBrowsingExtendedReporting( | 2334 void BrowserOptionsHandler::HandleSafeBrowsingExtendedReporting( |
2344 const base::ListValue* args) { | 2335 const base::ListValue* args) { |
2345 bool checked; | 2336 bool checked; |
2346 if (args->GetBoolean(0, &checked)) { | 2337 if (args->GetBoolean(0, &checked)) { |
2347 safe_browsing::SetExtendedReportingPrefAndMetric( | 2338 safe_browsing::SetExtendedReportingPrefAndMetric( |
(...skipping 13 matching lines...) Expand all Loading... |
2361 | 2352 |
2362 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2353 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
2363 #if defined(OS_CHROMEOS) | 2354 #if defined(OS_CHROMEOS) |
2364 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2355 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
2365 #else | 2356 #else |
2366 return true; | 2357 return true; |
2367 #endif | 2358 #endif |
2368 } | 2359 } |
2369 | 2360 |
2370 } // namespace options | 2361 } // namespace options |
OLD | NEW |