Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/network_connect_delegate_chromeos.h" | 5 #include "chrome/browser/ui/ash/network_connect_delegate_chromeos.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/shell_window_ids.h" | 9 #include "ash/common/shell_window_ids.h" |
| 10 #include "ash/common/system/tray/system_tray_delegate.h" | 10 #include "ash/common/system/tray/system_tray_delegate.h" |
| 11 #include "ash/common/wm_shell.h" | 11 #include "ash/common/wm_shell.h" |
| 12 #include "ash/shell.h" | 12 #include "ash/shell.h" |
| 13 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 13 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
| 14 #include "chrome/browser/chromeos/options/network_config_view.h" | 14 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 15 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 15 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
| 16 #include "chrome/browser/ui/ash/system_tray_client.h" | 16 #include "chrome/browser/ui/ash/system_tray_client.h" |
| 17 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" | 17 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" |
| 18 #include "chromeos/network/network_handler.h" | |
| 19 #include "chromeos/network/network_state.h" | |
| 20 #include "chromeos/network/network_state_handler.h" | |
| 21 | |
| 22 namespace chromeos { | |
| 18 | 23 |
| 19 namespace { | 24 namespace { |
| 20 | 25 |
| 21 bool IsUIAvailable() { | 26 bool IsUIAvailable() { |
| 22 return ash::WmShell::HasInstance() && | 27 return ash::WmShell::HasInstance() && |
| 23 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked(); | 28 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked(); |
| 24 } | 29 } |
| 25 | 30 |
| 26 gfx::NativeWindow GetNativeWindow() { | 31 gfx::NativeWindow GetNativeWindow() { |
| 27 ash::WmShell* wm_shell = ash::WmShell::Get(); | 32 ash::WmShell* wm_shell = ash::WmShell::Get(); |
| 28 const bool session_started = | 33 const bool session_started = |
| 29 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); | 34 wm_shell->GetSessionStateDelegate()->IsActiveUserSessionStarted(); |
| 30 const ash::LoginStatus login_status = | 35 const ash::LoginStatus login_status = |
| 31 wm_shell->system_tray_delegate()->GetUserLoginStatus(); | 36 wm_shell->system_tray_delegate()->GetUserLoginStatus(); |
| 32 const bool is_in_secondary_login_screen = | 37 const bool is_in_secondary_login_screen = |
| 33 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); | 38 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); |
| 34 | 39 |
| 35 int container_id = | 40 int container_id = |
|
James Cook
2016/10/18 23:26:25
You may need to sync/rebase -- most of this functi
stevenjb
2016/10/19 17:06:44
Done.
| |
| 36 (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN || | 41 (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN || |
| 37 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen) | 42 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen) |
| 38 ? ash::kShellWindowId_LockSystemModalContainer | 43 ? ash::kShellWindowId_LockSystemModalContainer |
| 39 : ash::kShellWindowId_SystemModalContainer; | 44 : ash::kShellWindowId_SystemModalContainer; |
| 40 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | 45 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), |
| 41 container_id); | 46 container_id); |
| 42 } | 47 } |
| 43 | 48 |
| 49 std::string GetServicePathFromNetworkId(const std::string& network_id) { | |
|
James Cook
2016/10/18 23:26:25
Can you put this in a static function in SystemTra
stevenjb
2016/10/19 17:06:44
Moved to the dialog code.
| |
| 50 const NetworkState* network = | |
| 51 NetworkHandler::Get()->network_state_handler()->GetNetworkStateFromGuid( | |
| 52 network_id); | |
| 53 if (!network) { | |
| 54 LOG(ERROR) << "Network ID not found: " << network_id; | |
| 55 return ""; | |
|
James Cook
2016/10/18 23:26:25
nit: std::string()
stevenjb
2016/10/19 17:06:44
Acknowledged.
| |
| 56 } | |
| 57 return network->path(); | |
| 58 } | |
| 59 | |
| 44 } // namespace | 60 } // namespace |
| 45 | 61 |
| 46 namespace chromeos { | 62 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() {} |
| 47 | 63 |
| 48 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() { | 64 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {} |
| 49 } | |
| 50 | |
| 51 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() { | |
| 52 } | |
| 53 | 65 |
| 54 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure( | 66 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure( |
| 55 const std::string& network_id) { | 67 const std::string& network_id) { |
| 56 if (!IsUIAvailable()) | 68 if (!IsUIAvailable()) |
| 57 return; | 69 return; |
| 58 NetworkConfigView::Show(network_id, GetNativeWindow()); | 70 std::string service_path = GetServicePathFromNetworkId(network_id); |
| 71 if (service_path.empty()) | |
| 72 return; | |
| 73 NetworkConfigView::Show(service_path, GetNativeWindow()); | |
| 59 } | 74 } |
| 60 | 75 |
| 61 void NetworkConnectDelegateChromeOS::ShowNetworkSettingsForGuid( | 76 void NetworkConnectDelegateChromeOS::ShowNetworkSettingsForGuid( |
| 62 const std::string& network_id) { | 77 const std::string& network_id) { |
| 63 if (!IsUIAvailable()) | 78 if (!IsUIAvailable()) |
| 64 return; | 79 return; |
| 65 SystemTrayClient::Get()->ShowNetworkSettings(network_id); | 80 SystemTrayClient::Get()->ShowNetworkSettings(network_id); |
| 66 } | 81 } |
| 67 | 82 |
| 68 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork( | 83 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork( |
| 69 const std::string& network_id) { | 84 const std::string& network_id) { |
| 70 if (!IsUIAvailable()) | 85 if (!IsUIAvailable()) |
| 71 return false; | 86 return false; |
| 72 return enrollment::CreateDialog(network_id, GetNativeWindow()); | 87 return enrollment::CreateDialog(network_id, GetNativeWindow()); |
| 73 } | 88 } |
| 74 | 89 |
| 75 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() { | 90 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() { |
| 76 if (!IsUIAvailable()) | 91 if (!IsUIAvailable()) |
| 77 return; | 92 return; |
| 78 SimDialogDelegate::ShowDialog(GetNativeWindow(), | 93 SimDialogDelegate::ShowDialog(GetNativeWindow(), |
| 79 SimDialogDelegate::SIM_DIALOG_UNLOCK); | 94 SimDialogDelegate::SIM_DIALOG_UNLOCK); |
| 80 } | 95 } |
| 81 | 96 |
| 82 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog( | 97 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog( |
| 83 const std::string& service_path) { | 98 const std::string& network_id) { |
| 84 if (!IsUIAvailable()) | 99 if (!IsUIAvailable()) |
| 85 return; | 100 return; |
| 101 std::string service_path = GetServicePathFromNetworkId(network_id); | |
| 102 if (service_path.empty()) | |
| 103 return; | |
| 86 MobileSetupDialog::Show(service_path); | 104 MobileSetupDialog::Show(service_path); |
| 87 } | 105 } |
| 88 | 106 |
| 89 } // namespace chromeos | 107 } // namespace chromeos |
| OLD | NEW |