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 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 ->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 1158 ->GetPolicies(policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
1159 std::string())) | 1159 std::string())) |
1160 .Get(policy::key::kUserAvatarImage)); | 1160 .Get(policy::key::kUserAvatarImage)); |
1161 | 1161 |
1162 OnWallpaperManagedChanged( | 1162 OnWallpaperManagedChanged( |
1163 chromeos::WallpaperManager::Get()->IsPolicyControlled( | 1163 chromeos::WallpaperManager::Get()->IsPolicyControlled( |
1164 user->GetAccountId())); | 1164 user->GetAccountId())); |
1165 | 1165 |
1166 if (arc::ArcSessionManager::IsAllowedForProfile(profile) && | 1166 if (arc::ArcSessionManager::IsAllowedForProfile(profile) && |
1167 !arc::ArcSessionManager::IsOptInVerificationDisabled()) { | 1167 !arc::ArcSessionManager::IsOptInVerificationDisabled()) { |
1168 base::FundamentalValue is_arc_enabled( | 1168 base::Value is_arc_enabled(arc::ArcSessionManager::Get()->IsArcEnabled()); |
1169 arc::ArcSessionManager::Get()->IsArcEnabled()); | |
1170 web_ui()->CallJavascriptFunctionUnsafe( | 1169 web_ui()->CallJavascriptFunctionUnsafe( |
1171 "BrowserOptions.showAndroidAppsSection", | 1170 "BrowserOptions.showAndroidAppsSection", |
1172 is_arc_enabled); | 1171 is_arc_enabled); |
1173 // Get the initial state of Android Settings app readiness. | 1172 // Get the initial state of Android Settings app readiness. |
1174 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = | 1173 std::unique_ptr<ArcAppListPrefs::AppInfo> app_info = |
1175 ArcAppListPrefs::Get(profile)->GetApp(arc::kSettingsAppId); | 1174 ArcAppListPrefs::Get(profile)->GetApp(arc::kSettingsAppId); |
1176 if (app_info && app_info->ready) | 1175 if (app_info && app_info->ready) |
1177 UpdateAndroidSettingsAppState(app_info->ready); | 1176 UpdateAndroidSettingsAppState(app_info->ready); |
1178 } | 1177 } |
1179 | 1178 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1256 } | 1255 } |
1257 | 1256 |
1258 SetDefaultBrowserUIString(status_string_id); | 1257 SetDefaultBrowserUIString(status_string_id); |
1259 } | 1258 } |
1260 | 1259 |
1261 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { | 1260 void BrowserOptionsHandler::SetDefaultBrowserUIString(int status_string_id) { |
1262 base::StringValue status_string( | 1261 base::StringValue status_string( |
1263 l10n_util::GetStringFUTF16(status_string_id, | 1262 l10n_util::GetStringFUTF16(status_string_id, |
1264 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); | 1263 l10n_util::GetStringUTF16(IDS_PRODUCT_NAME))); |
1265 | 1264 |
1266 base::FundamentalValue is_default( | 1265 base::Value is_default( |
1267 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); | 1266 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT); |
1268 | 1267 |
1269 base::FundamentalValue can_be_default( | 1268 base::Value can_be_default( |
1270 !IsDisabledByPolicy(default_browser_policy_) && | 1269 !IsDisabledByPolicy(default_browser_policy_) && |
1271 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || | 1270 (status_string_id == IDS_OPTIONS_DEFAULTBROWSER_DEFAULT || |
1272 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); | 1271 status_string_id == IDS_OPTIONS_DEFAULTBROWSER_NOTDEFAULT)); |
1273 | 1272 |
1274 web_ui()->CallJavascriptFunctionUnsafe( | 1273 web_ui()->CallJavascriptFunctionUnsafe( |
1275 "BrowserOptions.updateDefaultBrowserState", status_string, is_default, | 1274 "BrowserOptions.updateDefaultBrowserState", status_string, is_default, |
1276 can_be_default); | 1275 can_be_default); |
1277 } | 1276 } |
1278 #endif // !defined(OS_CHROMEOS) | 1277 #endif // !defined(OS_CHROMEOS) |
1279 | 1278 |
(...skipping 16 matching lines...) Expand all Loading... |
1296 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); | 1295 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue()); |
1297 entry->SetString("name", t_url->short_name()); | 1296 entry->SetString("name", t_url->short_name()); |
1298 entry->SetInteger("index", i); | 1297 entry->SetInteger("index", i); |
1299 search_engines.Append(std::move(entry)); | 1298 search_engines.Append(std::move(entry)); |
1300 if (t_url == default_url) | 1299 if (t_url == default_url) |
1301 default_index = i; | 1300 default_index = i; |
1302 } | 1301 } |
1303 | 1302 |
1304 web_ui()->CallJavascriptFunctionUnsafe( | 1303 web_ui()->CallJavascriptFunctionUnsafe( |
1305 "BrowserOptions.updateSearchEngines", search_engines, | 1304 "BrowserOptions.updateSearchEngines", search_engines, |
1306 base::FundamentalValue(default_index), | 1305 base::Value(default_index), |
1307 base::FundamentalValue( | 1306 base::Value( |
1308 template_url_service_->is_default_search_managed() || | 1307 template_url_service_->is_default_search_managed() || |
1309 template_url_service_->IsExtensionControlledDefaultSearch())); | 1308 template_url_service_->IsExtensionControlledDefaultSearch())); |
1310 | 1309 |
1311 SetupExtensionControlledIndicators(); | 1310 SetupExtensionControlledIndicators(); |
1312 | 1311 |
1313 HandleRequestHotwordAvailable(nullptr); | 1312 HandleRequestHotwordAvailable(nullptr); |
1314 HandleRequestGoogleNowAvailable(nullptr); | 1313 HandleRequestGoogleNowAvailable(nullptr); |
1315 } | 1314 } |
1316 | 1315 |
1317 void BrowserOptionsHandler::SetDefaultSearchEngine( | 1316 void BrowserOptionsHandler::SetDefaultSearchEngine( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1470 } | 1469 } |
1471 | 1470 |
1472 void BrowserOptionsHandler::ObserveThemeChanged() { | 1471 void BrowserOptionsHandler::ObserveThemeChanged() { |
1473 Profile* profile = Profile::FromWebUI(web_ui()); | 1472 Profile* profile = Profile::FromWebUI(web_ui()); |
1474 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); | 1473 ThemeService* theme_service = ThemeServiceFactory::GetForProfile(profile); |
1475 bool is_system_theme = false; | 1474 bool is_system_theme = false; |
1476 | 1475 |
1477 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) | 1476 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) |
1478 bool profile_is_supervised = profile->IsSupervised(); | 1477 bool profile_is_supervised = profile->IsSupervised(); |
1479 is_system_theme = theme_service->UsingSystemTheme(); | 1478 is_system_theme = theme_service->UsingSystemTheme(); |
1480 base::FundamentalValue native_theme_enabled(!is_system_theme && | 1479 base::Value native_theme_enabled(!is_system_theme && |
1481 !profile_is_supervised); | 1480 !profile_is_supervised); |
1482 web_ui()->CallJavascriptFunctionUnsafe( | 1481 web_ui()->CallJavascriptFunctionUnsafe( |
1483 "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled); | 1482 "BrowserOptions.setNativeThemeButtonEnabled", native_theme_enabled); |
1484 #endif | 1483 #endif |
1485 | 1484 |
1486 bool is_classic_theme = !is_system_theme && | 1485 bool is_classic_theme = !is_system_theme && |
1487 theme_service->UsingDefaultTheme(); | 1486 theme_service->UsingDefaultTheme(); |
1488 base::FundamentalValue enabled(!is_classic_theme); | 1487 base::Value enabled(!is_classic_theme); |
1489 web_ui()->CallJavascriptFunctionUnsafe( | 1488 web_ui()->CallJavascriptFunctionUnsafe( |
1490 "BrowserOptions.setThemesResetButtonEnabled", enabled); | 1489 "BrowserOptions.setThemesResetButtonEnabled", enabled); |
1491 } | 1490 } |
1492 | 1491 |
1493 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { | 1492 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { |
1494 Profile* profile = Profile::FromWebUI(web_ui()); | 1493 Profile* profile = Profile::FromWebUI(web_ui()); |
1495 content::RecordAction(UserMetricsAction("Options_ThemesReset")); | 1494 content::RecordAction(UserMetricsAction("Options_ThemesReset")); |
1496 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); | 1495 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); |
1497 } | 1496 } |
1498 | 1497 |
(...skipping 18 matching lines...) Expand all Loading... |
1517 web_ui()->CallJavascriptFunctionUnsafe( | 1516 web_ui()->CallJavascriptFunctionUnsafe( |
1518 "BrowserOptions.updateAccountPicture", email_value); | 1517 "BrowserOptions.updateAccountPicture", email_value); |
1519 web_ui()->CallJavascriptFunctionUnsafe( | 1518 web_ui()->CallJavascriptFunctionUnsafe( |
1520 "AccountsOptions.getInstance().updateAccountPicture", email_value); | 1519 "AccountsOptions.getInstance().updateAccountPicture", email_value); |
1521 } | 1520 } |
1522 } | 1521 } |
1523 | 1522 |
1524 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { | 1523 void BrowserOptionsHandler::OnAccountPictureManagedChanged(bool managed) { |
1525 web_ui()->CallJavascriptFunctionUnsafe( | 1524 web_ui()->CallJavascriptFunctionUnsafe( |
1526 "BrowserOptions.setAccountPictureManaged", | 1525 "BrowserOptions.setAccountPictureManaged", |
1527 base::FundamentalValue(managed)); | 1526 base::Value(managed)); |
1528 } | 1527 } |
1529 | 1528 |
1530 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { | 1529 void BrowserOptionsHandler::OnWallpaperManagedChanged(bool managed) { |
1531 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged", | 1530 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setWallpaperManaged", |
1532 base::FundamentalValue(managed)); | 1531 base::Value(managed)); |
1533 } | 1532 } |
1534 | 1533 |
1535 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { | 1534 void BrowserOptionsHandler::OnSystemTimezonePolicyChanged() { |
1536 web_ui()->CallJavascriptFunctionUnsafe( | 1535 web_ui()->CallJavascriptFunctionUnsafe( |
1537 "BrowserOptions.setSystemTimezoneManaged", | 1536 "BrowserOptions.setSystemTimezoneManaged", |
1538 base::FundamentalValue(chromeos::system::HasSystemTimezonePolicy())); | 1537 base::Value(chromeos::system::HasSystemTimezonePolicy())); |
1539 } | 1538 } |
1540 | 1539 |
1541 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { | 1540 void BrowserOptionsHandler::OnSystemTimezoneAutomaticDetectionPolicyChanged() { |
1542 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1541 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1543 chromeos::switches::kDisableSystemTimezoneAutomaticDetectionPolicy)) { | 1542 chromeos::switches::kDisableSystemTimezoneAutomaticDetectionPolicy)) { |
1544 return; | 1543 return; |
1545 } | 1544 } |
1546 | 1545 |
1547 PrefService* prefs = g_browser_process->local_state(); | 1546 PrefService* prefs = g_browser_process->local_state(); |
1548 const bool is_managed = prefs->IsManagedPreference( | 1547 const bool is_managed = prefs->IsManagedPreference( |
1549 prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1548 prefs::kSystemTimezoneAutomaticDetectionPolicy); |
1550 const int value = | 1549 const int value = |
1551 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); | 1550 prefs->GetInteger(prefs::kSystemTimezoneAutomaticDetectionPolicy); |
1552 web_ui()->CallJavascriptFunctionUnsafe( | 1551 web_ui()->CallJavascriptFunctionUnsafe( |
1553 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", | 1552 "BrowserOptions.setSystemTimezoneAutomaticDetectionManaged", |
1554 base::FundamentalValue(is_managed), base::FundamentalValue(value)); | 1553 base::Value(is_managed), base::Value(value)); |
1555 } | 1554 } |
1556 #endif | 1555 #endif |
1557 | 1556 |
1558 std::unique_ptr<base::DictionaryValue> | 1557 std::unique_ptr<base::DictionaryValue> |
1559 BrowserOptionsHandler::GetSyncStateDictionary() { | 1558 BrowserOptionsHandler::GetSyncStateDictionary() { |
1560 // The items which are to be written into |sync_status| are also described in | 1559 // The items which are to be written into |sync_status| are also described in |
1561 // chrome/browser/resources/options/browser_options.js in @typedef | 1560 // chrome/browser/resources/options/browser_options.js in @typedef |
1562 // for SyncStatus. Please update it whenever you add or remove any keys here. | 1561 // for SyncStatus. Please update it whenever you add or remove any keys here. |
1563 std::unique_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); | 1562 std::unique_ptr<base::DictionaryValue> sync_status(new base::DictionaryValue); |
1564 Profile* profile = Profile::FromWebUI(web_ui()); | 1563 Profile* profile = Profile::FromWebUI(web_ui()); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1636 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index, | 1635 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index, |
1637 void* params) { | 1636 void* params) { |
1638 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); | 1637 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); |
1639 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 1638 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
1640 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); | 1639 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); |
1641 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); | 1640 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); |
1642 } | 1641 } |
1643 | 1642 |
1644 #if defined(OS_CHROMEOS) | 1643 #if defined(OS_CHROMEOS) |
1645 void BrowserOptionsHandler::TouchpadExists(bool exists) { | 1644 void BrowserOptionsHandler::TouchpadExists(bool exists) { |
1646 base::FundamentalValue val(exists); | 1645 base::Value val(exists); |
1647 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", | 1646 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", |
1648 val); | 1647 val); |
1649 } | 1648 } |
1650 | 1649 |
1651 void BrowserOptionsHandler::MouseExists(bool exists) { | 1650 void BrowserOptionsHandler::MouseExists(bool exists) { |
1652 base::FundamentalValue val(exists); | 1651 base::Value val(exists); |
1653 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls", | 1652 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showMouseControls", |
1654 val); | 1653 val); |
1655 } | 1654 } |
1656 | 1655 |
1657 void BrowserOptionsHandler::OnUserImagePolicyChanged( | 1656 void BrowserOptionsHandler::OnUserImagePolicyChanged( |
1658 const base::Value* previous_policy, | 1657 const base::Value* previous_policy, |
1659 const base::Value* current_policy) { | 1658 const base::Value* current_policy) { |
1660 const bool had_policy = previous_policy; | 1659 const bool had_policy = previous_policy; |
1661 const bool has_policy = current_policy; | 1660 const bool has_policy = current_policy; |
1662 if (had_policy != has_policy) | 1661 if (had_policy != has_policy) |
(...skipping 20 matching lines...) Expand all Loading... |
1683 #endif // defined(OS_CHROMEOS) | 1682 #endif // defined(OS_CHROMEOS) |
1684 | 1683 |
1685 void BrowserOptionsHandler::UpdateSyncState() { | 1684 void BrowserOptionsHandler::UpdateSyncState() { |
1686 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState", | 1685 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateSyncState", |
1687 *GetSyncStateDictionary()); | 1686 *GetSyncStateDictionary()); |
1688 | 1687 |
1689 // A change in sign-in state also affects how hotwording and audio history are | 1688 // A change in sign-in state also affects how hotwording and audio history are |
1690 // displayed. Hide all hotwording and re-display properly. | 1689 // displayed. Hide all hotwording and re-display properly. |
1691 web_ui()->CallJavascriptFunctionUnsafe( | 1690 web_ui()->CallJavascriptFunctionUnsafe( |
1692 "BrowserOptions.setAllHotwordSectionsVisible", | 1691 "BrowserOptions.setAllHotwordSectionsVisible", |
1693 base::FundamentalValue(false)); | 1692 base::Value(false)); |
1694 HandleRequestHotwordAvailable(nullptr); | 1693 HandleRequestHotwordAvailable(nullptr); |
1695 } | 1694 } |
1696 | 1695 |
1697 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { | 1696 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { |
1698 UpdateSyncState(); | 1697 UpdateSyncState(); |
1699 } | 1698 } |
1700 | 1699 |
1701 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { | 1700 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { |
1702 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); | 1701 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); |
1703 DownloadManager* manager = BrowserContext::GetDownloadManager( | 1702 DownloadManager* manager = BrowserContext::GetDownloadManager( |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 web_ui()->GetWebContents()->OpenURL(params); | 1775 web_ui()->GetWebContents()->OpenURL(params); |
1777 } | 1776 } |
1778 #endif | 1777 #endif |
1779 | 1778 |
1780 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( | 1779 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( |
1781 const base::string16& audio_history_state, | 1780 const base::string16& audio_history_state, |
1782 bool success, bool logging_enabled) { | 1781 bool success, bool logging_enabled) { |
1783 bool visible = logging_enabled && success; | 1782 bool visible = logging_enabled && success; |
1784 web_ui()->CallJavascriptFunctionUnsafe( | 1783 web_ui()->CallJavascriptFunctionUnsafe( |
1785 "BrowserOptions.setAudioHistorySectionVisible", | 1784 "BrowserOptions.setAudioHistorySectionVisible", |
1786 base::FundamentalValue(visible), base::StringValue(audio_history_state)); | 1785 base::Value(visible), base::StringValue(audio_history_state)); |
1787 } | 1786 } |
1788 | 1787 |
1789 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( | 1788 void BrowserOptionsHandler::HandleRequestGoogleNowAvailable( |
1790 const base::ListValue* args) { | 1789 const base::ListValue* args) { |
1791 bool is_search_provider_google = false; | 1790 bool is_search_provider_google = false; |
1792 if (template_url_service_ && template_url_service_->loaded()) { | 1791 if (template_url_service_ && template_url_service_->loaded()) { |
1793 const TemplateURL* default_url = | 1792 const TemplateURL* default_url = |
1794 template_url_service_->GetDefaultSearchProvider(); | 1793 template_url_service_->GetDefaultSearchProvider(); |
1795 if (default_url && default_url->HasGoogleBaseURLs( | 1794 if (default_url && default_url->HasGoogleBaseURLs( |
1796 template_url_service_->search_terms_data())) { | 1795 template_url_service_->search_terms_data())) { |
1797 is_search_provider_google = true; | 1796 is_search_provider_google = true; |
1798 } | 1797 } |
1799 } | 1798 } |
1800 | 1799 |
1801 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); | 1800 std::string group = base::FieldTrialList::FindFullName("GoogleNowExtension"); |
1802 bool has_field_trial = !group.empty() && group != "Disabled"; | 1801 bool has_field_trial = !group.empty() && group != "Disabled"; |
1803 | 1802 |
1804 bool should_show = is_search_provider_google && has_field_trial; | 1803 bool should_show = is_search_provider_google && has_field_trial; |
1805 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible", | 1804 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.setNowSectionVisible", |
1806 base::FundamentalValue(should_show)); | 1805 base::Value(should_show)); |
1807 } | 1806 } |
1808 | 1807 |
1809 void BrowserOptionsHandler::HandleRequestHotwordAvailable( | 1808 void BrowserOptionsHandler::HandleRequestHotwordAvailable( |
1810 const base::ListValue* args) { | 1809 const base::ListValue* args) { |
1811 Profile* profile = Profile::FromWebUI(web_ui()); | 1810 Profile* profile = Profile::FromWebUI(web_ui()); |
1812 | 1811 |
1813 bool is_search_provider_google = false; | 1812 bool is_search_provider_google = false; |
1814 // The check for default search provider is only valid if the | 1813 // The check for default search provider is only valid if the |
1815 // |template_url_service_| has loaded already. | 1814 // |template_url_service_| has loaded already. |
1816 if (template_url_service_ && template_url_service_->loaded()) { | 1815 if (template_url_service_ && template_url_service_->loaded()) { |
(...skipping 12 matching lines...) Expand all Loading... |
1829 } | 1828 } |
1830 } | 1829 } |
1831 | 1830 |
1832 // |is_search_provider_google| may be false because |template_url_service_| | 1831 // |is_search_provider_google| may be false because |template_url_service_| |
1833 // does not exist yet or because the user selected a different search | 1832 // does not exist yet or because the user selected a different search |
1834 // provider. In either case it does not make sense to show the hotwording | 1833 // provider. In either case it does not make sense to show the hotwording |
1835 // options. | 1834 // options. |
1836 if (!is_search_provider_google) { | 1835 if (!is_search_provider_google) { |
1837 web_ui()->CallJavascriptFunctionUnsafe( | 1836 web_ui()->CallJavascriptFunctionUnsafe( |
1838 "BrowserOptions.setAllHotwordSectionsVisible", | 1837 "BrowserOptions.setAllHotwordSectionsVisible", |
1839 base::FundamentalValue(false)); | 1838 base::Value(false)); |
1840 return; | 1839 return; |
1841 } | 1840 } |
1842 | 1841 |
1843 // Don't need to check the field trial here since |IsHotwordAllowed| also | 1842 // Don't need to check the field trial here since |IsHotwordAllowed| also |
1844 // checks it. | 1843 // checks it. |
1845 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { | 1844 if (HotwordServiceFactory::IsHotwordAllowed(profile)) { |
1846 // Update the current error value. | 1845 // Update the current error value. |
1847 HotwordServiceFactory::IsServiceAvailable(profile); | 1846 HotwordServiceFactory::IsServiceAvailable(profile); |
1848 int error = HotwordServiceFactory::GetCurrentError(profile); | 1847 int error = HotwordServiceFactory::GetCurrentError(profile); |
1849 | 1848 |
1850 std::string function_name; | 1849 std::string function_name; |
1851 bool always_on = false; | 1850 bool always_on = false; |
1852 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); | 1851 SigninManagerBase* signin = SigninManagerFactory::GetForProfile(profile); |
1853 bool authenticated = signin && signin->IsAuthenticated(); | 1852 bool authenticated = signin && signin->IsAuthenticated(); |
1854 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { | 1853 if (HotwordServiceFactory::IsAlwaysOnAvailable() && authenticated) { |
1855 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; | 1854 function_name = "BrowserOptions.showHotwordAlwaysOnSection"; |
1856 always_on = true; | 1855 always_on = true; |
1857 // Show the retrain link if always-on is enabled. | 1856 // Show the retrain link if always-on is enabled. |
1858 if (profile->GetPrefs()->GetBoolean( | 1857 if (profile->GetPrefs()->GetBoolean( |
1859 prefs::kHotwordAlwaysOnSearchEnabled)) { | 1858 prefs::kHotwordAlwaysOnSearchEnabled)) { |
1860 web_ui()->CallJavascriptFunctionUnsafe( | 1859 web_ui()->CallJavascriptFunctionUnsafe( |
1861 "BrowserOptions.setHotwordRetrainLinkVisible", | 1860 "BrowserOptions.setHotwordRetrainLinkVisible", |
1862 base::FundamentalValue(true)); | 1861 base::Value(true)); |
1863 } | 1862 } |
1864 } else { | 1863 } else { |
1865 function_name = "BrowserOptions.showHotwordNoDspSection"; | 1864 function_name = "BrowserOptions.showHotwordNoDspSection"; |
1866 } | 1865 } |
1867 | 1866 |
1868 // Audio history should be displayed if it's enabled regardless of the | 1867 // Audio history should be displayed if it's enabled regardless of the |
1869 // hotword error state if the user is signed in. If the user is not signed | 1868 // hotword error state if the user is signed in. If the user is not signed |
1870 // in, audio history is meaningless. This is only displayed if always-on | 1869 // in, audio history is meaningless. This is only displayed if always-on |
1871 // hotwording is available. | 1870 // hotwording is available. |
1872 if (authenticated && always_on) { | 1871 if (authenticated && always_on) { |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1987 | 1986 |
1988 void BrowserOptionsHandler::OnAppReadyChanged( | 1987 void BrowserOptionsHandler::OnAppReadyChanged( |
1989 const std::string& app_id, | 1988 const std::string& app_id, |
1990 bool ready) { | 1989 bool ready) { |
1991 if (app_id == arc::kSettingsAppId) { | 1990 if (app_id == arc::kSettingsAppId) { |
1992 UpdateAndroidSettingsAppState(ready); | 1991 UpdateAndroidSettingsAppState(ready); |
1993 } | 1992 } |
1994 } | 1993 } |
1995 | 1994 |
1996 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) { | 1995 void BrowserOptionsHandler::UpdateAndroidSettingsAppState(bool visible) { |
1997 base::FundamentalValue is_visible(visible); | 1996 base::Value is_visible(visible); |
1998 web_ui()->CallJavascriptFunctionUnsafe( | 1997 web_ui()->CallJavascriptFunctionUnsafe( |
1999 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible); | 1998 "BrowserOptions.setAndroidAppsSettingsVisibility", is_visible); |
2000 } | 1999 } |
2001 | 2000 |
2002 void BrowserOptionsHandler::ShowAndroidAppsSettings( | 2001 void BrowserOptionsHandler::ShowAndroidAppsSettings( |
2003 const base::ListValue* args) { | 2002 const base::ListValue* args) { |
2004 Profile* profile = Profile::FromWebUI(web_ui()); | 2003 Profile* profile = Profile::FromWebUI(web_ui()); |
2005 // Settings in secondary profile cannot access ARC. | 2004 // Settings in secondary profile cannot access ARC. |
2006 if (!arc::ArcSessionManager::IsAllowedForProfile(profile)) { | 2005 if (!arc::ArcSessionManager::IsAllowedForProfile(profile)) { |
2007 LOG(ERROR) << "Settings can't be invoked for non-primary profile"; | 2006 LOG(ERROR) << "Settings can't be invoked for non-primary profile"; |
(...skipping 10 matching lines...) Expand all Loading... |
2018 if (!arc::ArcSessionManager::IsAllowedForProfile(profile)) { | 2017 if (!arc::ArcSessionManager::IsAllowedForProfile(profile)) { |
2019 LOG(WARNING) << "Settings can't be invoked for non-primary profile"; | 2018 LOG(WARNING) << "Settings can't be invoked for non-primary profile"; |
2020 return; | 2019 return; |
2021 } | 2020 } |
2022 | 2021 |
2023 arc::ShowTalkBackSettings(); | 2022 arc::ShowTalkBackSettings(); |
2024 } | 2023 } |
2025 | 2024 |
2026 void BrowserOptionsHandler::SetupAccessibilityFeatures() { | 2025 void BrowserOptionsHandler::SetupAccessibilityFeatures() { |
2027 PrefService* pref_service = g_browser_process->local_state(); | 2026 PrefService* pref_service = g_browser_process->local_state(); |
2028 base::FundamentalValue virtual_keyboard_enabled( | 2027 base::Value virtual_keyboard_enabled( |
2029 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); | 2028 pref_service->GetBoolean(prefs::kAccessibilityVirtualKeyboardEnabled)); |
2030 web_ui()->CallJavascriptFunctionUnsafe( | 2029 web_ui()->CallJavascriptFunctionUnsafe( |
2031 "BrowserOptions.setVirtualKeyboardCheckboxState", | 2030 "BrowserOptions.setVirtualKeyboardCheckboxState", |
2032 virtual_keyboard_enabled); | 2031 virtual_keyboard_enabled); |
2033 } | 2032 } |
2034 #endif | 2033 #endif |
2035 | 2034 |
2036 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { | 2035 void BrowserOptionsHandler::SetupMetricsReportingSettingVisibility() { |
2037 #if defined(GOOGLE_CHROME_BUILD) | 2036 #if defined(GOOGLE_CHROME_BUILD) |
2038 // Don't show the reporting setting if we are in the guest mode. | 2037 // Don't show the reporting setting if we are in the guest mode. |
2039 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { | 2038 if (Profile::FromWebUI(web_ui())->IsGuestSession()) { |
2040 base::FundamentalValue visible(false); | 2039 base::Value visible(false); |
2041 web_ui()->CallJavascriptFunctionUnsafe( | 2040 web_ui()->CallJavascriptFunctionUnsafe( |
2042 "BrowserOptions.setMetricsReportingSettingVisibility", visible); | 2041 "BrowserOptions.setMetricsReportingSettingVisibility", visible); |
2043 } | 2042 } |
2044 #endif | 2043 #endif |
2045 } | 2044 } |
2046 | 2045 |
2047 void BrowserOptionsHandler::SetupNetworkPredictionControl() { | 2046 void BrowserOptionsHandler::SetupNetworkPredictionControl() { |
2048 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 2047 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
2049 | 2048 |
2050 base::DictionaryValue dict; | 2049 base::DictionaryValue dict; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2125 zoom_factors_value); | 2124 zoom_factors_value); |
2126 } | 2125 } |
2127 | 2126 |
2128 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { | 2127 void BrowserOptionsHandler::SetupAutoOpenFileTypes() { |
2129 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. | 2128 // Set the hidden state for the AutoOpenFileTypesResetToDefault button. |
2130 // We show the button if the user has any auto-open file types registered. | 2129 // We show the button if the user has any auto-open file types registered. |
2131 DownloadManager* manager = BrowserContext::GetDownloadManager( | 2130 DownloadManager* manager = BrowserContext::GetDownloadManager( |
2132 web_ui()->GetWebContents()->GetBrowserContext()); | 2131 web_ui()->GetWebContents()->GetBrowserContext()); |
2133 bool display = manager && | 2132 bool display = manager && |
2134 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); | 2133 DownloadPrefs::FromDownloadManager(manager)->IsAutoOpenUsed(); |
2135 base::FundamentalValue value(display); | 2134 base::Value value(display); |
2136 web_ui()->CallJavascriptFunctionUnsafe( | 2135 web_ui()->CallJavascriptFunctionUnsafe( |
2137 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); | 2136 "BrowserOptions.setAutoOpenFileTypesDisplayed", value); |
2138 } | 2137 } |
2139 | 2138 |
2140 void BrowserOptionsHandler::SetupProxySettingsSection() { | 2139 void BrowserOptionsHandler::SetupProxySettingsSection() { |
2141 #if !defined(OS_CHROMEOS) | 2140 #if !defined(OS_CHROMEOS) |
2142 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); | 2141 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); |
2143 const PrefService::Preference* proxy_config = | 2142 const PrefService::Preference* proxy_config = |
2144 pref_service->FindPreference(proxy_config::prefs::kProxy); | 2143 pref_service->FindPreference(proxy_config::prefs::kProxy); |
2145 bool is_extension_controlled = (proxy_config && | 2144 bool is_extension_controlled = (proxy_config && |
2146 proxy_config->IsExtensionControlled()); | 2145 proxy_config->IsExtensionControlled()); |
2147 | 2146 |
2148 base::FundamentalValue disabled(proxy_config && | 2147 base::Value disabled(proxy_config && |
2149 !proxy_config->IsUserModifiable()); | 2148 !proxy_config->IsUserModifiable()); |
2150 base::FundamentalValue extension_controlled(is_extension_controlled); | 2149 base::Value extension_controlled(is_extension_controlled); |
2151 web_ui()->CallJavascriptFunctionUnsafe( | 2150 web_ui()->CallJavascriptFunctionUnsafe( |
2152 "BrowserOptions.setupProxySettingsButton", disabled, | 2151 "BrowserOptions.setupProxySettingsButton", disabled, |
2153 extension_controlled); | 2152 extension_controlled); |
2154 | 2153 |
2155 #if defined(OS_WIN) | 2154 #if defined(OS_WIN) |
2156 SetupExtensionControlledIndicators(); | 2155 SetupExtensionControlledIndicators(); |
2157 #endif // defined(OS_WIN) | 2156 #endif // defined(OS_WIN) |
2158 | 2157 |
2159 #endif // !defined(OS_CHROMEOS) | 2158 #endif // !defined(OS_CHROMEOS) |
2160 } | 2159 } |
2161 | 2160 |
2162 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { | 2161 void BrowserOptionsHandler::SetupManagingSupervisedUsers() { |
2163 bool has_users = !Profile::FromWebUI(web_ui())-> | 2162 bool has_users = !Profile::FromWebUI(web_ui())-> |
2164 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); | 2163 GetPrefs()->GetDictionary(prefs::kSupervisedUsers)->empty(); |
2165 base::FundamentalValue has_users_value(has_users); | 2164 base::Value has_users_value(has_users); |
2166 web_ui()->CallJavascriptFunctionUnsafe( | 2165 web_ui()->CallJavascriptFunctionUnsafe( |
2167 "BrowserOptions.updateManagesSupervisedUsers", has_users_value); | 2166 "BrowserOptions.updateManagesSupervisedUsers", has_users_value); |
2168 } | 2167 } |
2169 | 2168 |
2170 void BrowserOptionsHandler::SetupEasyUnlock() { | 2169 void BrowserOptionsHandler::SetupEasyUnlock() { |
2171 base::FundamentalValue is_enabled( | 2170 base::Value is_enabled( |
2172 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); | 2171 EasyUnlockService::Get(Profile::FromWebUI(web_ui()))->IsEnabled()); |
2173 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", | 2172 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.updateEasyUnlock", |
2174 is_enabled); | 2173 is_enabled); |
2175 } | 2174 } |
2176 | 2175 |
2177 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { | 2176 void BrowserOptionsHandler::SetupExtensionControlledIndicators() { |
2178 base::DictionaryValue extension_controlled; | 2177 base::DictionaryValue extension_controlled; |
2179 | 2178 |
2180 Profile* profile = Profile::FromWebUI(web_ui()); | 2179 Profile* profile = Profile::FromWebUI(web_ui()); |
2181 | 2180 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2252 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { | 2251 void BrowserOptionsHandler::NotifyUIOfMetricsReportingChange(bool enabled) { |
2253 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), | 2252 SetMetricsReportingCheckbox(enabled, IsMetricsReportingPolicyManaged(), |
2254 !IsDeviceOwnerProfile()); | 2253 !IsDeviceOwnerProfile()); |
2255 } | 2254 } |
2256 | 2255 |
2257 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, | 2256 void BrowserOptionsHandler::SetMetricsReportingCheckbox(bool checked, |
2258 bool policy_managed, | 2257 bool policy_managed, |
2259 bool owner_managed) { | 2258 bool owner_managed) { |
2260 web_ui()->CallJavascriptFunctionUnsafe( | 2259 web_ui()->CallJavascriptFunctionUnsafe( |
2261 "BrowserOptions.setMetricsReportingCheckboxState", | 2260 "BrowserOptions.setMetricsReportingCheckboxState", |
2262 base::FundamentalValue(checked), base::FundamentalValue(policy_managed), | 2261 base::Value(checked), base::Value(policy_managed), |
2263 base::FundamentalValue(owner_managed)); | 2262 base::Value(owner_managed)); |
2264 } | 2263 } |
2265 | 2264 |
2266 void BrowserOptionsHandler::SetupSafeBrowsingExtendedReporting() { | 2265 void BrowserOptionsHandler::SetupSafeBrowsingExtendedReporting() { |
2267 base::FundamentalValue is_enabled(safe_browsing::IsExtendedReportingEnabled( | 2266 base::Value is_enabled(safe_browsing::IsExtendedReportingEnabled( |
2268 *Profile::FromWebUI(web_ui())->GetPrefs())); | 2267 *Profile::FromWebUI(web_ui())->GetPrefs())); |
2269 web_ui()->CallJavascriptFunctionUnsafe( | 2268 web_ui()->CallJavascriptFunctionUnsafe( |
2270 "BrowserOptions.setExtendedReportingEnabledCheckboxState", is_enabled); | 2269 "BrowserOptions.setExtendedReportingEnabledCheckboxState", is_enabled); |
2271 } | 2270 } |
2272 | 2271 |
2273 void BrowserOptionsHandler::HandleSafeBrowsingExtendedReporting( | 2272 void BrowserOptionsHandler::HandleSafeBrowsingExtendedReporting( |
2274 const base::ListValue* args) { | 2273 const base::ListValue* args) { |
2275 bool checked; | 2274 bool checked; |
2276 if (args->GetBoolean(0, &checked)) { | 2275 if (args->GetBoolean(0, &checked)) { |
2277 safe_browsing::SetExtendedReportingPref( | 2276 safe_browsing::SetExtendedReportingPref( |
(...skipping 12 matching lines...) Expand all Loading... |
2290 | 2289 |
2291 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { | 2290 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { |
2292 #if defined(OS_CHROMEOS) | 2291 #if defined(OS_CHROMEOS) |
2293 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); | 2292 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); |
2294 #else | 2293 #else |
2295 return true; | 2294 return true; |
2296 #endif | 2295 #endif |
2297 } | 2296 } |
2298 | 2297 |
2299 } // namespace options | 2298 } // namespace options |
OLD | NEW |