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 "ash/common/login_status.h" | 7 #include "ash/common/login_status.h" |
8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
9 #include "ash/public/cpp/shell_window_ids.h" | 9 #include "ash/public/cpp/shell_window_ids.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
| 11 #include "base/feature_list.h" |
11 #include "base/logging.h" | 12 #include "base/logging.h" |
12 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
13 #include "chrome/browser/browser_process_platform_part.h" | 14 #include "chrome/browser/browser_process_platform_part.h" |
14 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
17 #include "chrome/browser/chromeos/options/network_config_view.h" | 18 #include "chrome/browser/chromeos/options/network_config_view.h" |
18 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 19 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
19 #include "chrome/browser/chromeos/set_time_dialog.h" | 20 #include "chrome/browser/chromeos/set_time_dialog.h" |
20 #include "chrome/browser/chromeos/system/system_clock.h" | 21 #include "chrome/browser/chromeos/system/system_clock.h" |
21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 22 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
22 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
23 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
24 #include "chrome/browser/ui/ash/ash_util.h" | 25 #include "chrome/browser/ui/ash/ash_util.h" |
25 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 26 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
26 #include "chrome/browser/ui/chrome_pages.h" | 27 #include "chrome/browser/ui/chrome_pages.h" |
27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
28 #include "chrome/browser/ui/singleton_tabs.h" | 29 #include "chrome/browser/ui/singleton_tabs.h" |
29 #include "chrome/browser/upgrade_detector.h" | 30 #include "chrome/browser/upgrade_detector.h" |
| 31 #include "chrome/common/chrome_features.h" |
30 #include "chrome/common/url_constants.h" | 32 #include "chrome/common/url_constants.h" |
31 #include "chromeos/dbus/dbus_thread_manager.h" | 33 #include "chromeos/dbus/dbus_thread_manager.h" |
32 #include "chromeos/dbus/session_manager_client.h" | 34 #include "chromeos/dbus/session_manager_client.h" |
33 #include "chromeos/login/login_state.h" | 35 #include "chromeos/login/login_state.h" |
34 #include "components/session_manager/core/session_manager.h" | 36 #include "components/session_manager/core/session_manager.h" |
35 #include "components/user_manager/user_manager.h" | 37 #include "components/user_manager/user_manager.h" |
36 #include "content/public/browser/notification_service.h" | 38 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
38 #include "content/public/common/service_manager_connection.h" | 40 #include "content/public/common/service_manager_connection.h" |
39 #include "extensions/browser/api/vpn_provider/vpn_service.h" | 41 #include "extensions/browser/api/vpn_provider/vpn_service.h" |
40 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" | 42 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" |
41 #include "net/base/escape.h" | 43 #include "net/base/escape.h" |
42 #include "services/service_manager/public/cpp/connector.h" | 44 #include "services/service_manager/public/cpp/connector.h" |
43 #include "services/ui/public/cpp/property_type_converters.h" | 45 #include "services/ui/public/cpp/property_type_converters.h" |
44 #include "services/ui/public/interfaces/window_manager.mojom.h" | 46 #include "services/ui/public/interfaces/window_manager.mojom.h" |
45 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" | 47 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" |
46 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
47 #include "ui/views/window/dialog_delegate.h" | 49 #include "ui/views/window/dialog_delegate.h" |
48 | 50 |
49 using chromeos::DBusThreadManager; | 51 using chromeos::DBusThreadManager; |
50 using chromeos::LoginState; | 52 using chromeos::LoginState; |
51 using views::Widget; | 53 using views::Widget; |
52 | 54 |
53 namespace { | 55 namespace { |
54 | 56 |
55 const char kDisplaySettingsSubPageName[] = "display"; | |
56 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; | |
57 | |
58 SystemTrayClient* g_instance = nullptr; | 57 SystemTrayClient* g_instance = nullptr; |
59 | 58 |
60 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | 59 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { |
61 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 60 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
62 sub_page); | 61 sub_page); |
63 } | 62 } |
64 | 63 |
65 // Returns the severity of a pending Chrome / Chrome OS update. | 64 // Returns the severity of a pending Chrome / Chrome OS update. |
66 ash::mojom::UpdateSeverity GetUpdateSeverity(UpgradeDetector* detector) { | 65 ash::mojom::UpdateSeverity GetUpdateSeverity(UpgradeDetector* detector) { |
67 switch (detector->upgrade_notification_stage()) { | 66 switch (detector->upgrade_notification_stage()) { |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 218 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
220 chrome::kDateTimeSubPage); | 219 chrome::kDateTimeSubPage); |
221 } | 220 } |
222 | 221 |
223 void SystemTrayClient::ShowSetTimeDialog() { | 222 void SystemTrayClient::ShowSetTimeDialog() { |
224 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); | 223 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); |
225 } | 224 } |
226 | 225 |
227 void SystemTrayClient::ShowDisplaySettings() { | 226 void SystemTrayClient::ShowDisplaySettings() { |
228 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); | 227 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); |
229 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); | 228 ShowSettingsSubPageForActiveUser(chrome::kDisplaySubPage); |
230 } | 229 } |
231 | 230 |
232 void SystemTrayClient::ShowPowerSettings() { | 231 void SystemTrayClient::ShowPowerSettings() { |
233 content::RecordAction(base::UserMetricsAction("Tray_ShowPowerOptions")); | 232 content::RecordAction(base::UserMetricsAction("Tray_ShowPowerOptions")); |
234 ShowSettingsSubPageForActiveUser(chrome::kPowerOptionsSubPage); | 233 ShowSettingsSubPageForActiveUser(chrome::kPowerSubPage); |
235 } | 234 } |
236 | 235 |
237 void SystemTrayClient::ShowChromeSlow() { | 236 void SystemTrayClient::ShowChromeSlow() { |
238 chrome::ScopedTabbedBrowserDisplayer displayer( | 237 chrome::ScopedTabbedBrowserDisplayer displayer( |
239 ProfileManager::GetPrimaryUserProfile()); | 238 ProfileManager::GetPrimaryUserProfile()); |
240 chrome::ShowSlow(displayer.browser()); | 239 chrome::ShowSlow(displayer.browser()); |
241 } | 240 } |
242 | 241 |
243 void SystemTrayClient::ShowIMESettings() { | 242 void SystemTrayClient::ShowIMESettings() { |
244 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); | 243 content::RecordAction(base::UserMetricsAction("OpenLanguageOptionsDialog")); |
(...skipping 18 matching lines...) Expand all Loading... |
263 | 262 |
264 void SystemTrayClient::ShowPaletteHelp() { | 263 void SystemTrayClient::ShowPaletteHelp() { |
265 chrome::ScopedTabbedBrowserDisplayer displayer( | 264 chrome::ScopedTabbedBrowserDisplayer displayer( |
266 ProfileManager::GetActiveUserProfile()); | 265 ProfileManager::GetActiveUserProfile()); |
267 chrome::ShowSingletonTab(displayer.browser(), | 266 chrome::ShowSingletonTab(displayer.browser(), |
268 GURL(chrome::kChromePaletteHelpURL)); | 267 GURL(chrome::kChromePaletteHelpURL)); |
269 } | 268 } |
270 | 269 |
271 void SystemTrayClient::ShowPaletteSettings() { | 270 void SystemTrayClient::ShowPaletteSettings() { |
272 content::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); | 271 content::RecordAction(base::UserMetricsAction("ShowPaletteOptions")); |
273 ShowSettingsSubPageForActiveUser(kPaletteSettingsSubPageName); | 272 ShowSettingsSubPageForActiveUser(chrome::kStylusSubPage); |
274 } | 273 } |
275 | 274 |
276 void SystemTrayClient::ShowPublicAccountInfo() { | 275 void SystemTrayClient::ShowPublicAccountInfo() { |
277 chrome::ScopedTabbedBrowserDisplayer displayer( | 276 chrome::ScopedTabbedBrowserDisplayer displayer( |
278 ProfileManager::GetActiveUserProfile()); | 277 ProfileManager::GetActiveUserProfile()); |
279 chrome::ShowPolicy(displayer.browser()); | 278 chrome::ShowPolicy(displayer.browser()); |
280 } | 279 } |
281 | 280 |
282 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { | 281 void SystemTrayClient::ShowNetworkConfigure(const std::string& network_id) { |
283 // UI is not available at the lock screen. | 282 // UI is not available at the lock screen. |
(...skipping 30 matching lines...) Expand all Loading... |
314 chromeos::VpnServiceFactory::GetForBrowserContext(profile) | 313 chromeos::VpnServiceFactory::GetForBrowserContext(profile) |
315 ->SendShowAddDialogToExtension(extension_id); | 314 ->SendShowAddDialogToExtension(extension_id); |
316 } | 315 } |
317 | 316 |
318 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { | 317 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { |
319 if (!LoginState::Get()->IsUserLoggedIn() || | 318 if (!LoginState::Get()->IsUserLoggedIn() || |
320 session_manager::SessionManager::Get()->IsInSecondaryLoginScreen()) { | 319 session_manager::SessionManager::Get()->IsInSecondaryLoginScreen()) { |
321 return; | 320 return; |
322 } | 321 } |
323 | 322 |
324 std::string page = chrome::kInternetOptionsSubPage; | 323 std::string page = chrome::kInternetSubPage; |
325 if (!network_id.empty()) | 324 if (!network_id.empty()) { |
| 325 if (base::FeatureList::IsEnabled(features::kMaterialDesignSettings)) |
| 326 page = chrome::kNetworkDetailSubPage; |
326 page += "?guid=" + net::EscapeUrlEncodedData(network_id, true); | 327 page += "?guid=" + net::EscapeUrlEncodedData(network_id, true); |
| 328 } |
327 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); | 329 content::RecordAction(base::UserMetricsAction("OpenInternetOptionsDialog")); |
328 ShowSettingsSubPageForActiveUser(page); | 330 ShowSettingsSubPageForActiveUser(page); |
329 } | 331 } |
330 | 332 |
331 void SystemTrayClient::ShowProxySettings() { | 333 void SystemTrayClient::ShowProxySettings() { |
332 LoginState* login_state = LoginState::Get(); | 334 LoginState* login_state = LoginState::Get(); |
333 // User is not logged in. | 335 // User is not logged in. |
334 CHECK(!login_state->IsUserLoggedIn() || | 336 CHECK(!login_state->IsUserLoggedIn() || |
335 login_state->GetLoggedInUserType() == LoginState::LOGGED_IN_USER_NONE); | 337 login_state->GetLoggedInUserType() == LoginState::LOGGED_IN_USER_NONE); |
336 chromeos::LoginDisplayHost::default_host()->OpenProxySettings(); | 338 chromeos::LoginDisplayHost::default_host()->OpenProxySettings(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 chromeos::system::SystemClock* clock) { | 373 chromeos::system::SystemClock* clock) { |
372 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 374 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
373 } | 375 } |
374 | 376 |
375 void SystemTrayClient::Observe(int type, | 377 void SystemTrayClient::Observe(int type, |
376 const content::NotificationSource& source, | 378 const content::NotificationSource& source, |
377 const content::NotificationDetails& details) { | 379 const content::NotificationDetails& details) { |
378 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 380 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); |
379 HandleUpdateAvailable(); | 381 HandleUpdateAvailable(); |
380 } | 382 } |
OLD | NEW |