| 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 "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/browser_process_platform_part.h" | 15 #include "chrome/browser/browser_process_platform_part.h" |
| 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 16 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 17 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 18 #include "chrome/browser/chromeos/options/network_config_view.h" | 18 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 19 #include "chrome/browser/chromeos/set_time_dialog.h" | 19 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 20 #include "chrome/browser/chromeos/system/system_clock.h" | 20 #include "chrome/browser/chromeos/system/system_clock.h" |
| 21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 21 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 22 #include "chrome/browser/profiles/profile_manager.h" | 22 #include "chrome/browser/profiles/profile_manager.h" |
| 23 #include "chrome/browser/ui/ash/ash_util.h" | 23 #include "chrome/browser/ui/ash/ash_util.h" |
| 24 #include "chrome/browser/ui/chrome_pages.h" | 24 #include "chrome/browser/ui/chrome_pages.h" |
| 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 25 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 26 #include "chrome/browser/ui/singleton_tabs.h" | 26 #include "chrome/browser/ui/singleton_tabs.h" |
| 27 #include "chrome/common/url_constants.h" | 27 #include "chrome/common/url_constants.h" |
| 28 #include "chrome/grit/generated_resources.h" | |
| 29 #include "chromeos/dbus/dbus_thread_manager.h" | 28 #include "chromeos/dbus/dbus_thread_manager.h" |
| 30 #include "chromeos/dbus/session_manager_client.h" | 29 #include "chromeos/dbus/session_manager_client.h" |
| 31 #include "chromeos/login/login_state.h" | 30 #include "chromeos/login/login_state.h" |
| 32 #include "content/public/browser/user_metrics.h" | 31 #include "content/public/browser/user_metrics.h" |
| 33 #include "content/public/common/service_manager_connection.h" | 32 #include "content/public/common/service_manager_connection.h" |
| 34 #include "net/base/escape.h" | 33 #include "net/base/escape.h" |
| 35 #include "services/service_manager/public/cpp/connector.h" | 34 #include "services/service_manager/public/cpp/connector.h" |
| 36 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" | 35 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" |
| 37 #include "ui/base/l10n/l10n_util.h" | |
| 38 | 36 |
| 39 using chromeos::DBusThreadManager; | 37 using chromeos::DBusThreadManager; |
| 40 using chromeos::LoginState; | 38 using chromeos::LoginState; |
| 41 | 39 |
| 42 namespace { | 40 namespace { |
| 43 | 41 |
| 44 const char kDisplaySettingsSubPageName[] = "display"; | 42 const char kDisplaySettingsSubPageName[] = "display"; |
| 45 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; | 43 const char kPaletteSettingsSubPageName[] = "stylus-overlay"; |
| 46 | 44 |
| 47 SystemTrayClient* g_instance = nullptr; | 45 SystemTrayClient* g_instance = nullptr; |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 131 |
| 134 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
| 135 // ash::mojom::SystemTrayClient: | 133 // ash::mojom::SystemTrayClient: |
| 136 | 134 |
| 137 void SystemTrayClient::ShowSettings() { | 135 void SystemTrayClient::ShowSettings() { |
| 138 ShowSettingsSubPageForActiveUser(std::string()); | 136 ShowSettingsSubPageForActiveUser(std::string()); |
| 139 } | 137 } |
| 140 | 138 |
| 141 void SystemTrayClient::ShowDateSettings() { | 139 void SystemTrayClient::ShowDateSettings() { |
| 142 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); | 140 content::RecordAction(base::UserMetricsAction("ShowDateOptions")); |
| 143 std::string sub_page = | |
| 144 std::string(chrome::kSearchSubPage) + "#" + | |
| 145 l10n_util::GetStringUTF8(IDS_OPTIONS_SETTINGS_SECTION_TITLE_DATETIME); | |
| 146 // Everybody can change the time zone (even though it is a device setting). | 141 // Everybody can change the time zone (even though it is a device setting). |
| 147 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), | 142 chrome::ShowSettingsSubPageForProfile(ProfileManager::GetActiveUserProfile(), |
| 148 sub_page); | 143 chrome::kDateTimeSubPage); |
| 149 } | 144 } |
| 150 | 145 |
| 151 void SystemTrayClient::ShowSetTimeDialog() { | 146 void SystemTrayClient::ShowSetTimeDialog() { |
| 152 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); | 147 chromeos::SetTimeDialog::ShowDialogInContainer(GetDialogParentContainerId()); |
| 153 } | 148 } |
| 154 | 149 |
| 155 void SystemTrayClient::ShowDisplaySettings() { | 150 void SystemTrayClient::ShowDisplaySettings() { |
| 156 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); | 151 content::RecordAction(base::UserMetricsAction("ShowDisplayOptions")); |
| 157 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); | 152 ShowSettingsSubPageForActiveUser(kDisplaySettingsSubPageName); |
| 158 } | 153 } |
| (...skipping 20 matching lines...) Expand all Loading... |
| 179 } | 174 } |
| 180 | 175 |
| 181 void SystemTrayClient::ShowAccessibilityHelp() { | 176 void SystemTrayClient::ShowAccessibilityHelp() { |
| 182 chrome::ScopedTabbedBrowserDisplayer displayer( | 177 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 183 ProfileManager::GetActiveUserProfile()); | 178 ProfileManager::GetActiveUserProfile()); |
| 184 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); | 179 chromeos::accessibility::ShowAccessibilityHelp(displayer.browser()); |
| 185 } | 180 } |
| 186 | 181 |
| 187 void SystemTrayClient::ShowAccessibilitySettings() { | 182 void SystemTrayClient::ShowAccessibilitySettings() { |
| 188 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); | 183 content::RecordAction(base::UserMetricsAction("ShowAccessibilitySettings")); |
| 189 std::string sub_page = std::string(chrome::kSearchSubPage) + "#" + | 184 ShowSettingsSubPageForActiveUser(chrome::kAccessibilitySubPage); |
| 190 l10n_util::GetStringUTF8( | |
| 191 IDS_OPTIONS_SETTINGS_SECTION_TITLE_ACCESSIBILITY); | |
| 192 ShowSettingsSubPageForActiveUser(sub_page); | |
| 193 } | 185 } |
| 194 | 186 |
| 195 void SystemTrayClient::ShowPaletteHelp() { | 187 void SystemTrayClient::ShowPaletteHelp() { |
| 196 chrome::ScopedTabbedBrowserDisplayer displayer( | 188 chrome::ScopedTabbedBrowserDisplayer displayer( |
| 197 ProfileManager::GetActiveUserProfile()); | 189 ProfileManager::GetActiveUserProfile()); |
| 198 chrome::ShowSingletonTab(displayer.browser(), | 190 chrome::ShowSingletonTab(displayer.browser(), |
| 199 GURL(chrome::kChromePaletteHelpURL)); | 191 GURL(chrome::kChromePaletteHelpURL)); |
| 200 } | 192 } |
| 201 | 193 |
| 202 void SystemTrayClient::ShowPaletteSettings() { | 194 void SystemTrayClient::ShowPaletteSettings() { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 280 connector->ConnectToInterface("service:content_browser", &system_tray_); | 272 connector->ConnectToInterface("service:content_browser", &system_tray_); |
| 281 | 273 |
| 282 // Tolerate ash crashing and coming back up. | 274 // Tolerate ash crashing and coming back up. |
| 283 system_tray_.set_connection_error_handler(base::Bind( | 275 system_tray_.set_connection_error_handler(base::Bind( |
| 284 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 276 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
| 285 } | 277 } |
| 286 | 278 |
| 287 void SystemTrayClient::OnClientConnectionError() { | 279 void SystemTrayClient::OnClientConnectionError() { |
| 288 system_tray_.reset(); | 280 system_tray_.reset(); |
| 289 } | 281 } |
| OLD | NEW |