| 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/set_time_dialog.h" | 18 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 21 #include "chrome/browser/chromeos/system/system_clock.h" | 19 #include "chrome/browser/chromeos/system/system_clock.h" |
| 22 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 20 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 23 #include "chrome/browser/lifetime/application_lifetime.h" | 21 #include "chrome/browser/lifetime/application_lifetime.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 52 | 50 |
| 53 SystemTrayClient* g_instance = nullptr; | 51 SystemTrayClient* g_instance = nullptr; |
| 54 | 52 |
| 55 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { | 53 void ShowSettingsSubPageForActiveUser(const std::string& sub_page) { |
| 56 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 54 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 57 sub_page); | 55 sub_page); |
| 58 } | 56 } |
| 59 | 57 |
| 60 } // namespace | 58 } // namespace |
| 61 | 59 |
| 62 SystemTrayClient::SystemTrayClient() { | 60 SystemTrayClient::SystemTrayClient() : binding_(this) { |
| 61 service_manager::Connector* connector = |
| 62 content::ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 63 // Connect to the SystemTray interface in ash. Under mash the SystemTray |
| 64 // interface is in the ash process. In classic ash we provide it to ourself. |
| 65 if (chrome::IsRunningInMash()) { |
| 66 connector->ConnectToInterface("ash", &system_tray_); |
| 67 } else { |
| 68 connector->ConnectToInterface(content::mojom::kBrowserServiceName, |
| 69 &system_tray_); |
| 70 } |
| 71 // Register this object as the client interface implementation. |
| 72 system_tray_->SetClient(binding_.CreateInterfacePtrAndBind()); |
| 73 |
| 63 // If this observes clock setting changes before ash comes up the IPCs will | 74 // If this observes clock setting changes before ash comes up the IPCs will |
| 64 // be queued on |system_tray_|. | 75 // be queued on |system_tray_|. |
| 65 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); | 76 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this); |
| 66 | 77 |
| 67 DCHECK(!g_instance); | 78 DCHECK(!g_instance); |
| 68 g_instance = this; | 79 g_instance = this; |
| 69 } | 80 } |
| 70 | 81 |
| 71 SystemTrayClient::~SystemTrayClient() { | 82 SystemTrayClient::~SystemTrayClient() { |
| 72 DCHECK_EQ(this, g_instance); | 83 DCHECK_EQ(this, g_instance); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void SystemTrayClient::RequestRestartForUpdate() { | 297 void SystemTrayClient::RequestRestartForUpdate() { |
| 287 // We expect that UpdateEngine is in "Reboot for update" state now. | 298 // We expect that UpdateEngine is in "Reboot for update" state now. |
| 288 chrome::NotifyAndTerminate(true /* fast_path */); | 299 chrome::NotifyAndTerminate(true /* fast_path */); |
| 289 } | 300 } |
| 290 | 301 |
| 291 //////////////////////////////////////////////////////////////////////////////// | 302 //////////////////////////////////////////////////////////////////////////////// |
| 292 // chromeos::system::SystemClockObserver: | 303 // chromeos::system::SystemClockObserver: |
| 293 | 304 |
| 294 void SystemTrayClient::OnSystemClockChanged( | 305 void SystemTrayClient::OnSystemClockChanged( |
| 295 chromeos::system::SystemClock* clock) { | 306 chromeos::system::SystemClock* clock) { |
| 296 ConnectToSystemTray(); | |
| 297 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 307 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 298 } | 308 } |
| 299 | |
| 300 void SystemTrayClient::ConnectToSystemTray() { | |
| 301 if (system_tray_.is_bound()) | |
| 302 return; | |
| 303 | |
| 304 service_manager::Connector* connector = | |
| 305 content::ServiceManagerConnection::GetForProcess()->GetConnector(); | |
| 306 // Under mash the SystemTray interface is in the ash process. In classic ash | |
| 307 // we provide it to ourself. | |
| 308 if (chrome::IsRunningInMash()) { | |
| 309 connector->ConnectToInterface("ash", &system_tray_); | |
| 310 } else { | |
| 311 connector->ConnectToInterface(content::mojom::kBrowserServiceName, | |
| 312 &system_tray_); | |
| 313 } | |
| 314 | |
| 315 // Tolerate ash crashing and coming back up. | |
| 316 system_tray_.set_connection_error_handler(base::Bind( | |
| 317 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | |
| 318 } | |
| 319 | |
| 320 void SystemTrayClient::OnClientConnectionError() { | |
| 321 system_tray_.reset(); | |
| 322 } | |
| OLD | NEW |