Chromium Code Reviews| 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/public/interfaces/constants.mojom.h" | 10 #include "ash/public/interfaces/constants.mojom.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "base/feature_list.h" | 12 #include "base/feature_list.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/metrics/user_metrics.h" | |
| 14 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_process_platform_part.h" | 16 #include "chrome/browser/browser_process_platform_part.h" |
| 16 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 18 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 19 #include "chrome/browser/chromeos/bluetooth/bluetooth_pairing_dialog.h" | |
| 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 20 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 19 #include "chrome/browser/chromeos/options/network_config_view.h" | 21 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 21 #include "chrome/browser/chromeos/set_time_dialog.h" | 23 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 22 #include "chrome/browser/chromeos/system/system_clock.h" | 24 #include "chrome/browser/chromeos/system/system_clock.h" |
| 23 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 25 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 24 #include "chrome/browser/lifetime/application_lifetime.h" | 26 #include "chrome/browser/lifetime/application_lifetime.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 27 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/ash/ash_util.h" | 28 #include "chrome/browser/ui/ash/ash_util.h" |
| 27 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" | 29 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" |
| 28 #include "chrome/browser/ui/chrome_pages.h" | 30 #include "chrome/browser/ui/chrome_pages.h" |
| 29 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 31 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 30 #include "chrome/browser/ui/singleton_tabs.h" | 32 #include "chrome/browser/ui/singleton_tabs.h" |
| 31 #include "chrome/browser/upgrade_detector.h" | 33 #include "chrome/browser/upgrade_detector.h" |
| 32 #include "chrome/common/chrome_features.h" | 34 #include "chrome/common/chrome_features.h" |
| 33 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 34 #include "chromeos/dbus/dbus_thread_manager.h" | 36 #include "chromeos/dbus/dbus_thread_manager.h" |
| 35 #include "chromeos/dbus/session_manager_client.h" | 37 #include "chromeos/dbus/session_manager_client.h" |
| 36 #include "chromeos/login/login_state.h" | 38 #include "chromeos/login/login_state.h" |
| 37 #include "components/session_manager/core/session_manager.h" | 39 #include "components/session_manager/core/session_manager.h" |
| 38 #include "components/user_manager/user_manager.h" | 40 #include "components/user_manager/user_manager.h" |
| 39 #include "content/public/browser/notification_service.h" | 41 #include "content/public/browser/notification_service.h" |
| 40 #include "content/public/browser/user_metrics.h" | 42 #include "content/public/browser/user_metrics.h" |
| 41 #include "content/public/common/service_manager_connection.h" | 43 #include "content/public/common/service_manager_connection.h" |
| 44 #include "device/bluetooth/bluetooth_device.h" | |
| 42 #include "extensions/browser/api/vpn_provider/vpn_service.h" | 45 #include "extensions/browser/api/vpn_provider/vpn_service.h" |
| 43 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" | 46 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" |
| 44 #include "net/base/escape.h" | 47 #include "net/base/escape.h" |
| 45 #include "services/service_manager/public/cpp/connector.h" | 48 #include "services/service_manager/public/cpp/connector.h" |
| 46 #include "services/ui/public/cpp/property_type_converters.h" | 49 #include "services/ui/public/cpp/property_type_converters.h" |
| 47 #include "services/ui/public/interfaces/window_manager.mojom.h" | 50 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 48 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" | 51 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" |
| 49 #include "ui/views/widget/widget.h" | 52 #include "ui/views/widget/widget.h" |
| 50 #include "ui/views/window/dialog_delegate.h" | 53 #include "ui/views/window/dialog_delegate.h" |
| 51 | 54 |
| 55 using chromeos::BluetoothPairingDialog; | |
| 52 using chromeos::DBusThreadManager; | 56 using chromeos::DBusThreadManager; |
| 53 using chromeos::LoginState; | 57 using chromeos::LoginState; |
| 58 using device::BluetoothDevice; | |
| 54 using views::Widget; | 59 using views::Widget; |
| 55 | 60 |
| 56 namespace { | 61 namespace { |
| 57 | 62 |
| 58 SystemTrayClient* g_instance = nullptr; | 63 SystemTrayClient* g_instance = nullptr; |
| 59 | 64 |
| 60 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | 65 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { |
| 61 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 66 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 62 sub_page); | 67 sub_page); |
| 63 } | 68 } |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 206 system_tray_->SetPrimaryTrayVisible(visible); | 211 system_tray_->SetPrimaryTrayVisible(visible); |
| 207 } | 212 } |
| 208 | 213 |
| 209 //////////////////////////////////////////////////////////////////////////////// | 214 //////////////////////////////////////////////////////////////////////////////// |
| 210 // ash::mojom::SystemTrayClient: | 215 // ash::mojom::SystemTrayClient: |
| 211 | 216 |
| 212 void SystemTrayClient::ShowSettings() { | 217 void SystemTrayClient::ShowSettings() { |
| 213 ShowSettingsSubPageForActiveUser(std::string()); | 218 ShowSettingsSubPageForActiveUser(std::string()); |
| 214 } | 219 } |
| 215 | 220 |
| 221 void SystemTrayClient::ShowBluetoothSettings() { | |
|
James Cook
2017/03/17 22:23:30
Moved from SystemTrayDelegateChromeOS.
msw
2017/03/18 00:44:44
Acknowledged.
| |
| 222 base::RecordAction(base::UserMetricsAction("ShowBluetoothSettingsPage")); | |
| 223 ShowSettingsSubPageForActiveUser(chrome::kBluetoothSubPage); | |
| 224 } | |
| 225 | |
| 226 void SystemTrayClient::ShowBluetoothPairingDialog( | |
|
James Cook
2017/03/17 22:23:30
Moved from TrayBluetoothHelper.
msw
2017/03/18 00:44:44
Acknowledged.
| |
| 227 const std::string& address, | |
| 228 const base::string16& name_for_display, | |
| 229 bool paired, | |
| 230 bool connected) { | |
| 231 std::string canonical_address = BluetoothDevice::CanonicalizeAddress(address); | |
| 232 if (canonical_address.empty()) // Address was invalid. | |
| 233 return; | |
| 234 | |
| 235 base::RecordAction( | |
| 236 base::UserMetricsAction("StatusArea_Bluetooth_Connect_Unknown")); | |
| 237 BluetoothPairingDialog* dialog = new BluetoothPairingDialog( | |
| 238 canonical_address, name_for_display, paired, connected); | |
| 239 // The dialog deletes itself on close. | |
| 240 dialog->ShowInContainer(GetDialogParentContainerId()); | |
| 241 } | |
| 242 | |
| 216 void SystemTrayClient::ShowDateSettings() { | 243 void SystemTrayClient::ShowDateSettings() { |
| 217 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); | 244 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); |
| 218 // Everybody can change the time zone (even though it is a device setting). | 245 // Everybody can change the time zone (even though it is a device setting). |
| 219 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 246 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 220 chrome::kDateTimeSubPage); | 247 chrome::kDateTimeSubPage); |
| 221 } | 248 } |
| 222 | 249 |
| 223 void SystemTrayClient::ShowSetTimeDialog() { | 250 void SystemTrayClient::ShowSetTimeDialog() { |
| 224 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); | 251 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); |
| 225 } | 252 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 374 chromeos::system::SystemClock* clock) { | 401 chromeos::system::SystemClock* clock) { |
| 375 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 402 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 376 } | 403 } |
| 377 | 404 |
| 378 void SystemTrayClient::Observe(int type, | 405 void SystemTrayClient::Observe(int type, |
| 379 const content::NotificationSource& source, | 406 const content::NotificationSource& source, |
| 380 const content::NotificationDetails& details) { | 407 const content::NotificationDetails& details) { |
| 381 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | 408 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); |
| 382 HandleUpdateAvailable(); | 409 HandleUpdateAvailable(); |
| 383 } | 410 } |
| OLD | NEW |