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

Side by Side Diff: chrome/browser/ui/webui/options/chromeos/internet_options_handler.cc

Issue 2426473009: mash: Place views Wi-Fi network config dialogs in correct window parent (Closed)
Patch Set: rebase Created 4 years, 2 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
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/options/chromeos/internet_options_handler.h" 5 #include "chrome/browser/ui/webui/options/chromeos/internet_options_handler.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 20 matching lines...) Expand all
31 #include "chromeos/network/network_state_handler.h" 31 #include "chromeos/network/network_state_handler.h"
32 #include "components/onc/onc_constants.h" 32 #include "components/onc/onc_constants.h"
33 #include "components/user_manager/user_manager.h" 33 #include "components/user_manager/user_manager.h"
34 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
35 #include "content/public/browser/web_ui.h" 35 #include "content/public/browser/web_ui.h"
36 #include "extensions/browser/api/vpn_provider/vpn_service.h" 36 #include "extensions/browser/api/vpn_provider/vpn_service.h"
37 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" 37 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
38 #include "third_party/cros_system_api/dbus/service_constants.h" 38 #include "third_party/cros_system_api/dbus/service_constants.h"
39 #include "ui/base/webui/web_ui_util.h" 39 #include "ui/base/webui/web_ui_util.h"
40 #include "ui/chromeos/network/network_connect.h" 40 #include "ui/chromeos/network/network_connect.h"
41 #include "ui/views/widget/widget_parent.h"
41 42
42 namespace chromeos { 43 namespace chromeos {
43 namespace options { 44 namespace options {
44 45
45 namespace { 46 namespace {
46 47
47 const char kAllowOnlyPolicyNetworksToConnect[] = 48 const char kAllowOnlyPolicyNetworksToConnect[] =
48 "allowOnlyPolicyNetworksToConnect"; 49 "allowOnlyPolicyNetworksToConnect";
49 50
50 // Keys for the initial "localized" dictionary values. 51 // Keys for the initial "localized" dictionary values.
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 184 }
184 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode); 185 SimDialogDelegate::ShowDialog(GetNativeWindow(), mode);
185 } 186 }
186 187
187 //////////////////////////////////////////////////////////////////////////////// 188 ////////////////////////////////////////////////////////////////////////////////
188 189
189 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const { 190 gfx::NativeWindow InternetOptionsHandler::GetNativeWindow() const {
190 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 191 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
191 } 192 }
192 193
194 views::WidgetParent InternetOptionsHandler::GetWidgetParent() const {
195 views::WidgetParent widget_parent;
196 widget_parent.native_parent = GetNativeWindow();
197 return widget_parent;
198 }
199
193 const PrefService* InternetOptionsHandler::GetPrefs() const { 200 const PrefService* InternetOptionsHandler::GetPrefs() const {
194 return Profile::FromWebUI(web_ui())->GetPrefs(); 201 return Profile::FromWebUI(web_ui())->GetPrefs();
195 } 202 }
196 203
197 204
198 void InternetOptionsHandler::AddVPNConnection(const base::ListValue* args) { 205 void InternetOptionsHandler::AddVPNConnection(const base::ListValue* args) {
199 if (args->empty()) { 206 if (args->empty()) {
200 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider. 207 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider.
201 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); 208 NetworkConfigView::ShowForType(shill::kTypeVPN, GetWidgetParent());
202 return; 209 return;
203 } 210 }
204 211
205 std::string extension_id; 212 std::string extension_id;
206 if (args->GetSize() != 1 || !args->GetString(0, &extension_id)) { 213 if (args->GetSize() != 1 || !args->GetString(0, &extension_id)) {
207 NOTREACHED(); 214 NOTREACHED();
208 return; 215 return;
209 } 216 }
210 217
211 // Request that the third-party VPN provider identified by |provider_id| 218 // Request that the third-party VPN provider identified by |provider_id|
212 // show its "add network" dialog. 219 // show its "add network" dialog.
213 chromeos::VpnServiceFactory::GetForBrowserContext( 220 chromeos::VpnServiceFactory::GetForBrowserContext(
214 GetProfileForPrimaryUser())->SendShowAddDialogToExtension(extension_id); 221 GetProfileForPrimaryUser())->SendShowAddDialogToExtension(extension_id);
215 } 222 }
216 223
217 void InternetOptionsHandler::AddNonVPNConnection(const base::ListValue* args) { 224 void InternetOptionsHandler::AddNonVPNConnection(const base::ListValue* args) {
218 std::string onc_type; 225 std::string onc_type;
219 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) { 226 if (args->GetSize() != 1 || !args->GetString(0, &onc_type)) {
220 NOTREACHED(); 227 NOTREACHED();
221 return; 228 return;
222 } 229 }
223 if (onc_type == ::onc::network_type::kWiFi) { 230 if (onc_type == ::onc::network_type::kWiFi) {
224 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); 231 NetworkConfigView::ShowForType(shill::kTypeWifi, GetWidgetParent());
225 } else if (onc_type == ::onc::network_type::kCellular) { 232 } else if (onc_type == ::onc::network_type::kCellular) {
226 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 233 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
227 } else { 234 } else {
228 LOG(ERROR) << "Unsupported type for AddConnection"; 235 LOG(ERROR) << "Unsupported type for AddConnection";
229 } 236 }
230 } 237 }
231 238
232 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) { 239 void InternetOptionsHandler::ConfigureNetwork(const base::ListValue* args) {
233 std::string guid; 240 std::string guid;
234 if (args->GetSize() < 1 || !args->GetString(0, &guid)) { 241 if (args->GetSize() < 1 || !args->GetString(0, &guid)) {
(...skipping 21 matching lines...) Expand all
256 network->third_party_vpn_provider_extension_id(), network->name()); 263 network->third_party_vpn_provider_extension_id(), network->name());
257 return; 264 return;
258 } 265 }
259 266
260 // If a network is not connectable, show the enrollment dialog if available. 267 // If a network is not connectable, show the enrollment dialog if available.
261 if (!force_show && !network->connectable() && 268 if (!force_show && !network->connectable() &&
262 enrollment::CreateDialog(service_path, GetNativeWindow())) { 269 enrollment::CreateDialog(service_path, GetNativeWindow())) {
263 return; 270 return;
264 } 271 }
265 272
266 NetworkConfigView::Show(service_path, GetNativeWindow()); 273 NetworkConfigView::Show(service_path, GetWidgetParent());
267 } 274 }
268 275
269 } // namespace options 276 } // namespace options
270 } // namespace chromeos 277 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698