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

Side by Side Diff: chrome/browser/ui/webui/settings/chromeos/internet_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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/settings/chromeos/internet_handler.h" 5 #include "chrome/browser/ui/webui/settings/chromeos/internet_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "chrome/browser/chromeos/options/network_config_view.h" 9 #include "chrome/browser/chromeos/options/network_config_view.h"
10 #include "chrome/browser/chromeos/profiles/profile_helper.h" 10 #include "chrome/browser/chromeos/profiles/profile_helper.h"
11 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h" 11 #include "chrome/browser/chromeos/ui/choose_mobile_network_dialog.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "chromeos/network/network_state.h" 13 #include "chromeos/network/network_state.h"
14 #include "chromeos/network/network_state_handler.h" 14 #include "chromeos/network/network_state_handler.h"
15 #include "components/onc/onc_constants.h" 15 #include "components/onc/onc_constants.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_ui.h" 17 #include "content/public/browser/web_ui.h"
18 #include "extensions/browser/api/vpn_provider/vpn_service.h" 18 #include "extensions/browser/api/vpn_provider/vpn_service.h"
19 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h" 19 #include "extensions/browser/api/vpn_provider/vpn_service_factory.h"
20 #include "third_party/cros_system_api/dbus/service_constants.h" 20 #include "third_party/cros_system_api/dbus/service_constants.h"
21 #include "ui/views/widget/widget_parent.h"
21 22
22 namespace chromeos { 23 namespace chromeos {
23 24
24 namespace { 25 namespace {
25 26
26 const char kAddNetworkMessage[] = "addNetwork"; 27 const char kAddNetworkMessage[] = "addNetwork";
27 const char kConfigureNetworkMessage[] = "configureNetwork"; 28 const char kConfigureNetworkMessage[] = "configureNetwork";
28 29
29 std::string ServicePathFromGuid(const std::string& guid) { 30 std::string ServicePathFromGuid(const std::string& guid) {
30 const NetworkState* network = 31 const NetworkState* network =
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 NOTREACHED() << "Invalid args for: " << kAddNetworkMessage; 68 NOTREACHED() << "Invalid args for: " << kAddNetworkMessage;
68 return; 69 return;
69 } 70 }
70 71
71 if (onc_type == ::onc::network_type::kVPN) { 72 if (onc_type == ::onc::network_type::kVPN) {
72 std::string extension_id; 73 std::string extension_id;
73 if (args->GetSize() >= 2) 74 if (args->GetSize() >= 2)
74 args->GetString(1, &extension_id); 75 args->GetString(1, &extension_id);
75 if (extension_id.empty()) { 76 if (extension_id.empty()) {
76 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider. 77 // Show the "add network" dialog for the built-in OpenVPN/L2TP provider.
77 NetworkConfigView::ShowForType(shill::kTypeVPN, GetNativeWindow()); 78 NetworkConfigView::ShowForType(shill::kTypeVPN, GetWidgetParent());
78 return; 79 return;
79 } 80 }
80 // Request that the third-party VPN provider identified by |provider_id| 81 // Request that the third-party VPN provider identified by |provider_id|
81 // show its "add network" dialog. 82 // show its "add network" dialog.
82 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser()) 83 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser())
83 ->SendShowAddDialogToExtension(extension_id); 84 ->SendShowAddDialogToExtension(extension_id);
84 } else if (onc_type == ::onc::network_type::kWiFi) { 85 } else if (onc_type == ::onc::network_type::kWiFi) {
85 NetworkConfigView::ShowForType(shill::kTypeWifi, GetNativeWindow()); 86 NetworkConfigView::ShowForType(shill::kTypeWifi, GetWidgetParent());
86 } else if (onc_type == ::onc::network_type::kCellular) { 87 } else if (onc_type == ::onc::network_type::kCellular) {
87 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow()); 88 ChooseMobileNetworkDialog::ShowDialog(GetNativeWindow());
88 } else { 89 } else {
89 LOG(ERROR) << "Unsupported type for: " << kAddNetworkMessage; 90 LOG(ERROR) << "Unsupported type for: " << kAddNetworkMessage;
90 } 91 }
91 } 92 }
92 93
93 void InternetHandler::ConfigureNetwork(const base::ListValue* args) { 94 void InternetHandler::ConfigureNetwork(const base::ListValue* args) {
94 std::string guid; 95 std::string guid;
95 if (args->GetSize() < 1 || !args->GetString(0, &guid)) { 96 if (args->GetSize() < 1 || !args->GetString(0, &guid)) {
(...skipping 18 matching lines...) Expand all
114 if (network->type() == shill::kTypeVPN && 115 if (network->type() == shill::kTypeVPN &&
115 network->vpn_provider_type() == shill::kProviderThirdPartyVpn) { 116 network->vpn_provider_type() == shill::kProviderThirdPartyVpn) {
116 // Request that the third-party VPN provider used by the |network| show a 117 // Request that the third-party VPN provider used by the |network| show a
117 // configuration dialog for it. 118 // configuration dialog for it.
118 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser()) 119 VpnServiceFactory::GetForBrowserContext(GetProfileForPrimaryUser())
119 ->SendShowConfigureDialogToExtension( 120 ->SendShowConfigureDialogToExtension(
120 network->third_party_vpn_provider_extension_id(), network->name()); 121 network->third_party_vpn_provider_extension_id(), network->name());
121 return; 122 return;
122 } 123 }
123 124
124 NetworkConfigView::Show(service_path, GetNativeWindow()); 125 NetworkConfigView::Show(service_path, GetWidgetParent());
125 } 126 }
126 127
127 gfx::NativeWindow InternetHandler::GetNativeWindow() const { 128 gfx::NativeWindow InternetHandler::GetNativeWindow() const {
128 return web_ui()->GetWebContents()->GetTopLevelNativeWindow(); 129 return web_ui()->GetWebContents()->GetTopLevelNativeWindow();
129 } 130 }
130 131
132 views::WidgetParent InternetHandler::GetWidgetParent() const {
133 views::WidgetParent widget_parent;
134 widget_parent.native_parent = GetNativeWindow();
135 return widget_parent;
136 }
137
131 } // namespace settings 138 } // namespace settings
132 } // namespace chromeos 139 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698