| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/network_login_observer.h" | 5 #include "chrome/browser/chromeos/network_login_observer.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/cros/cros_library.h" | 7 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 8 #include "chrome/browser/chromeos/cros/network_library.h" | 8 #include "chrome/browser/chromeos/cros/network_library.h" |
| 9 #include "chrome/browser/chromeos/login/base_login_display_host.h" | 9 #include "chrome/browser/chromeos/login/base_login_display_host.h" |
| 10 #include "chrome/browser/chromeos/options/network_config_view.h" | 10 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 11 #include "chrome/browser/profiles/profile_manager.h" | 11 #include "chrome/browser/profiles/profile_manager.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_list.h" | 13 #include "chrome/browser/ui/browser_finder.h" |
| 14 #include "chrome/browser/ui/browser_window.h" | 14 #include "chrome/browser/ui/browser_window.h" |
| 15 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 16 #include "ui/views/widget/widget_delegate.h" | 16 #include "ui/views/widget/widget_delegate.h" |
| 17 | 17 |
| 18 namespace chromeos { | 18 namespace chromeos { |
| 19 | 19 |
| 20 NetworkLoginObserver::NetworkLoginObserver(NetworkLibrary* netlib) { | 20 NetworkLoginObserver::NetworkLoginObserver(NetworkLibrary* netlib) { |
| 21 netlib->AddNetworkManagerObserver(this); | 21 netlib->AddNetworkManagerObserver(this); |
| 22 } | 22 } |
| 23 | 23 |
| 24 NetworkLoginObserver::~NetworkLoginObserver() { | 24 NetworkLoginObserver::~NetworkLoginObserver() { |
| 25 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); | 25 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
| 26 } | 26 } |
| 27 | 27 |
| 28 void NetworkLoginObserver::CreateModalPopup(views::WidgetDelegate* view) { | 28 void NetworkLoginObserver::CreateModalPopup(views::WidgetDelegate* view) { |
| 29 gfx::NativeWindow parent = NULL; | 29 gfx::NativeWindow parent = NULL; |
| 30 if (BaseLoginDisplayHost::default_host()) { | 30 if (BaseLoginDisplayHost::default_host()) { |
| 31 parent = BaseLoginDisplayHost::default_host()->GetNativeWindow(); | 31 parent = BaseLoginDisplayHost::default_host()->GetNativeWindow(); |
| 32 } else { | 32 } else { |
| 33 Browser* browser = BrowserList::FindTabbedBrowser( | 33 Browser* browser = browser::FindTabbedBrowser( |
| 34 ProfileManager::GetDefaultProfileOrOffTheRecord(), true); | 34 ProfileManager::GetDefaultProfileOrOffTheRecord(), true); |
| 35 parent = browser ? browser->window()->GetNativeHandle() : NULL; | 35 parent = browser ? browser->window()->GetNativeHandle() : NULL; |
| 36 } | 36 } |
| 37 views::Widget* window = views::Widget::CreateWindowWithParent(view, parent); | 37 views::Widget* window = views::Widget::CreateWindowWithParent(view, parent); |
| 38 window->SetAlwaysOnTop(true); | 38 window->SetAlwaysOnTop(true); |
| 39 window->Show(); | 39 window->Show(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { | 42 void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* cros) { |
| 43 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); | 43 const WifiNetworkVector& wifi_networks = cros->wifi_networks(); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 // Display login dialog for any error or newly added network. | 75 // Display login dialog for any error or newly added network. |
| 76 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { | 76 if (vpn->error() != ERROR_NO_ERROR || vpn->added()) { |
| 77 CreateModalPopup(new NetworkConfigView(vpn)); | 77 CreateModalPopup(new NetworkConfigView(vpn)); |
| 78 return; // Only support one failure per notification. | 78 return; // Only support one failure per notification. |
| 79 } | 79 } |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace chromeos | 84 } // namespace chromeos |
| OLD | NEW |