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

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

Issue 1043343002: Use networkingPrivate.startConnect (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@issue_430115_internet_options_cellular
Patch Set: . Created 5 years, 8 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const char kSetVPNProvidersFunction[] = "options.VPNProviders.setProviders"; 84 const char kSetVPNProvidersFunction[] = "options.VPNProviders.setProviders";
85 const char kRefreshNetworkDataFunction[] = 85 const char kRefreshNetworkDataFunction[] =
86 "options.network.NetworkList.refreshNetworkData"; 86 "options.network.NetworkList.refreshNetworkData";
87 const char kUpdateConnectionDataFunction[] = 87 const char kUpdateConnectionDataFunction[] =
88 "options.internet.DetailsInternetPage.updateConnectionData"; 88 "options.internet.DetailsInternetPage.updateConnectionData";
89 89
90 // JS methods to show additional UI. 90 // JS methods to show additional UI.
91 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo"; 91 const char kShowMorePlanInfoMessage[] = "showMorePlanInfo";
92 const char kSimOperationMessage[] = "simOperation"; 92 const char kSimOperationMessage[] = "simOperation";
93 93
94 // TODO(stevenjb): Replace these with the matching networkingPrivate methods.
95 // crbug.com/279351.
96 const char kStartConnectMessage[] = "startConnect";
97
98 // TODO(stevenjb): Deprecate this once we handle events in the JS. 94 // TODO(stevenjb): Deprecate this once we handle events in the JS.
99 const char kSetNetworkGuidMessage[] = "setNetworkGuid"; 95 const char kSetNetworkGuidMessage[] = "setNetworkGuid";
100 96
101 // TODO(stevenjb): Add these to networkingPrivate. 97 // TODO(stevenjb): Add these to networkingPrivate.
102 const char kRemoveNetworkMessage[] = "removeNetwork"; 98 const char kRemoveNetworkMessage[] = "removeNetwork";
103 99
104 // TODO(stevenjb): Deprecate these and integrate with settings Web UI. 100 // TODO(stevenjb): Deprecate these and integrate with settings Web UI.
105 const char kAddVPNConnectionMessage[] = "addVPNConnection"; 101 const char kAddVPNConnectionMessage[] = "addVPNConnection";
106 const char kAddNonVPNConnectionMessage[] = "addNonVPNConnection"; 102 const char kAddNonVPNConnectionMessage[] = "addNonVPNConnection";
107 const char kConfigureNetworkMessage[] = "configureNetwork"; 103 const char kConfigureNetworkMessage[] = "configureNetwork";
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 base::Bind(&InternetOptionsHandler::SimOperationCallback, 255 base::Bind(&InternetOptionsHandler::SimOperationCallback,
260 base::Unretained(this))); 256 base::Unretained(this)));
261 web_ui()->RegisterMessageCallback( 257 web_ui()->RegisterMessageCallback(
262 kLoadVPNProviders, 258 kLoadVPNProviders,
263 base::Bind(&InternetOptionsHandler::LoadVPNProvidersCallback, 259 base::Bind(&InternetOptionsHandler::LoadVPNProvidersCallback,
264 base::Unretained(this))); 260 base::Unretained(this)));
265 261
266 web_ui()->RegisterMessageCallback(kSetNetworkGuidMessage, 262 web_ui()->RegisterMessageCallback(kSetNetworkGuidMessage,
267 base::Bind(&InternetOptionsHandler::SetNetworkGuidCallback, 263 base::Bind(&InternetOptionsHandler::SetNetworkGuidCallback,
268 base::Unretained(this))); 264 base::Unretained(this)));
269
270 // networkingPrivate methods
271 web_ui()->RegisterMessageCallback(kStartConnectMessage,
272 base::Bind(&InternetOptionsHandler::StartConnectCallback,
273 base::Unretained(this)));
274 } 265 }
275 266
276 void InternetOptionsHandler::OnExtensionLoaded( 267 void InternetOptionsHandler::OnExtensionLoaded(
277 content::BrowserContext* browser_context, 268 content::BrowserContext* browser_context,
278 const extensions::Extension* extension) { 269 const extensions::Extension* extension) {
279 if (IsVPNProvider(extension)) 270 if (IsVPNProvider(extension))
280 UpdateVPNProviders(); 271 UpdateVPNProviders();
281 } 272 }
282 273
283 void InternetOptionsHandler::OnExtensionUnloaded( 274 void InternetOptionsHandler::OnExtensionUnloaded(
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 void InternetOptionsHandler::SetNetworkGuidCallback( 336 void InternetOptionsHandler::SetNetworkGuidCallback(
346 const base::ListValue* args) { 337 const base::ListValue* args) {
347 std::string guid; 338 std::string guid;
348 if (args->GetSize() != 1 || !args->GetString(0, &guid)) { 339 if (args->GetSize() != 1 || !args->GetString(0, &guid)) {
349 NOTREACHED(); 340 NOTREACHED();
350 return; 341 return;
351 } 342 }
352 details_guid_ = guid; 343 details_guid_ = guid;
353 } 344 }
354 345
355
356 ////////////////////////////////////////////////////////////////////////////////
357 // networkingPrivate implementation methods. TODO(stevenjb): Use the
358 // networkingPrivate API directly in the settings JS and deprecate these
359 // methods. crbug.com/279351.
360
361 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) {
362 std::string guid;
363 if (!args->GetString(0, &guid)) {
364 NOTREACHED();
365 return;
366 }
367 std::string service_path = ServicePathFromGuid(guid);
368 if (!service_path.empty())
369 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
370 }
371
372 //////////////////////////////////////////////////////////////////////////////// 346 ////////////////////////////////////////////////////////////////////////////////
373 347
374 void InternetOptionsHandler::UpdateVPNProviders() { 348 void InternetOptionsHandler::UpdateVPNProviders() {
375 extensions::ExtensionRegistry* const registry = 349 extensions::ExtensionRegistry* const registry =
376 GetExtensionRegistryForPrimaryUser(); 350 GetExtensionRegistryForPrimaryUser();
377 351
378 base::ListValue vpn_providers; 352 base::ListValue vpn_providers;
379 const extensions::ExtensionSet& extensions = registry->enabled_extensions(); 353 const extensions::ExtensionSet& extensions = registry->enabled_extensions();
380 for (const auto& extension : extensions) { 354 for (const auto& extension : extensions) {
381 if (IsVPNProvider(extension.get())) { 355 if (IsVPNProvider(extension.get())) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 dictionary->SetBoolean( 616 dictionary->SetBoolean(
643 kTagWimaxAvailable, 617 kTagWimaxAvailable,
644 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 618 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
645 dictionary->SetBoolean( 619 dictionary->SetBoolean(
646 kTagWimaxEnabled, 620 kTagWimaxEnabled,
647 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 621 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
648 } 622 }
649 623
650 } // namespace options 624 } // namespace options
651 } // namespace chromeos 625 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698