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/chromeos/net/network_connect_delegate_chromeos.h" | 5 #include "chrome/browser/chromeos/net/network_connect_delegate_chromeos.h" |
6 | 6 |
7 #include "ash/common/session/session_state_delegate.h" | |
8 #include "ash/common/wm_shell.h" | |
9 #include "ash/shell.h" | |
10 #include "chrome/browser/chromeos/enrollment_dialog_view.h" | 7 #include "chrome/browser/chromeos/enrollment_dialog_view.h" |
8 #include "chrome/browser/chromeos/login/lock/screen_locker.h" | |
11 #include "chrome/browser/chromeos/net/network_state_notifier.h" | 9 #include "chrome/browser/chromeos/net/network_state_notifier.h" |
12 #include "chrome/browser/chromeos/sim_dialog_delegate.h" | 10 #include "chrome/browser/chromeos/sim_dialog_delegate.h" |
13 #include "chrome/browser/ui/ash/system_tray_client.h" | 11 #include "chrome/browser/ui/ash/system_tray_client.h" |
14 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" | 12 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h" |
15 | 13 |
14 namespace chromeos { | |
stevenjb
2016/10/27 18:45:13
nit: blank line
James Cook
2016/10/27 22:28:27
Done.
| |
16 namespace { | 15 namespace { |
17 | 16 |
18 bool IsUIAvailable() { | 17 bool IsUIAvailable() { |
19 return ash::WmShell::HasInstance() && | 18 // UI is available when screen is unlocked. |
20 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked(); | 19 return !ScreenLocker::default_screen_locker() || |
21 } | 20 !ScreenLocker::default_screen_locker()->locked(); |
22 | |
23 gfx::NativeWindow GetNativeWindow() { | |
24 int container_id = SystemTrayClient::GetDialogParentContainerId(); | |
25 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(), | |
26 container_id); | |
27 } | 21 } |
28 | 22 |
29 } // namespace | 23 } // namespace |
30 | 24 |
31 namespace chromeos { | |
32 | |
33 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() | 25 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() |
34 : network_state_notifier_(new NetworkStateNotifier()) {} | 26 : network_state_notifier_(new NetworkStateNotifier()) {} |
35 | 27 |
36 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {} | 28 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {} |
37 | 29 |
38 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure( | 30 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure( |
39 const std::string& network_id) { | 31 const std::string& network_id) { |
40 if (!IsUIAvailable()) | 32 if (!IsUIAvailable()) |
41 return; | 33 return; |
42 SystemTrayClient::Get()->ShowNetworkConfigure(network_id); | 34 SystemTrayClient::Get()->ShowNetworkConfigure(network_id); |
43 } | 35 } |
44 | 36 |
45 void NetworkConnectDelegateChromeOS::ShowNetworkSettings( | 37 void NetworkConnectDelegateChromeOS::ShowNetworkSettings( |
46 const std::string& network_id) { | 38 const std::string& network_id) { |
47 if (!IsUIAvailable()) | 39 if (!IsUIAvailable()) |
48 return; | 40 return; |
49 SystemTrayClient::Get()->ShowNetworkSettings(network_id); | 41 SystemTrayClient::Get()->ShowNetworkSettings(network_id); |
50 } | 42 } |
51 | 43 |
52 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork( | 44 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork( |
53 const std::string& network_id) { | 45 const std::string& network_id) { |
54 if (!IsUIAvailable()) | 46 if (!IsUIAvailable()) |
55 return false; | 47 return false; |
56 return enrollment::CreateDialog(network_id, GetNativeWindow()); | 48 return enrollment::CreateDialog(network_id, nullptr /* owning_window */); |
57 } | 49 } |
58 | 50 |
59 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() { | 51 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() { |
60 if (!IsUIAvailable()) | 52 if (!IsUIAvailable()) |
61 return; | 53 return; |
62 SimDialogDelegate::ShowDialog(GetNativeWindow(), | 54 SimDialogDelegate::ShowDialog(nullptr /* owning_window */, |
63 SimDialogDelegate::SIM_DIALOG_UNLOCK); | 55 SimDialogDelegate::SIM_DIALOG_UNLOCK); |
64 } | 56 } |
65 | 57 |
66 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog( | 58 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog( |
67 const std::string& network_id) { | 59 const std::string& network_id) { |
68 if (!IsUIAvailable()) | 60 if (!IsUIAvailable()) |
69 return; | 61 return; |
70 MobileSetupDialog::ShowByNetworkId(network_id); | 62 MobileSetupDialog::ShowByNetworkId(network_id); |
71 } | 63 } |
72 | 64 |
73 void NetworkConnectDelegateChromeOS::ShowNetworkConnectError( | 65 void NetworkConnectDelegateChromeOS::ShowNetworkConnectError( |
74 const std::string& error_name, | 66 const std::string& error_name, |
75 const std::string& network_id) { | 67 const std::string& network_id) { |
76 network_state_notifier_->ShowNetworkConnectError(error_name, network_id); | 68 network_state_notifier_->ShowNetworkConnectError(error_name, network_id); |
77 } | 69 } |
78 | 70 |
79 void NetworkConnectDelegateChromeOS::ShowMobileActivationError( | 71 void NetworkConnectDelegateChromeOS::ShowMobileActivationError( |
80 const std::string& network_id) { | 72 const std::string& network_id) { |
81 network_state_notifier_->ShowMobileActivationError(network_id); | 73 network_state_notifier_->ShowMobileActivationError(network_id); |
82 } | 74 } |
83 | 75 |
84 } // namespace chromeos | 76 } // namespace chromeos |
OLD | NEW |