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

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

Issue 2771233002: Remove the wrapper functions content::RecordAction et al (Closed)
Patch Set: Rebased Created 3 years, 9 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 #include <utility> 10 #include <utility>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/bind_helpers.h" 13 #include "base/bind_helpers.h"
14 #include "base/command_line.h" 14 #include "base/command_line.h"
15 #include "base/environment.h" 15 #include "base/environment.h"
16 #include "base/i18n/number_formatting.h" 16 #include "base/i18n/number_formatting.h"
17 #include "base/macros.h" 17 #include "base/macros.h"
18 #include "base/memory/singleton.h" 18 #include "base/memory/singleton.h"
19 #include "base/metrics/field_trial.h" 19 #include "base/metrics/field_trial.h"
20 #include "base/metrics/histogram_macros.h" 20 #include "base/metrics/histogram_macros.h"
21 #include "base/metrics/user_metrics.h"
21 #include "base/stl_util.h" 22 #include "base/stl_util.h"
22 #include "base/strings/string_number_conversions.h" 23 #include "base/strings/string_number_conversions.h"
23 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
24 #include "base/value_conversions.h" 25 #include "base/value_conversions.h"
25 #include "base/values.h" 26 #include "base/values.h"
26 #include "build/build_config.h" 27 #include "build/build_config.h"
27 #include "chrome/browser/browser_process.h" 28 #include "chrome/browser/browser_process.h"
28 #include "chrome/browser/chrome_notification_types.h" 29 #include "chrome/browser/chrome_notification_types.h"
29 #include "chrome/browser/custom_home_pages_table_model.h" 30 #include "chrome/browser/custom_home_pages_table_model.h"
30 #include "chrome/browser/download/download_prefs.h" 31 #include "chrome/browser/download/download_prefs.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 #include "components/zoom/page_zoom.h" 95 #include "components/zoom/page_zoom.h"
95 #include "content/public/browser/browser_thread.h" 96 #include "content/public/browser/browser_thread.h"
96 #include "content/public/browser/browser_url_handler.h" 97 #include "content/public/browser/browser_url_handler.h"
97 #include "content/public/browser/download_manager.h" 98 #include "content/public/browser/download_manager.h"
98 #include "content/public/browser/navigation_controller.h" 99 #include "content/public/browser/navigation_controller.h"
99 #include "content/public/browser/notification_details.h" 100 #include "content/public/browser/notification_details.h"
100 #include "content/public/browser/notification_service.h" 101 #include "content/public/browser/notification_service.h"
101 #include "content/public/browser/notification_source.h" 102 #include "content/public/browser/notification_source.h"
102 #include "content/public/browser/notification_types.h" 103 #include "content/public/browser/notification_types.h"
103 #include "content/public/browser/url_data_source.h" 104 #include "content/public/browser/url_data_source.h"
104 #include "content/public/browser/user_metrics.h"
105 #include "content/public/browser/web_contents.h" 105 #include "content/public/browser/web_contents.h"
106 #include "content/public/common/page_zoom.h" 106 #include "content/public/common/page_zoom.h"
107 #include "extensions/browser/extension_registry.h" 107 #include "extensions/browser/extension_registry.h"
108 #include "google_apis/gaia/gaia_auth_util.h" 108 #include "google_apis/gaia/gaia_auth_util.h"
109 #include "google_apis/gaia/google_service_auth_error.h" 109 #include "google_apis/gaia/google_service_auth_error.h"
110 #include "printing/features/features.h" 110 #include "printing/features/features.h"
111 #include "third_party/skia/include/core/SkBitmap.h" 111 #include "third_party/skia/include/core/SkBitmap.h"
112 #include "ui/base/l10n/l10n_util.h" 112 #include "ui/base/l10n/l10n_util.h"
113 #include "ui/base/webui/web_ui_util.h" 113 #include "ui/base/webui/web_ui_util.h"
114 114
(...skipping 1157 matching lines...) Expand 10 before | Expand all | Expand 10 after
1272 void BrowserOptionsHandler::UpdateDefaultBrowserState() { 1272 void BrowserOptionsHandler::UpdateDefaultBrowserState() {
1273 default_browser_worker_->StartCheckIsDefault(); 1273 default_browser_worker_->StartCheckIsDefault();
1274 } 1274 }
1275 1275
1276 void BrowserOptionsHandler::BecomeDefaultBrowser(const base::ListValue* args) { 1276 void BrowserOptionsHandler::BecomeDefaultBrowser(const base::ListValue* args) {
1277 // If the default browser setting is managed then we should not be able to 1277 // If the default browser setting is managed then we should not be able to
1278 // call this function. 1278 // call this function.
1279 if (IsDisabledByPolicy(default_browser_policy_)) 1279 if (IsDisabledByPolicy(default_browser_policy_))
1280 return; 1280 return;
1281 1281
1282 content::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser")); 1282 base::RecordAction(UserMetricsAction("Options_SetAsDefaultBrowser"));
1283 UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true); 1283 UMA_HISTOGRAM_COUNTS("Settings.StartSetAsDefault", true);
1284 1284
1285 // Callback takes care of updating UI. 1285 // Callback takes care of updating UI.
1286 default_browser_worker_->StartSetAsDefault(); 1286 default_browser_worker_->StartSetAsDefault();
1287 1287
1288 // If the user attempted to make Chrome the default browser, notify 1288 // If the user attempted to make Chrome the default browser, notify
1289 // them when this changes. 1289 // them when this changes.
1290 chrome::ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui())); 1290 chrome::ResetDefaultBrowserPrompt(Profile::FromWebUI(web_ui()));
1291 } 1291 }
1292 1292
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 return; 1377 return;
1378 } 1378 }
1379 1379
1380 TemplateURLService::TemplateURLVector model_urls( 1380 TemplateURLService::TemplateURLVector model_urls(
1381 template_url_service_->GetTemplateURLs()); 1381 template_url_service_->GetTemplateURLs());
1382 if (selected_index >= 0 && 1382 if (selected_index >= 0 &&
1383 selected_index < static_cast<int>(model_urls.size())) 1383 selected_index < static_cast<int>(model_urls.size()))
1384 template_url_service_->SetUserSelectedDefaultSearchProvider( 1384 template_url_service_->SetUserSelectedDefaultSearchProvider(
1385 model_urls[selected_index]); 1385 model_urls[selected_index]);
1386 1386
1387 content::RecordAction(UserMetricsAction("Options_SearchEngineChanged")); 1387 base::RecordAction(UserMetricsAction("Options_SearchEngineChanged"));
1388 } 1388 }
1389 1389
1390 void BrowserOptionsHandler::AddTemplateUrlServiceObserver() { 1390 void BrowserOptionsHandler::AddTemplateUrlServiceObserver() {
1391 template_url_service_ = 1391 template_url_service_ =
1392 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui())); 1392 TemplateURLServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()));
1393 if (template_url_service_) { 1393 if (template_url_service_) {
1394 template_url_service_->Load(); 1394 template_url_service_->Load();
1395 template_url_service_->AddObserver(this); 1395 template_url_service_->AddObserver(this);
1396 } 1396 }
1397 } 1397 }
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 1534
1535 bool is_classic_theme = !is_system_theme && 1535 bool is_classic_theme = !is_system_theme &&
1536 theme_service->UsingDefaultTheme(); 1536 theme_service->UsingDefaultTheme();
1537 base::Value enabled(!is_classic_theme); 1537 base::Value enabled(!is_classic_theme);
1538 web_ui()->CallJavascriptFunctionUnsafe( 1538 web_ui()->CallJavascriptFunctionUnsafe(
1539 "BrowserOptions.setThemesResetButtonEnabled", enabled); 1539 "BrowserOptions.setThemesResetButtonEnabled", enabled);
1540 } 1540 }
1541 1541
1542 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) { 1542 void BrowserOptionsHandler::ThemesReset(const base::ListValue* args) {
1543 Profile* profile = Profile::FromWebUI(web_ui()); 1543 Profile* profile = Profile::FromWebUI(web_ui());
1544 content::RecordAction(UserMetricsAction("Options_ThemesReset")); 1544 base::RecordAction(UserMetricsAction("Options_ThemesReset"));
1545 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme(); 1545 ThemeServiceFactory::GetForProfile(profile)->UseDefaultTheme();
1546 } 1546 }
1547 1547
1548 #if defined(OS_LINUX) && !defined(OS_CHROMEOS) 1548 #if defined(OS_LINUX) && !defined(OS_CHROMEOS)
1549 void BrowserOptionsHandler::ThemesSetNative(const base::ListValue* args) { 1549 void BrowserOptionsHandler::ThemesSetNative(const base::ListValue* args) {
1550 content::RecordAction(UserMetricsAction("Options_GtkThemeSet")); 1550 base::RecordAction(UserMetricsAction("Options_GtkThemeSet"));
1551 Profile* profile = Profile::FromWebUI(web_ui()); 1551 Profile* profile = Profile::FromWebUI(web_ui());
1552 ThemeServiceFactory::GetForProfile(profile)->UseSystemTheme(); 1552 ThemeServiceFactory::GetForProfile(profile)->UseSystemTheme();
1553 } 1553 }
1554 #endif 1554 #endif
1555 1555
1556 #if defined(OS_CHROMEOS) 1556 #if defined(OS_CHROMEOS)
1557 void BrowserOptionsHandler::UpdateAccountPicture() { 1557 void BrowserOptionsHandler::UpdateAccountPicture() {
1558 std::string email = user_manager::UserManager::Get() 1558 std::string email = user_manager::UserManager::Get()
1559 ->GetActiveUser() 1559 ->GetActiveUser()
1560 ->GetAccountId() 1560 ->GetAccountId()
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1676 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory), 1676 pref_service->GetFilePath(prefs::kDownloadDefaultDirectory),
1677 &info, 1677 &info,
1678 0, 1678 0,
1679 base::FilePath::StringType(), 1679 base::FilePath::StringType(),
1680 web_ui()->GetWebContents()->GetTopLevelNativeWindow(), 1680 web_ui()->GetWebContents()->GetTopLevelNativeWindow(),
1681 NULL); 1681 NULL);
1682 } 1682 }
1683 1683
1684 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index, 1684 void BrowserOptionsHandler::FileSelected(const base::FilePath& path, int index,
1685 void* params) { 1685 void* params) {
1686 content::RecordAction(UserMetricsAction("Options_SetDownloadDirectory")); 1686 base::RecordAction(UserMetricsAction("Options_SetDownloadDirectory"));
1687 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs(); 1687 PrefService* pref_service = Profile::FromWebUI(web_ui())->GetPrefs();
1688 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path); 1688 pref_service->SetFilePath(prefs::kDownloadDefaultDirectory, path);
1689 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path); 1689 pref_service->SetFilePath(prefs::kSaveFileDefaultDirectory, path);
1690 } 1690 }
1691 1691
1692 #if defined(OS_CHROMEOS) 1692 #if defined(OS_CHROMEOS)
1693 void BrowserOptionsHandler::TouchpadExists(bool exists) { 1693 void BrowserOptionsHandler::TouchpadExists(bool exists) {
1694 base::Value val(exists); 1694 base::Value val(exists);
1695 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls", 1695 web_ui()->CallJavascriptFunctionUnsafe("BrowserOptions.showTouchpadControls",
1696 val); 1696 val);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 web_ui()->CallJavascriptFunctionUnsafe( 1739 web_ui()->CallJavascriptFunctionUnsafe(
1740 "BrowserOptions.setAllHotwordSectionsVisible", base::Value(false)); 1740 "BrowserOptions.setAllHotwordSectionsVisible", base::Value(false));
1741 HandleRequestHotwordAvailable(nullptr); 1741 HandleRequestHotwordAvailable(nullptr);
1742 } 1742 }
1743 1743
1744 void BrowserOptionsHandler::OnSigninAllowedPrefChange() { 1744 void BrowserOptionsHandler::OnSigninAllowedPrefChange() {
1745 UpdateSyncState(); 1745 UpdateSyncState();
1746 } 1746 }
1747 1747
1748 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) { 1748 void BrowserOptionsHandler::HandleAutoOpenButton(const base::ListValue* args) {
1749 content::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles")); 1749 base::RecordAction(UserMetricsAction("Options_ResetAutoOpenFiles"));
1750 DownloadManager* manager = BrowserContext::GetDownloadManager( 1750 DownloadManager* manager = BrowserContext::GetDownloadManager(
1751 web_ui()->GetWebContents()->GetBrowserContext()); 1751 web_ui()->GetWebContents()->GetBrowserContext());
1752 if (manager) 1752 if (manager)
1753 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen(); 1753 DownloadPrefs::FromDownloadManager(manager)->ResetAutoOpen();
1754 } 1754 }
1755 1755
1756 void BrowserOptionsHandler::HandleDefaultFontSize(const base::ListValue* args) { 1756 void BrowserOptionsHandler::HandleDefaultFontSize(const base::ListValue* args) {
1757 int font_size; 1757 int font_size;
1758 if (ExtractIntegerValue(args, &font_size)) { 1758 if (ExtractIntegerValue(args, &font_size)) {
1759 if (font_size > 0) { 1759 if (font_size > 0) {
(...skipping 21 matching lines...) Expand all
1781 } 1781 }
1782 1782
1783 void BrowserOptionsHandler::HandleRequestProfilesInfo( 1783 void BrowserOptionsHandler::HandleRequestProfilesInfo(
1784 const base::ListValue* args) { 1784 const base::ListValue* args) {
1785 SendProfilesInfo(); 1785 SendProfilesInfo();
1786 } 1786 }
1787 1787
1788 #if !defined(OS_CHROMEOS) 1788 #if !defined(OS_CHROMEOS)
1789 void BrowserOptionsHandler::ShowNetworkProxySettings( 1789 void BrowserOptionsHandler::ShowNetworkProxySettings(
1790 const base::ListValue* args) { 1790 const base::ListValue* args) {
1791 content::RecordAction(UserMetricsAction("Options_ShowProxySettings")); 1791 base::RecordAction(UserMetricsAction("Options_ShowProxySettings"));
1792 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents()); 1792 settings_utils::ShowNetworkProxySettings(web_ui()->GetWebContents());
1793 } 1793 }
1794 #endif 1794 #endif
1795 1795
1796 #if defined(OS_WIN) || defined(OS_MACOSX) 1796 #if defined(OS_WIN) || defined(OS_MACOSX)
1797 void BrowserOptionsHandler::ShowManageSSLCertificates( 1797 void BrowserOptionsHandler::ShowManageSSLCertificates(
1798 const base::ListValue* args) { 1798 const base::ListValue* args) {
1799 content::RecordAction(UserMetricsAction("Options_ManageSSLCertificates")); 1799 base::RecordAction(UserMetricsAction("Options_ManageSSLCertificates"));
1800 settings_utils::ShowManageSSLCertificates(web_ui()->GetWebContents()); 1800 settings_utils::ShowManageSSLCertificates(web_ui()->GetWebContents());
1801 } 1801 }
1802 #endif 1802 #endif
1803 1803
1804 #if defined(OS_CHROMEOS) 1804 #if defined(OS_CHROMEOS)
1805 void BrowserOptionsHandler::ShowCupsPrintDevicesPage( 1805 void BrowserOptionsHandler::ShowCupsPrintDevicesPage(
1806 const base::ListValue* args) { 1806 const base::ListValue* args) {
1807 // Navigate in current tab to CUPS printers management page. 1807 // Navigate in current tab to CUPS printers management page.
1808 OpenURLParams params(GURL(chrome::kChromeUIMdCupsSettingsURL), Referrer(), 1808 OpenURLParams params(GURL(chrome::kChromeUIMdCupsSettingsURL), Referrer(),
1809 WindowOpenDisposition::NEW_FOREGROUND_TAB, 1809 WindowOpenDisposition::NEW_FOREGROUND_TAB,
1810 ui::PAGE_TRANSITION_LINK, false); 1810 ui::PAGE_TRANSITION_LINK, false);
1811 web_ui()->GetWebContents()->OpenURL(params); 1811 web_ui()->GetWebContents()->OpenURL(params);
1812 } 1812 }
1813 #endif // defined(OS_CHROMEOS) 1813 #endif // defined(OS_CHROMEOS)
1814 1814
1815 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY) 1815 #if BUILDFLAG(ENABLE_SERVICE_DISCOVERY)
1816 void BrowserOptionsHandler::ShowCloudPrintDevicesPage( 1816 void BrowserOptionsHandler::ShowCloudPrintDevicesPage(
1817 const base::ListValue* args) { 1817 const base::ListValue* args) {
1818 content::RecordAction(UserMetricsAction("Options_CloudPrintDevicesPage")); 1818 base::RecordAction(UserMetricsAction("Options_CloudPrintDevicesPage"));
1819 // Navigate in current tab to devices page. 1819 // Navigate in current tab to devices page.
1820 OpenURLParams params(GURL(chrome::kChromeUIDevicesURL), Referrer(), 1820 OpenURLParams params(GURL(chrome::kChromeUIDevicesURL), Referrer(),
1821 WindowOpenDisposition::CURRENT_TAB, 1821 WindowOpenDisposition::CURRENT_TAB,
1822 ui::PAGE_TRANSITION_LINK, false); 1822 ui::PAGE_TRANSITION_LINK, false);
1823 web_ui()->GetWebContents()->OpenURL(params); 1823 web_ui()->GetWebContents()->OpenURL(params);
1824 } 1824 }
1825 #endif 1825 #endif
1826 1826
1827 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible( 1827 void BrowserOptionsHandler::SetHotwordAudioHistorySectionVisible(
1828 const base::string16& audio_history_state, 1828 const base::string16& audio_history_state,
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 2364
2365 bool BrowserOptionsHandler::IsDeviceOwnerProfile() { 2365 bool BrowserOptionsHandler::IsDeviceOwnerProfile() {
2366 #if defined(OS_CHROMEOS) 2366 #if defined(OS_CHROMEOS)
2367 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui())); 2367 return chromeos::ProfileHelper::IsOwnerProfile(Profile::FromWebUI(web_ui()));
2368 #else 2368 #else
2369 return true; 2369 return true;
2370 #endif 2370 #endif
2371 } 2371 }
2372 2372
2373 } // namespace options 2373 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698