Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: chrome/browser/chromeos/net/network_connect_delegate_chromeos.cc

Issue 2452283003: chromeos: Make network enrollment and SIM unlock dialogs work with mash (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
15
16 namespace { 16 namespace {
17 17
18 bool IsUIAvailable() { 18 bool IsUIAvailable() {
19 return ash::WmShell::HasInstance() && 19 // UI is available when screen is unlocked.
20 !ash::WmShell::Get()->GetSessionStateDelegate()->IsScreenLocked(); 20 return !ScreenLocker::default_screen_locker() ||
21 } 21 !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 } 22 }
28 23
29 } // namespace 24 } // namespace
30 25
31 namespace chromeos {
32
33 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() 26 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS()
34 : network_state_notifier_(new NetworkStateNotifier()) {} 27 : network_state_notifier_(new NetworkStateNotifier()) {}
35 28
36 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {} 29 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {}
37 30
38 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure( 31 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure(
39 const std::string& network_id) { 32 const std::string& network_id) {
40 if (!IsUIAvailable()) 33 if (!IsUIAvailable())
41 return; 34 return;
42 SystemTrayClient::Get()->ShowNetworkConfigure(network_id); 35 SystemTrayClient::Get()->ShowNetworkConfigure(network_id);
43 } 36 }
44 37
45 void NetworkConnectDelegateChromeOS::ShowNetworkSettings( 38 void NetworkConnectDelegateChromeOS::ShowNetworkSettings(
46 const std::string& network_id) { 39 const std::string& network_id) {
47 if (!IsUIAvailable()) 40 if (!IsUIAvailable())
48 return; 41 return;
49 SystemTrayClient::Get()->ShowNetworkSettings(network_id); 42 SystemTrayClient::Get()->ShowNetworkSettings(network_id);
50 } 43 }
51 44
52 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork( 45 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork(
53 const std::string& network_id) { 46 const std::string& network_id) {
54 if (!IsUIAvailable()) 47 if (!IsUIAvailable())
55 return false; 48 return false;
56 return enrollment::CreateEnrollmentDialog(network_id, GetNativeWindow()); 49 return enrollment::CreateEnrollmentDialog(network_id,
50 nullptr /* owning_window */);
57 } 51 }
58 52
59 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() { 53 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() {
60 if (!IsUIAvailable()) 54 if (!IsUIAvailable())
61 return; 55 return;
62 SimDialogDelegate::ShowDialog(GetNativeWindow(), 56 SimDialogDelegate::ShowDialog(nullptr /* owning_window */,
63 SimDialogDelegate::SIM_DIALOG_UNLOCK); 57 SimDialogDelegate::SIM_DIALOG_UNLOCK);
64 } 58 }
65 59
66 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog( 60 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog(
67 const std::string& network_id) { 61 const std::string& network_id) {
68 if (!IsUIAvailable()) 62 if (!IsUIAvailable())
69 return; 63 return;
70 MobileSetupDialog::ShowByNetworkId(network_id); 64 MobileSetupDialog::ShowByNetworkId(network_id);
71 } 65 }
72 66
73 void NetworkConnectDelegateChromeOS::ShowNetworkConnectError( 67 void NetworkConnectDelegateChromeOS::ShowNetworkConnectError(
74 const std::string& error_name, 68 const std::string& error_name,
75 const std::string& network_id) { 69 const std::string& network_id) {
76 network_state_notifier_->ShowNetworkConnectError(error_name, network_id); 70 network_state_notifier_->ShowNetworkConnectError(error_name, network_id);
77 } 71 }
78 72
79 void NetworkConnectDelegateChromeOS::ShowMobileActivationError( 73 void NetworkConnectDelegateChromeOS::ShowMobileActivationError(
80 const std::string& network_id) { 74 const std::string& network_id) {
81 network_state_notifier_->ShowMobileActivationError(network_id); 75 network_state_notifier_->ShowMobileActivationError(network_id);
82 } 76 }
83 77
84 } // namespace chromeos 78 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/net/DEPS ('k') | chrome/browser/chromeos/net/network_portal_notification_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698