OLD | NEW |
| (Empty) |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/ui/ash/system_tray_common.h" | |
6 | |
7 #include "base/logging.h" | |
8 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | |
9 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | |
10 #include "chrome/browser/profiles/profile_manager.h" | |
11 #include "chrome/browser/ui/chrome_pages.h" | |
12 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | |
13 #include "chrome/browser/ui/singleton_tabs.h" | |
14 #include "chrome/common/url_constants.h" | |
15 #include "chrome/grit/generated_resources.h" | |
16 #include "chromeos/login/login_state.h" | |
17 #include "content/public/browser/user_metrics.h" | |
18 #include "ui/base/l10n/l10n_util.h" | |
19 | |
20 using chromeos::LoginState; | |
21 | |
22 namespace { | |
23 | |
24 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; | |
25 | |
26 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | |
27 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | |
28 sub_page); | |
29 } | |
30 | |
31 } // namespace | |
32 | |
33 // static | |
34 const char SystemTrayCommon::kDisplaySettingsSubPageName[] = "display"; | |
35 const char SystemTrayCommon::kDisplayOverscanSettingsSubPageName[] = | |
36 "displayOverscan"; | |
37 | |
38 // static | |
39 void SystemTrayCommon::ShowSettings() { | |
40 ShowSettingsSubPageForActiveUser(std::string()); | |
41 } | |
42 | |
43 // static | |
44 void SystemTrayCommon::ShowDateSettings() { | |
45 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); | |
46 std::string sub_page = | |
47 std::string(chrome::kSearchSubPage) + "#" + | |
48 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | |
49 // Everybody can change the time zone (even though it is a device setting). | |
50 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | |
51 sub_page); | |
52 } | |
53 | |
54 // static | |
55 void SystemTrayCommon::ShowDisplaySettings() { | |
56 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); | |
57 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); | |
58 } | |
59 | |
60 // static | |
61 void SystemTrayCommon::ShowPowerSettings() { | |
62 content::RecordAction(base::UserMetricsAction("Tray_ShowPowerOptions")); | |
63 ShowSettingsSubPageForActiveUser(chrome::kPowerOptionsSubPage); | |
64 } | |
65 | |
66 // static | |
67 void SystemTrayCommon::ShowChromeSlow() { | |
68 chrome::ScopedTabbedBrowserDisplayer displayer( | |
69 ProfileManager::GetPrimaryUserProfile()); | |
70 chrome::ShowSlow(displayer.browser()); | |
71 } | |
72 | |
73 // static | |
74 void SystemTrayCommon::ShowIMESettings() { | |
75 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); | |
76 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); | |
77 } | |
78 | |
79 // static | |
80 void SystemTrayCommon::ShowHelp() { | |
81 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), | |
82 chrome::HELP_SOURCE_MENU); | |
83 } | |
84 | |
85 // static | |
86 void SystemTrayCommon::ShowAccessibilityHelp() { | |
87 chrome::ScopedTabbedBrowserDisplayer displayer( | |
88 ProfileManager::GetActiveUserProfile()); | |
89 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); | |
90 } | |
91 | |
92 // static | |
93 void SystemTrayCommon::ShowAccessibilitySettings() { | |
94 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); | |
95 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + | |
96 l10n_util::GetStringUTF8( | |
97 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); | |
98 ShowSettingsSubPageForActiveUser(sub_page); | |
99 } | |
100 | |
101 // static | |
102 void SystemTrayCommon::ShowPaletteHelp() { | |
103 chrome::ScopedTabbedBrowserDisplayer displayer( | |
104 ProfileManager::GetActiveUserProfile()); | |
105 chrome::ShowSingletonTab(displayer.browser(), | |
106 GURL(chrome::kChromePaletteHelpURL)); | |
107 } | |
108 | |
109 // static | |
110 void SystemTrayCommon::ShowPaletteSettings() { | |
111 content::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); | |
112 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); | |
113 } | |
114 | |
115 // static | |
116 void SystemTrayCommon::ShowPublicAccountInfo() { | |
117 chrome::ScopedTabbedBrowserDisplayer displayer( | |
118 ProfileManager::GetActiveUserProfile()); | |
119 chrome::ShowPolicy(displayer.browser()); | |
120 } | |
121 | |
122 // static | |
123 void SystemTrayCommon::ShowProxySettings() { | |
124 LoginState* login_state = LoginState::Get(); | |
125 // User is not logged in. | |
126 CHECK(!login_state->IsUserLoggedIn() || | |
127 login_state->GetLoggedInUserType() == LoginState::LOGGED_IN_USER_NONE); | |
128 chromeos::LoginDisplayHost::default_host()->OpenProxySettings(); | |
129 } | |
OLD | NEW |