| 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" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "chrome/browser/browser_process.h" | 15 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/browser_process_platform_part.h" | 16 #include "chrome/browser/browser_process_platform_part.h" |
| 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" | 17 #include "chrome/browser/chromeos/accessibility/accessibility_util.h" |
| 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h" | 18 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 19 #include "chrome/browser/chromeos/options/network_config_view.h" | 19 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 20 #include "chrome/browser/chromeos/profiles/profile_helper.h" | |
| 21 #include "chrome/browser/chromeos/set_time_dialog.h" | 20 #include "chrome/browser/chromeos/set_time_dialog.h" |
| 22 #include "chrome/browser/chromeos/system/system_clock.h" | 21 #include "chrome/browser/chromeos/system/system_clock.h" |
| 23 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" | 22 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" |
| 24 #include "chrome/browser/lifetime/application_lifetime.h" | 23 #include "chrome/browser/lifetime/application_lifetime.h" |
| 25 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 26 #include "chrome/browser/ui/ash/ash_util.h" | 25 #include "chrome/browser/ui/ash/ash_util.h" |
| 27 #include "chrome/browser/ui/chrome_pages.h" | 26 #include "chrome/browser/ui/chrome_pages.h" |
| 28 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" | 27 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" |
| 29 #include "chrome/browser/ui/singleton_tabs.h" | 28 #include "chrome/browser/ui/singleton_tabs.h" |
| 30 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
| 31 #include "chromeos/dbus/dbus_thread_manager.h" | 30 #include "chromeos/dbus/dbus_thread_manager.h" |
| 32 #include "chromeos/dbus/session_manager_client.h" | 31 #include "chromeos/dbus/session_manager_client.h" |
| 33 #include "chromeos/login/login_state.h" | 32 #include "chromeos/login/login_state.h" |
| 34 #include "components/user_manager/user_manager.h" | |
| 35 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 36 #include "content/public/common/service_manager_connection.h" | 34 #include "content/public/common/service_manager_connection.h" |
| 37 #include "content/public/common/service_names.mojom.h" | 35 #include "content/public/common/service_names.mojom.h" |
| 38 #include "extensions/browser/api/vpn_provider/vpn_service.h" | |
| 39 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" | |
| 40 #include "net/base/escape.h" | 36 #include "net/base/escape.h" |
| 41 #include "services/service_manager/public/cpp/connector.h" | 37 #include "services/service_manager/public/cpp/connector.h" |
| 42 #include "services/ui/public/cpp/property_type_converters.h" | 38 #include "services/ui/public/cpp/property_type_converters.h" |
| 43 #include "services/ui/public/interfaces/window_manager.mojom.h" | 39 #include "services/ui/public/interfaces/window_manager.mojom.h" |
| 44 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" | 40 #include "third_party/cros_system_api/dbus/shill/dbus-constants.h" |
| 45 #include "ui/views/widget/widget.h" | 41 #include "ui/views/widget/widget.h" |
| 46 #include "ui/views/window/dialog_delegate.h" | 42 #include "ui/views/window/dialog_delegate.h" |
| 47 | 43 |
| 48 using chromeos::DBusThreadManager; | 44 using chromeos::DBusThreadManager; |
| 49 using chromeos::LoginState; | 45 using chromeos::LoginState; |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 | 247 |
| 252 void SystemTrayClient::ShowNetworkCreate(const std::string& type) { | 248 void SystemTrayClient::ShowNetworkCreate(const std::string& type) { |
| 253 int container_id = GetDialogParentContainerId(); | 249 int container_id = GetDialogParentContainerId(); |
| 254 if (type == shill::kTypeCellular) { | 250 if (type == shill::kTypeCellular) { |
| 255 chromeos::ChooseMobileNetworkDialog::ShowDialogInContainer(container_id); | 251 chromeos::ChooseMobileNetworkDialog::ShowDialogInContainer(container_id); |
| 256 return; | 252 return; |
| 257 } | 253 } |
| 258 chromeos::NetworkConfigView::ShowForType(type, nullptr /* parent */); | 254 chromeos::NetworkConfigView::ShowForType(type, nullptr /* parent */); |
| 259 } | 255 } |
| 260 | 256 |
| 261 void SystemTrayClient::ShowThirdPartyVpnCreate( | |
| 262 const std::string& extension_id) { | |
| 263 const user_manager::User* primary_user = | |
| 264 user_manager::UserManager::Get()->GetPrimaryUser(); | |
| 265 if (!primary_user) | |
| 266 return; | |
| 267 | |
| 268 Profile* profile = | |
| 269 chromeos::ProfileHelper::Get()->GetProfileByUser(primary_user); | |
| 270 if (!profile) | |
| 271 return; | |
| 272 | |
| 273 // Request that the third-party VPN provider show its "add network" dialog. | |
| 274 chromeos::VpnServiceFactory::GetForBrowserContext(profile) | |
| 275 ->SendShowAddDialogToExtension(extension_id); | |
| 276 } | |
| 277 | |
| 278 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { | 257 void SystemTrayClient::ShowNetworkSettings(const std::string& network_id) { |
| 279 if (!chrome::IsRunningInMash()) { | 258 if (!chrome::IsRunningInMash()) { |
| 280 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 | 259 // TODO(mash): Need replacement for SessionStateDelegate. crbug.com/648964 |
| 281 if (!LoginState::Get()->IsUserLoggedIn() || | 260 if (!LoginState::Get()->IsUserLoggedIn() || |
| 282 ash::WmShell::Get() | 261 ash::WmShell::Get() |
| 283 ->GetSessionStateDelegate() | 262 ->GetSessionStateDelegate() |
| 284 ->IsInSecondaryLoginScreen()) | 263 ->IsInSecondaryLoginScreen()) |
| 285 return; | 264 return; |
| 286 } | 265 } |
| 287 | 266 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 } | 313 } |
| 335 | 314 |
| 336 // Tolerate ash crashing and coming back up. | 315 // Tolerate ash crashing and coming back up. |
| 337 system_tray_.set_connection_error_handler(base::Bind( | 316 system_tray_.set_connection_error_handler(base::Bind( |
| 338 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); | 317 &SystemTrayClient::OnClientConnectionError, base::Unretained(this))); |
| 339 } | 318 } |
| 340 | 319 |
| 341 void SystemTrayClient::OnClientConnectionError() { | 320 void SystemTrayClient::OnClientConnectionError() { |
| 342 system_tray_.reset(); | 321 system_tray_.reset(); |
| 343 } | 322 } |
| OLD | NEW |