| 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/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
| 9 #include "ash/common/wm_shell.h" | 9 #include "ash/common/wm_shell.h" |
| 10 #include "ash/public/cpp/shell_window_ids.h" | 10 #include "ash/public/cpp/shell_window_ids.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "base/bind.h" | |
| 13 #include "base/bind_helpers.h" | |
| 14 #include "base/logging.h" | 12 #include "base/logging.h" |
| 15 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browser_process_platform_part.h" | 14 #include "chrome/browser/browser_process_platform_part.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 15 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 16 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 19 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 18 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 21 #include "chrome/browser/chromeos/set_time_dialog.h" | 19 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 22 #include "chrome/browser/chromeos/system/system_clock.h" | 20 #include "chrome/browser/chromeos/system/system_clock.h" |
| 23 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 | 54 |
| 57 SystemTrayClient* g_instance = nullptr; | 55 SystemTrayClient* g_instance = nullptr; |
| 58 | 56 |
| 59 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | 57 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { |
| 60 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 58 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 61 sub_page); | 59 sub_page); |
| 62 } | 60 } |
| 63 | 61 |
| 64 } // namespace | 62 } // namespace |
| 65 | 63 |
| 66 SystemTrayClient::SystemTrayClient() { | 64 SystemTrayClient::SystemTrayClient() : binding_(this) { |
| 65 service_manager::Connector* connector = |
| 66 content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 67 // Connect to the SystemTray interface in ash. Under mash the SystemTray |
| 68 // interface is in the ash process. In classic ash we provide it to ourself. |
| 69 if (chrome::IsRunningInMash()) { |
| 70 connector->ConnectToInterface("ash", &system_tray_); |
| 71 } else { |
| 72 connector->ConnectToInterface(content::mojom::kBrowserServiceName, |
| 73 &system_tray_); |
| 74 } |
| 75 // Register this object as the client interface implementation. |
| 76 system_tray_->SetClient(binding_.CreateInterfacePtrAndBind()); |
| 77 |
| 67 // If this observes clock setting changes before ash comes up the IPCs will | 78 // If this observes clock setting changes before ash comes up the IPCs will |
| 68 // be queued on |system_tray_|. | 79 // be queued on |system_tray_|. |
| 69 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); | 80 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); |
| 70 | 81 |
| 71 DCHECK(!g_instance); | 82 DCHECK(!g_instance); |
| 72 g_instance = this; | 83 g_instance = this; |
| 73 } | 84 } |
| 74 | 85 |
| 75 SystemTrayClient::~SystemTrayClient() { | 86 SystemTrayClient::~SystemTrayClient() { |
| 76 DCHECK_EQ(this, g_instance); | 87 DCHECK_EQ(this, g_instance); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 void SystemTrayClient::RequestRestartForUpdate() { | 318 void SystemTrayClient::RequestRestartForUpdate() { |
| 308 // We expect that UpdateEngine is in "Reboot for update" state now. | 319 // We expect that UpdateEngine is in "Reboot for update" state now. |
| 309 chrome::NotifyAndTerminate(true /* fast_path */); | 320 chrome::NotifyAndTerminate(true /* fast_path */); |
| 310 } | 321 } |
| 311 | 322 |
| 312 //////////////////////////////////////////////////////////////////////////////// | 323 //////////////////////////////////////////////////////////////////////////////// |
| 313 // chromeos::system::SystemClockObserver: | 324 // chromeos::system::SystemClockObserver: |
| 314 | 325 |
| 315 void SystemTrayClient::OnSystemClockChanged( | 326 void SystemTrayClient::OnSystemClockChanged( |
| 316 chromeos::system::SystemClock* clock) { | 327 chromeos::system::SystemClock* clock) { |
| 317 ConnectToSystemTray(); | |
| 318 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 328 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 319 } | 329 } |
| 320 | |
| 321 void SystemTrayClient::ConnectToSystemTray() { | |
| 322 if (system_tray_.is_bound()) | |
| 323 return; | |
| 324 | |
| 325 service_manager::Connector* connector = | |
| 326 content::ServiceManagerConnection::GetForProcess()->GetConnector(); | |
| 327 // Under mash the SystemTray interface is in the ash process. In classic ash | |
| 328 // we provide it to ourself. | |
| 329 if (chrome::IsRunningInMash()) { | |
| 330 connector->ConnectToInterface("ash", &system_tray_); | |
| 331 } else { | |
| 332 connector->ConnectToInterface(content::mojom::kBrowserServiceName, | |
| 333 &system_tray_); | |
| 334 } | |
| 335 | |
| 336 // Tolerate ash crashing and coming back up. | |
| 337 system_tray_.set_connection_error_handler(base::Bind( | |
| 338 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | |
| 339 } | |
| 340 | |
| 341 void SystemTrayClient::OnClientConnectionError() { | |
| 342 system_tray_.reset(); | |
| 343 } | |
| OLD | NEW |