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

Side by Side Diff: chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.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
« no previous file with comments | « chrome/browser/chromeos/status/network_menu.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/ui/webui/options2/chromeos/internet_options_handler2.h" 5 #include "chrome/browser/ui/webui/options2/chromeos/internet_options_handler2.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after
1044 const chromeos::MobileConfig::Carrier* carrier = 1044 const chromeos::MobileConfig::Carrier* carrier =
1045 chromeos::MobileConfig::GetInstance()->GetCarrier(carrier_id); 1045 chromeos::MobileConfig::GetInstance()->GetCarrier(carrier_id);
1046 if (carrier && carrier->show_portal_button()) { 1046 if (carrier && carrier->show_portal_button()) {
1047 // This will trigger BuyDataPlanCallback() so that 1047 // This will trigger BuyDataPlanCallback() so that
1048 // chrome://mobilesetup/ will open carrier specific portal. 1048 // chrome://mobilesetup/ will open carrier specific portal.
1049 dictionary->SetBoolean("showViewAccountButton", true); 1049 dictionary->SetBoolean("showViewAccountButton", true);
1050 } 1050 }
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 void InternetOptionsHandler::CreateModalPopup(views::WidgetDelegate* view) {
1055 views::Widget* window = views::Widget::CreateWindowWithParent(
1056 view, GetNativeWindow());
1057 window->SetAlwaysOnTop(true);
1058 window->Show();
1059 }
1060
1061 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 1054 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
1062 // TODO(beng): This is an improper direct dependency on Browser. Route this 1055 // TODO(beng): This is an improper direct dependency on Browser. Route this
1063 // through some sort of delegate. 1056 // through some sort of delegate.
1064 Browser* browser = 1057 Browser* browser =
1065 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui())); 1058 BrowserList::FindBrowserWithProfile(Profile::FromWebUI(web_ui()));
1066 return browser->window()->GetNativeHandle(); 1059 return browser->window()->GetNativeHandle();
1067 } 1060 }
1068 1061
1069 Browser* InternetOptionsHandler::GetAppropriateBrowser() { 1062 Browser* InternetOptionsHandler::GetAppropriateBrowser() {
1070 return Browser::GetOrCreateTabbedBrowser( 1063 return Browser::GetOrCreateTabbedBrowser(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 } 1099 }
1107 1100
1108 void InternetOptionsHandler::HandleWifiButtonClick( 1101 void InternetOptionsHandler::HandleWifiButtonClick(
1109 const std::string& service_path, 1102 const std::string& service_path,
1110 const std::string& command) { 1103 const std::string& command) {
1111 chromeos::WifiNetwork* wifi = NULL; 1104 chromeos::WifiNetwork* wifi = NULL;
1112 if (command == "forget") { 1105 if (command == "forget") {
1113 cros_->ForgetNetwork(service_path); 1106 cros_->ForgetNetwork(service_path);
1114 } else if (service_path == kOtherNetworksFakePath) { 1107 } else if (service_path == kOtherNetworksFakePath) {
1115 // Other wifi networks. 1108 // Other wifi networks.
1116 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_WIFI)); 1109 chromeos::NetworkConfigView::ShowForType(
1110 chromeos::TYPE_WIFI, GetNativeWindow());
1117 } else if ((wifi = cros_->FindWifiNetworkByPath(service_path))) { 1111 } else if ((wifi = cros_->FindWifiNetworkByPath(service_path))) {
1118 if (command == "connect") { 1112 if (command == "connect") {
1119 wifi->SetEnrollmentDelegate( 1113 wifi->SetEnrollmentDelegate(
1120 chromeos::CreateEnrollmentDelegate(GetNativeWindow(), wifi->name(), 1114 chromeos::CreateEnrollmentDelegate(GetNativeWindow(), wifi->name(),
1121 ProfileManager::GetLastUsedProfile())); 1115 ProfileManager::GetLastUsedProfile()));
1122 wifi->AttemptConnection(base::Bind(&InternetOptionsHandler::DoConnect, 1116 wifi->AttemptConnection(base::Bind(&InternetOptionsHandler::DoConnect,
1123 weak_factory_.GetWeakPtr(), 1117 weak_factory_.GetWeakPtr(),
1124 wifi)); 1118 wifi));
1125 } else if (command == "disconnect") { 1119 } else if (command == "disconnect") {
1126 cros_->DisconnectFromNetwork(wifi); 1120 cros_->DisconnectFromNetwork(wifi);
(...skipping 24 matching lines...) Expand all
1151 1145
1152 void InternetOptionsHandler::HandleVPNButtonClick( 1146 void InternetOptionsHandler::HandleVPNButtonClick(
1153 const std::string& service_path, 1147 const std::string& service_path,
1154 const std::string& command) { 1148 const std::string& command) {
1155 chromeos::VirtualNetwork* network = NULL; 1149 chromeos::VirtualNetwork* network = NULL;
1156 if (command == "forget") { 1150 if (command == "forget") {
1157 cros_->ForgetNetwork(service_path); 1151 cros_->ForgetNetwork(service_path);
1158 } else if (service_path == kOtherNetworksFakePath) { 1152 } else if (service_path == kOtherNetworksFakePath) {
1159 // TODO(altimofeev): verify if service_path in condition is correct. 1153 // TODO(altimofeev): verify if service_path in condition is correct.
1160 // Other VPN networks. 1154 // Other VPN networks.
1161 CreateModalPopup(new chromeos::NetworkConfigView(chromeos::TYPE_VPN)); 1155 chromeos::NetworkConfigView::ShowForType(
1156 chromeos::TYPE_VPN, GetNativeWindow());
1162 } else if ((network = cros_->FindVirtualNetworkByPath(service_path))) { 1157 } else if ((network = cros_->FindVirtualNetworkByPath(service_path))) {
1163 if (command == "connect") { 1158 if (command == "connect") {
1164 network->SetEnrollmentDelegate( 1159 network->SetEnrollmentDelegate(
1165 chromeos::CreateEnrollmentDelegate( 1160 chromeos::CreateEnrollmentDelegate(
1166 GetNativeWindow(), 1161 GetNativeWindow(),
1167 network->name(), 1162 network->name(),
1168 ProfileManager::GetLastUsedProfile())); 1163 ProfileManager::GetLastUsedProfile()));
1169 network->AttemptConnection(base::Bind(&InternetOptionsHandler::DoConnect, 1164 network->AttemptConnection(base::Bind(&InternetOptionsHandler::DoConnect,
1170 weak_factory_.GetWeakPtr(), 1165 weak_factory_.GetWeakPtr(),
1171 network)); 1166 network));
1172 } else if (command == "disconnect") { 1167 } else if (command == "disconnect") {
1173 cros_->DisconnectFromNetwork(network); 1168 cros_->DisconnectFromNetwork(network);
1174 } else if (command == "options") { 1169 } else if (command == "options") {
1175 PopulateDictionaryDetails(network); 1170 PopulateDictionaryDetails(network);
1176 } 1171 }
1177 } 1172 }
1178 } 1173 }
1179 1174
1180 void InternetOptionsHandler::DoConnect(chromeos::Network* network) { 1175 void InternetOptionsHandler::DoConnect(chromeos::Network* network) {
1181 if (network->type() == chromeos::TYPE_VPN) { 1176 if (network->type() == chromeos::TYPE_VPN) {
1182 chromeos::VirtualNetwork* vpn = 1177 chromeos::VirtualNetwork* vpn =
1183 static_cast<chromeos::VirtualNetwork*>(network); 1178 static_cast<chromeos::VirtualNetwork*>(network);
1184 if (vpn->NeedMoreInfoToConnect()) { 1179 if (vpn->NeedMoreInfoToConnect()) {
1185 CreateModalPopup(new chromeos::NetworkConfigView(network)); 1180 chromeos::NetworkConfigView::Show(network, GetNativeWindow());
1186 } else { 1181 } else {
1187 cros_->ConnectToVirtualNetwork(vpn); 1182 cros_->ConnectToVirtualNetwork(vpn);
1188 // Connection failures are responsible for updating the UI, including 1183 // Connection failures are responsible for updating the UI, including
1189 // reopening dialogs. 1184 // reopening dialogs.
1190 } 1185 }
1191 } 1186 }
1192 if (network->type() == chromeos::TYPE_WIFI) { 1187 if (network->type() == chromeos::TYPE_WIFI) {
1193 chromeos::WifiNetwork* wifi = static_cast<chromeos::WifiNetwork*>(network); 1188 chromeos::WifiNetwork* wifi = static_cast<chromeos::WifiNetwork*>(network);
1194 if (wifi->IsPassphraseRequired()) { 1189 if (wifi->IsPassphraseRequired()) {
1195 // Show the connection UI if we require a passphrase. 1190 // Show the connection UI if we require a passphrase.
1196 CreateModalPopup(new chromeos::NetworkConfigView(wifi)); 1191 chromeos::NetworkConfigView::Show(wifi, GetNativeWindow());
1197 } else { 1192 } else {
1198 cros_->ConnectToWifiNetwork(wifi); 1193 cros_->ConnectToWifiNetwork(wifi);
1199 // Connection failures are responsible for updating the UI, including 1194 // Connection failures are responsible for updating the UI, including
1200 // reopening dialogs. 1195 // reopening dialogs.
1201 } 1196 }
1202 } 1197 }
1203 } 1198 }
1204 1199
1205 void InternetOptionsHandler::RefreshCellularPlanCallback( 1200 void InternetOptionsHandler::RefreshCellularPlanCallback(
1206 const ListValue* args) { 1201 const ListValue* args) {
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 if (default_value) 1344 if (default_value)
1350 value_dict->Set("default", default_value->DeepCopy()); 1345 value_dict->Set("default", default_value->DeepCopy());
1351 if (ui_data.managed()) 1346 if (ui_data.managed())
1352 value_dict->SetString("controlledBy", "policy"); 1347 value_dict->SetString("controlledBy", "policy");
1353 else if (ui_data.recommended()) 1348 else if (ui_data.recommended())
1354 value_dict->SetString("controlledBy", "recommended"); 1349 value_dict->SetString("controlledBy", "recommended");
1355 settings->Set(key, value_dict); 1350 settings->Set(key, value_dict);
1356 } 1351 }
1357 1352
1358 } // namespace options2 1353 } // namespace options2
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/status/network_menu.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698