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

Unified Diff: chrome/browser/chromeos/network_login_observer.cc

Issue 6027012: Fix so that login errors are shown from login/oobe screens.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 11 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/network_login_observer.cc
===================================================================
--- chrome/browser/chromeos/network_login_observer.cc (revision 0)
+++ chrome/browser/chromeos/network_login_observer.cc (revision 0)
@@ -0,0 +1,102 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/network_login_observer.h"
+
+#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_window.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/network_library.h"
+#include "chrome/browser/chromeos/login/background_view.h"
+#include "chrome/browser/chromeos/login/login_utils.h"
+#include "chrome/browser/chromeos/options/network_config_view.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/browser/ui/views/window.h"
+#include "views/window/dialog_delegate.h"
+#include "views/window/window.h"
+
+namespace chromeos {
+
+NetworkLoginObserver::NetworkLoginObserver(NetworkLibrary* netlib) {
+ RefreshStoredNetworks(netlib->wifi_networks());
+ netlib->AddNetworkManagerObserver(this);
+}
+
+NetworkLoginObserver::~NetworkLoginObserver() {
+ CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this);
+}
+
+void NetworkLoginObserver::CreateModalPopup(views::WindowDelegate* view) {
+ Browser* browser = BrowserList::GetLastActive();
+ if (browser && browser->type() != Browser::TYPE_NORMAL) {
+ browser = BrowserList::FindBrowserWithType(browser->profile(),
+ Browser::TYPE_NORMAL,
+ true);
+ }
+ if (browser) {
+ views::Window* window = browser::CreateViewsWindow(
+ browser->window()->GetNativeHandle(), gfx::Rect(), view);
+ window->SetIsAlwaysOnTop(true);
+ window->Show();
+ } else {
+ // Browser not found, so we should be in login/oobe screen.
+ BackgroundView* background_view = LoginUtils::Get()->GetBackgroundView();
+ if (background_view) {
+ background_view->CreateModalPopup(view);
+ }
+ }
+}
+
+void NetworkLoginObserver::RefreshStoredNetworks(
+ const WifiNetworkVector& wifi_networks) {
+ wifi_network_failures_.clear();
+ for (WifiNetworkVector::const_iterator it = wifi_networks.begin();
+ it < wifi_networks.end(); it++) {
+ const WifiNetwork* wifi = *it;
+ wifi_network_failures_[wifi->service_path()] = wifi->failed();
+ }
+}
+
+void NetworkLoginObserver::OnNetworkManagerChanged(NetworkLibrary* obj) {
+ const WifiNetworkVector& wifi_networks = obj->wifi_networks();
+
+ NetworkConfigView* view = NULL;
+ // Check to see if we have any newly failed wifi network.
+ for (WifiNetworkVector::const_iterator it = wifi_networks.begin();
+ it < wifi_networks.end(); it++) {
+ const WifiNetwork* wifi = *it;
+ if (wifi->failed()) {
+ WifiFailureMap::iterator iter =
+ wifi_network_failures_.find(wifi->service_path());
+ // If the network did not previously exist, then don't do anything.
+ // For example, if the user travels to a location and finds a service
+ // that has previously failed, we don't want to show an error.
+ if (iter == wifi_network_failures_.end())
+ continue;
+
+ // If this network was in a failed state previously, then it's not new.
+ if (iter->second)
+ continue;
+
+ // Display login box again for bad_passphrase and bad_wepkey errors.
+ if (wifi->error() == ERROR_BAD_PASSPHRASE ||
+ wifi->error() == ERROR_BAD_WEPKEY) {
+ // The NetworkConfigView will show the appropriate error message.
+ view = new NetworkConfigView(wifi);
+ // There should only be one wifi network that failed to connect.
+ // If for some reason, we have more than one failure,
+ // we only display the first one. So we break here.
+ break;
+ }
+ }
+ }
+
+ RefreshStoredNetworks(wifi_networks);
+
+ // Show login box if necessary.
+ if (view)
+ CreateModalPopup(view);
+}
+
+} // namespace chromeos
Property changes on: chrome/browser/chromeos/network_login_observer.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « chrome/browser/chromeos/network_login_observer.h ('k') | chrome/browser/chromeos/network_message_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698