| 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 "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
| 10 #include "chrome/browser/browser_process_platform_part.h" | 10 #include "chrome/browser/browser_process_platform_part.h" |
| 11 #include "chrome/browser/chromeos/system/system_clock.h" | 11 #include "chrome/browser/chromeos/system/system_clock.h" |
| 12 #include "chrome/browser/ui/ash/ash_util.h" |
| 12 #include "chrome/browser/ui/ash/system_tray_common.h" | 13 #include "chrome/browser/ui/ash/system_tray_common.h" |
| 13 #include "content/public/common/mojo_shell_connection.h" | 14 #include "content/public/common/mojo_shell_connection.h" |
| 14 #include "services/shell/public/cpp/connector.h" | 15 #include "services/shell/public/cpp/connector.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 SystemTrayClient* g_instance = nullptr; | 19 SystemTrayClient* g_instance = nullptr; |
| 19 | 20 |
| 20 } // namespace | 21 } // namespace |
| 21 | 22 |
| (...skipping 15 matching lines...) Expand all Loading... |
| 37 | 38 |
| 38 // static | 39 // static |
| 39 SystemTrayClient* SystemTrayClient::Get() { | 40 SystemTrayClient* SystemTrayClient::Get() { |
| 40 return g_instance; | 41 return g_instance; |
| 41 } | 42 } |
| 42 | 43 |
| 43 void SystemTrayClient::ConnectToSystemTray() { | 44 void SystemTrayClient::ConnectToSystemTray() { |
| 44 if (system_tray_.is_bound()) | 45 if (system_tray_.is_bound()) |
| 45 return; | 46 return; |
| 46 | 47 |
| 47 content::MojoShellConnection::GetForProcess() | 48 shell::Connector* connector = |
| 48 ->GetConnector() | 49 content::MojoShellConnection::GetForProcess()->GetConnector(); |
| 49 ->ConnectToInterface("mojo:ash", &system_tray_); | 50 // Under mash the SystemTray interface is in the ash process. In classic ash |
| 51 // we provide it to ourself. |
| 52 if (chrome::IsRunningInMash()) |
| 53 connector->ConnectToInterface("mojo:ash", &system_tray_); |
| 54 else |
| 55 connector->ConnectToInterface("exe:content_browser", &system_tray_); |
| 50 | 56 |
| 51 // Tolerate ash crashing and coming back up. | 57 // Tolerate ash crashing and coming back up. |
| 52 system_tray_.set_connection_error_handler(base::Bind( | 58 system_tray_.set_connection_error_handler(base::Bind( |
| 53 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 59 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
| 54 } | 60 } |
| 55 | 61 |
| 56 void SystemTrayClient::OnClientConnectionError() { | 62 void SystemTrayClient::OnClientConnectionError() { |
| 57 system_tray_.reset(); | 63 system_tray_.reset(); |
| 58 } | 64 } |
| 59 | 65 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 } | 119 } |
| 114 | 120 |
| 115 //////////////////////////////////////////////////////////////////////////////// | 121 //////////////////////////////////////////////////////////////////////////////// |
| 116 // chromeos::system::SystemClockObserver: | 122 // chromeos::system::SystemClockObserver: |
| 117 | 123 |
| 118 void SystemTrayClient::OnSystemClockChanged( | 124 void SystemTrayClient::OnSystemClockChanged( |
| 119 chromeos::system::SystemClock* clock) { | 125 chromeos::system::SystemClock* clock) { |
| 120 ConnectToSystemTray(); | 126 ConnectToSystemTray(); |
| 121 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); | 127 system_tray_->SetUse24HourClock(clock->ShouldUse24HourClock()); |
| 122 } | 128 } |
| OLD | NEW |