| 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 "ash/mus/system_tray_delegate_mus.h" | 5 #include "ash/mus/system_tray_delegate_mus.h" |
| 6 | 6 |
| 7 #include "ash/common/system/tray/system_tray_notifier.h" | 7 #include "ash/common/system/tray/system_tray_notifier.h" |
| 8 #include "ash/common/wm_shell.h" | 8 #include "ash/common/wm_shell.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 SystemTrayDelegateMus::~SystemTrayDelegateMus() { | 29 SystemTrayDelegateMus::~SystemTrayDelegateMus() { |
| 30 DCHECK_EQ(this, g_instance); | 30 DCHECK_EQ(this, g_instance); |
| 31 g_instance = nullptr; | 31 g_instance = nullptr; |
| 32 } | 32 } |
| 33 | 33 |
| 34 // static | 34 // static |
| 35 SystemTrayDelegateMus* SystemTrayDelegateMus::Get() { | 35 SystemTrayDelegateMus* SystemTrayDelegateMus::Get() { |
| 36 return g_instance; | 36 return g_instance; |
| 37 } | 37 } |
| 38 | 38 |
| 39 void SystemTrayDelegateMus::ConnectToSystemTrayClient() { | 39 mojom::SystemTrayClient* SystemTrayDelegateMus::ConnectToSystemTrayClient() { |
| 40 if (system_tray_client_.is_bound()) | 40 if (!system_tray_client_.is_bound()) { |
| 41 return; | 41 // Connect (or reconnect) to the interface. |
| 42 connector_->ConnectToInterface("exe:chrome", &system_tray_client_); |
| 42 | 43 |
| 43 connector_->ConnectToInterface("exe:chrome", &system_tray_client_); | 44 // Tolerate chrome crashing and coming back up. |
| 44 | 45 system_tray_client_.set_connection_error_handler( |
| 45 // Tolerate chrome crashing and coming back up. | 46 base::Bind(&SystemTrayDelegateMus::OnClientConnectionError, |
| 46 system_tray_client_.set_connection_error_handler(base::Bind( | 47 base::Unretained(this))); |
| 47 &SystemTrayDelegateMus::OnClientConnectionError, base::Unretained(this))); | 48 } |
| 49 return system_tray_client_.get(); |
| 48 } | 50 } |
| 49 | 51 |
| 50 void SystemTrayDelegateMus::OnClientConnectionError() { | 52 void SystemTrayDelegateMus::OnClientConnectionError() { |
| 51 system_tray_client_.reset(); | 53 system_tray_client_.reset(); |
| 52 } | 54 } |
| 53 | 55 |
| 56 //////////////////////////////////////////////////////////////////////////////// |
| 57 // SystemTrayDelegate: |
| 58 |
| 54 base::HourClockType SystemTrayDelegateMus::GetHourClockType() const { | 59 base::HourClockType SystemTrayDelegateMus::GetHourClockType() const { |
| 55 return hour_clock_type_; | 60 return hour_clock_type_; |
| 56 } | 61 } |
| 57 | 62 |
| 63 void SystemTrayDelegateMus::ShowSettings() { |
| 64 ConnectToSystemTrayClient()->ShowSettings(); |
| 65 } |
| 66 |
| 58 void SystemTrayDelegateMus::ShowDateSettings() { | 67 void SystemTrayDelegateMus::ShowDateSettings() { |
| 59 ConnectToSystemTrayClient(); | 68 ConnectToSystemTrayClient()->ShowDateSettings(); |
| 60 system_tray_client_->ShowDateSettings(); | |
| 61 } | 69 } |
| 62 | 70 |
| 71 void SystemTrayDelegateMus::ShowNetworkSettingsForGuid( |
| 72 const std::string& guid) { |
| 73 // http://crbug.com/647412 |
| 74 NOTIMPLEMENTED(); |
| 75 } |
| 76 |
| 77 void SystemTrayDelegateMus::ShowDisplaySettings() { |
| 78 ConnectToSystemTrayClient()->ShowDisplaySettings(); |
| 79 } |
| 80 |
| 81 void SystemTrayDelegateMus::ShowPowerSettings() { |
| 82 // http://crbug.com/647412 |
| 83 NOTIMPLEMENTED(); |
| 84 } |
| 85 |
| 86 void SystemTrayDelegateMus::ShowChromeSlow() { |
| 87 ConnectToSystemTrayClient()->ShowChromeSlow(); |
| 88 } |
| 89 |
| 90 void SystemTrayDelegateMus::ShowIMESettings() { |
| 91 ConnectToSystemTrayClient()->ShowIMESettings(); |
| 92 } |
| 93 |
| 94 void SystemTrayDelegateMus::ShowHelp() { |
| 95 ConnectToSystemTrayClient()->ShowHelp(); |
| 96 } |
| 97 |
| 98 void SystemTrayDelegateMus::ShowAccessibilityHelp() { |
| 99 ConnectToSystemTrayClient()->ShowAccessibilityHelp(); |
| 100 } |
| 101 |
| 102 void SystemTrayDelegateMus::ShowAccessibilitySettings() { |
| 103 ConnectToSystemTrayClient()->ShowAccessibilitySettings(); |
| 104 } |
| 105 |
| 106 void SystemTrayDelegateMus::ShowPaletteHelp() { |
| 107 ConnectToSystemTrayClient()->ShowPaletteHelp(); |
| 108 } |
| 109 |
| 110 void SystemTrayDelegateMus::ShowPaletteSettings() { |
| 111 ConnectToSystemTrayClient()->ShowPaletteSettings(); |
| 112 } |
| 113 |
| 114 void SystemTrayDelegateMus::ShowPublicAccountInfo() { |
| 115 ConnectToSystemTrayClient()->ShowPublicAccountInfo(); |
| 116 } |
| 117 |
| 118 void SystemTrayDelegateMus::ShowEnterpriseInfo() { |
| 119 // http://crbug.com/647412 |
| 120 NOTIMPLEMENTED(); |
| 121 } |
| 122 |
| 123 void SystemTrayDelegateMus::ShowProxySettings() { |
| 124 ConnectToSystemTrayClient()->ShowProxySettings(); |
| 125 } |
| 126 |
| 127 //////////////////////////////////////////////////////////////////////////////// |
| 128 // mojom::SystemTray: |
| 129 |
| 63 void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) { | 130 void SystemTrayDelegateMus::SetUse24HourClock(bool use_24_hour) { |
| 64 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; | 131 hour_clock_type_ = use_24_hour ? base::k24HourClock : base::k12HourClock; |
| 65 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); | 132 WmShell::Get()->system_tray_notifier()->NotifyDateFormatChanged(); |
| 66 } | 133 } |
| 67 | 134 |
| 68 } // namespace ash | 135 } // namespace ash |
| OLD | NEW |