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

Side by Side Diff: chrome/browser/chromeos/status/network_menu.cc

Issue 10392097: Prevent showing multiple network config views. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/status/network_menu.h" 5 #include "chrome/browser/chromeos/status/network_menu.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/shell_delegate.h" 10 #include "ash/shell_delegate.h"
(...skipping 1007 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 net::EscapeUrlEncodedData(network_name, false).c_str()); 1018 net::EscapeUrlEncodedData(network_name, false).c_str());
1019 browser->ShowOptionsTab(page); 1019 browser->ShowOptionsTab(page);
1020 } 1020 }
1021 1021
1022 void NetworkMenu::DoConnect(Network* network) { 1022 void NetworkMenu::DoConnect(Network* network) {
1023 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 1023 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
1024 if (network->type() == TYPE_VPN) { 1024 if (network->type() == TYPE_VPN) {
1025 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(network); 1025 VirtualNetwork* vpn = static_cast<VirtualNetwork*>(network);
1026 if (vpn->NeedMoreInfoToConnect()) { 1026 if (vpn->NeedMoreInfoToConnect()) {
1027 // Show the connection UI if info for a field is missing. 1027 // Show the connection UI if info for a field is missing.
1028 NetworkConfigView* view = new NetworkConfigView(vpn); 1028 NetworkConfigView::Show(vpn, delegate()->GetNativeWindow());
1029 views::Widget* window = views::Widget::CreateWindowWithParent(
1030 view, delegate()->GetNativeWindow());
1031 window->SetAlwaysOnTop(true);
1032 window->Show();
1033 } else { 1029 } else {
1034 cros->ConnectToVirtualNetwork(vpn); 1030 cros->ConnectToVirtualNetwork(vpn);
1035 // Connection failures are responsible for updating the UI, including 1031 // Connection failures are responsible for updating the UI, including
1036 // reopening dialogs. 1032 // reopening dialogs.
1037 } 1033 }
1038 } 1034 } else if (network->type() == TYPE_WIFI) {
1039 if (network->type() == TYPE_WIFI) {
1040 WifiNetwork* wifi = static_cast<WifiNetwork*>(network); 1035 WifiNetwork* wifi = static_cast<WifiNetwork*>(network);
1041 if (wifi->IsPassphraseRequired()) { 1036 if (wifi->IsPassphraseRequired()) {
1042 // Show the connection UI if we require a passphrase. 1037 // Show the connection UI if we require a passphrase.
1043 NetworkConfigView* view = new NetworkConfigView(wifi); 1038 NetworkConfigView::Show(wifi, delegate()->GetNativeWindow());
1044 views::Widget* window = views::Widget::CreateWindowWithParent(
1045 view, delegate()->GetNativeWindow());
1046 window->SetAlwaysOnTop(true);
1047 window->Show();
1048 } else { 1039 } else {
1049 cros->ConnectToWifiNetwork(wifi); 1040 cros->ConnectToWifiNetwork(wifi);
1050 // Connection failures are responsible for updating the UI, including 1041 // Connection failures are responsible for updating the UI, including
1051 // reopening dialogs. 1042 // reopening dialogs.
1052 } 1043 }
1053 } 1044 }
1054 } 1045 }
1055 1046
1056 void NetworkMenu::ToggleWifi() { 1047 void NetworkMenu::ToggleWifi() {
1057 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary(); 1048 NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
(...skipping 26 matching lines...) Expand all
1084 } else { 1075 } else {
1085 cros->EnableCellularNetworkDevice(!cros->cellular_enabled()); 1076 cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
1086 } 1077 }
1087 } else { 1078 } else {
1088 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(), 1079 SimDialogDelegate::ShowDialog(delegate()->GetNativeWindow(),
1089 SimDialogDelegate::SIM_DIALOG_UNLOCK); 1080 SimDialogDelegate::SIM_DIALOG_UNLOCK);
1090 } 1081 }
1091 } 1082 }
1092 1083
1093 void NetworkMenu::ShowOtherWifi() { 1084 void NetworkMenu::ShowOtherWifi() {
1094 NetworkConfigView* view = new NetworkConfigView(TYPE_WIFI); 1085 NetworkConfigView::ShowForType(TYPE_WIFI, delegate_->GetNativeWindow());
1095 views::Widget* window = views::Widget::CreateWindowWithParent(
1096 view, delegate_->GetNativeWindow());
1097 window->SetAlwaysOnTop(true);
1098 window->Show();
1099 } 1086 }
1100 1087
1101 void NetworkMenu::ShowOtherCellular() { 1088 void NetworkMenu::ShowOtherCellular() {
1102 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow()); 1089 ChooseMobileNetworkDialog::ShowDialog(delegate_->GetNativeWindow());
1103 } 1090 }
1104 1091
1105 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) { 1092 bool NetworkMenu::ShouldHighlightNetwork(const Network* network) {
1106 return ::ShouldHighlightNetwork(network); 1093 return ::ShouldHighlightNetwork(network);
1107 } 1094 }
1108 1095
1109 Browser* NetworkMenu::GetAppropriateBrowser() const { 1096 Browser* NetworkMenu::GetAppropriateBrowser() const {
1110 DCHECK(chromeos::UserManager::Get()->IsSessionStarted()); 1097 DCHECK(chromeos::UserManager::Get()->IsSessionStarted());
1111 return Browser::GetOrCreateTabbedBrowser( 1098 return Browser::GetOrCreateTabbedBrowser(
1112 ProfileManager::GetDefaultProfileOrOffTheRecord()); 1099 ProfileManager::GetDefaultProfileOrOffTheRecord());
1113 } 1100 }
1114 1101
1115 } // namespace chromeos 1102 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698