OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 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/ash/system_tray_client.h" | 5 #include "chrome/browser/ui/ash/system_tray_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | |
9 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browser_process_platform_part.h" | 11 #include "chrome/browser/browser_process_platform_part.h" |
12 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | |
13 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | |
11 #include "chrome/browser/chromeos/system/system_clock.h" | 14 #include "chrome/browser/chromeos/system/system_clock.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | |
12 #include "chrome/browser/ui/ash/ash_util.h" | 16 #include "chrome/browser/ui/ash/ash_util.h" |
13 #include "chrome/browser/ui/ash/system_tray_common.h" | 17 #include "chrome/browser/ui/chrome_pages.h" |
18 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | |
19 #include "chrome/browser/ui/singleton_tabs.h" | |
20 #include "chrome/common/url_constants.h" | |
msw
2016/10/04 17:29:00
nit: remove if not used
James Cook
2016/10/04 17:54:11
Sadly, used for various k*SubPage constants, which
| |
21 #include "chrome/grit/generated_resources.h" | |
22 #include "chromeos/login/login_state.h" | |
23 #include "content/public/browser/user_metrics.h" | |
14 #include "content/public/common/mojo_shell_connection.h" | 24 #include "content/public/common/mojo_shell_connection.h" |
15 #include "services/shell/public/cpp/connector.h" | 25 #include "services/shell/public/cpp/connector.h" |
26 #include "ui/base/l10n/l10n_util.h" | |
27 | |
28 using chromeos::LoginState; | |
16 | 29 |
17 namespace { | 30 namespace { |
18 | 31 |
32 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; | |
33 | |
19 SystemTrayClient* g_instance = nullptr; | 34 SystemTrayClient* g_instance = nullptr; |
20 | 35 |
36 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | |
37 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | |
38 sub_page); | |
39 } | |
40 | |
21 } // namespace | 41 } // namespace |
22 | 42 |
43 // static | |
44 const char SystemTrayClient::kDisplaySettingsSubPageName[] = "display"; | |
45 const char SystemTrayClient::kDisplayOverscanSettingsSubPageName[] = | |
46 "displayOverscan"; | |
47 | |
23 SystemTrayClient::SystemTrayClient() { | 48 SystemTrayClient::SystemTrayClient() { |
24 // If this observes clock setting changes before ash comes up the IPCs will | 49 // If this observes clock setting changes before ash comes up the IPCs will |
25 // be queued on |system_tray_|. | 50 // be queued on |system_tray_|. |
26 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); | 51 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); |
27 | 52 |
28 DCHECK(!g_instance); | 53 DCHECK(!g_instance); |
29 g_instance = this; | 54 g_instance = this; |
30 } | 55 } |
31 | 56 |
32 SystemTrayClient::~SystemTrayClient() { | 57 SystemTrayClient::~SystemTrayClient() { |
(...skipping 27 matching lines...) Expand all Loading... | |
60 } | 85 } |
61 | 86 |
62 void SystemTrayClient::OnClientConnectionError() { | 87 void SystemTrayClient::OnClientConnectionError() { |
63 system_tray_.reset(); | 88 system_tray_.reset(); |
64 } | 89 } |
65 | 90 |
66 //////////////////////////////////////////////////////////////////////////////// | 91 //////////////////////////////////////////////////////////////////////////////// |
67 // ash::mojom::SystemTrayClient: | 92 // ash::mojom::SystemTrayClient: |
68 | 93 |
69 void SystemTrayClient::ShowSettings() { | 94 void SystemTrayClient::ShowSettings() { |
70 SystemTrayCommon::ShowSettings(); | 95 ShowSettingsSubPageForActiveUser(std::string()); |
71 } | 96 } |
72 | 97 |
73 void SystemTrayClient::ShowDateSettings() { | 98 void SystemTrayClient::ShowDateSettings() { |
74 SystemTrayCommon::ShowDateSettings(); | 99 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); |
100 std::string sub_page = | |
101 std::string(chrome::kSearchSubPage) + "#" + | |
102 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | |
103 // Everybody can change the time zone (even though it is a device setting). | |
104 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | |
105 sub_page); | |
75 } | 106 } |
76 | 107 |
77 void SystemTrayClient::ShowDisplaySettings() { | 108 void SystemTrayClient::ShowDisplaySettings() { |
78 SystemTrayCommon::ShowDisplaySettings(); | 109 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); |
110 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); | |
79 } | 111 } |
80 | 112 |
81 void SystemTrayClient::ShowPowerSettings() { | 113 void SystemTrayClient::ShowPowerSettings() { |
82 SystemTrayCommon::ShowPowerSettings(); | 114 content::RecordAction(base::UserMetricsAction("Tray_ShowPowerOptions")); |
115 ShowSettingsSubPageForActiveUser(chrome::kPowerOptionsSubPage); | |
83 } | 116 } |
84 | 117 |
85 void SystemTrayClient::ShowChromeSlow() { | 118 void SystemTrayClient::ShowChromeSlow() { |
86 SystemTrayCommon::ShowChromeSlow(); | 119 chrome::ScopedTabbedBrowserDisplayer displayer( |
120 ProfileManager::GetPrimaryUserProfile()); | |
121 chrome::ShowSlow(displayer.browser()); | |
87 } | 122 } |
88 | 123 |
89 void SystemTrayClient::ShowIMESettings() { | 124 void SystemTrayClient::ShowIMESettings() { |
90 SystemTrayCommon::ShowIMESettings(); | 125 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); |
126 ShowSettingsSubPageForActiveUser(chrome::kLanguageOptionsSubPage); | |
91 } | 127 } |
92 | 128 |
93 void SystemTrayClient::ShowHelp() { | 129 void SystemTrayClient::ShowHelp() { |
94 SystemTrayCommon::ShowHelp(); | 130 chrome::ShowHelpForProfile(ProfileManager::GetActiveUserProfile(), |
131 chrome::HELP_SOURCE_MENU); | |
95 } | 132 } |
96 | 133 |
97 void SystemTrayClient::ShowAccessibilityHelp() { | 134 void SystemTrayClient::ShowAccessibilityHelp() { |
98 SystemTrayCommon::ShowAccessibilityHelp(); | 135 chrome::ScopedTabbedBrowserDisplayer displayer( |
136 ProfileManager::GetActiveUserProfile()); | |
137 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); | |
99 } | 138 } |
100 | 139 |
101 void SystemTrayClient::ShowAccessibilitySettings() { | 140 void SystemTrayClient::ShowAccessibilitySettings() { |
102 SystemTrayCommon::ShowAccessibilitySettings(); | 141 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); |
142 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + | |
143 l10n_util::GetStringUTF8( | |
144 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); | |
145 ShowSettingsSubPageForActiveUser(sub_page); | |
103 } | 146 } |
104 | 147 |
105 void SystemTrayClient::ShowPaletteHelp() { | 148 void SystemTrayClient::ShowPaletteHelp() { |
106 SystemTrayCommon::ShowPaletteHelp(); | 149 chrome::ScopedTabbedBrowserDisplayer displayer( |
150 ProfileManager::GetActiveUserProfile()); | |
151 chrome::ShowSingletonTab(displayer.browser(), | |
152 GURL(chrome::kChromePaletteHelpURL)); | |
107 } | 153 } |
108 | 154 |
109 void SystemTrayClient::ShowPaletteSettings() { | 155 void SystemTrayClient::ShowPaletteSettings() { |
110 SystemTrayCommon::ShowPaletteSettings(); | 156 content::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); |
157 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); | |
111 } | 158 } |
112 | 159 |
113 void SystemTrayClient::ShowPublicAccountInfo() { | 160 void SystemTrayClient::ShowPublicAccountInfo() { |
114 SystemTrayCommon::ShowPublicAccountInfo(); | 161 chrome::ScopedTabbedBrowserDisplayer displayer( |
162 ProfileManager::GetActiveUserProfile()); | |
163 chrome::ShowPolicy(displayer.browser()); | |
115 } | 164 } |
116 | 165 |
117 void SystemTrayClient::ShowProxySettings() { | 166 void SystemTrayClient::ShowProxySettings() { |
118 SystemTrayCommon::ShowProxySettings(); | 167 LoginState* login_state = LoginState::Get(); |
168 // User is not logged in. | |
169 CHECK(!login_state->IsUserLoggedIn() || | |
170 login_state->GetLoggedInUserType() == LoginState::LOGGED_IN_USER_NONE); | |
171 chromeos::LoginDisplayHost::default_host()->OpenProxySettings(); | |
119 } | 172 } |
120 | 173 |
121 //////////////////////////////////////////////////////////////////////////////// | 174 //////////////////////////////////////////////////////////////////////////////// |
122 // chromeos::system::SystemClockObserver: | 175 // chromeos::system::SystemClockObserver: |
123 | 176 |
124 void SystemTrayClient::OnSystemClockChanged( | 177 void SystemTrayClient::OnSystemClockChanged( |
125 chromeos::system::SystemClock* clock) { | 178 chromeos::system::SystemClock* clock) { |
126 ConnectToSystemTray(); | 179 ConnectToSystemTray(); |
127 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 180 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
128 } | 181 } |
OLD | NEW |