Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / ash / network_connect_delegate_chromeos.cc
blobdb74f16161989fab154495ad361d9a7aed32e40a
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/ash/network_connect_delegate_chromeos.h"
7 #include "ash/session/session_state_delegate.h"
8 #include "ash/shell.h"
9 #include "ash/shell_window_ids.h"
10 #include "ash/system/tray/system_tray_delegate.h"
11 #include "ash/system/user/login_status.h"
12 #include "chrome/browser/chromeos/enrollment_dialog_view.h"
13 #include "chrome/browser/chromeos/options/network_config_view.h"
14 #include "chrome/browser/chromeos/sim_dialog_delegate.h"
15 #include "chrome/browser/ui/webui/chromeos/mobile_setup_dialog.h"
17 namespace {
19 bool IsUIAvailable() {
20 return ash::Shell::GetInstance() &&
21 !ash::Shell::GetInstance()->session_state_delegate()->IsScreenLocked();
24 gfx::NativeWindow GetNativeWindow() {
25 bool session_started = ash::Shell::GetInstance()
26 ->session_state_delegate()
27 ->IsActiveUserSessionStarted();
28 ash::user::LoginStatus login_status =
29 ash::Shell::GetInstance()->system_tray_delegate()->GetUserLoginStatus();
30 bool isUserAddingRunning = ash::Shell::GetInstance()
31 ->session_state_delegate()
32 ->IsInSecondaryLoginScreen();
34 int container_id =
35 (!session_started || login_status == ash::user::LOGGED_IN_NONE ||
36 login_status == ash::user::LOGGED_IN_LOCKED || isUserAddingRunning)
37 ? ash::kShellWindowId_LockSystemModalContainer
38 : ash::kShellWindowId_SystemModalContainer;
39 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
40 container_id);
43 } // namespace
45 namespace chromeos {
47 NetworkConnectDelegateChromeOS::NetworkConnectDelegateChromeOS() {
50 NetworkConnectDelegateChromeOS::~NetworkConnectDelegateChromeOS() {
53 void NetworkConnectDelegateChromeOS::ShowNetworkConfigure(
54 const std::string& network_id) {
55 if (!IsUIAvailable())
56 return;
57 NetworkConfigView::Show(network_id, GetNativeWindow());
60 void NetworkConnectDelegateChromeOS::ShowNetworkSettingsForGuid(
61 const std::string& network_id) {
62 if (!IsUIAvailable())
63 return;
64 ash::Shell::GetInstance()->system_tray_delegate()->ShowNetworkSettingsForGuid(
65 network_id);
68 bool NetworkConnectDelegateChromeOS::ShowEnrollNetwork(
69 const std::string& network_id) {
70 if (!IsUIAvailable())
71 return false;
72 return enrollment::CreateDialog(network_id, GetNativeWindow());
75 void NetworkConnectDelegateChromeOS::ShowMobileSimDialog() {
76 if (!IsUIAvailable())
77 return;
78 SimDialogDelegate::ShowDialog(GetNativeWindow(),
79 SimDialogDelegate::SIM_DIALOG_UNLOCK);
82 void NetworkConnectDelegateChromeOS::ShowMobileSetupDialog(
83 const std::string& service_path) {
84 if (!IsUIAvailable())
85 return;
86 MobileSetupDialog::Show(service_path);
89 } // namespace chromeos