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

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

Issue 686503002: Move network_connect code to ui/chromeos/network (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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>
11 #include <vector> 11 #include <vector>
12 12
13 #include "ash/system/chromeos/network/network_connect.h"
14 #include "base/basictypes.h" 13 #include "base/basictypes.h"
15 #include "base/bind.h" 14 #include "base/bind.h"
16 #include "base/bind_helpers.h" 15 #include "base/bind_helpers.h"
17 #include "base/command_line.h" 16 #include "base/command_line.h"
18 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
19 #include "base/values.h" 18 #include "base/values.h"
20 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
21 #include "chrome/browser/chromeos/mobile_config.h" 20 #include "chrome/browser/chromeos/mobile_config.h"
22 #include "chrome/browser/chromeos/net/onc_utils.h" 21 #include "chrome/browser/chromeos/net/onc_utils.h"
23 #include "chrome/browser/chromeos/options/network_config_view.h" 22 #include "chrome/browser/chromeos/options/network_config_view.h"
(...skipping 24 matching lines...) Expand all
48 #include "chromeos/network/onc/onc_translation_tables.h" 47 #include "chromeos/network/onc/onc_translation_tables.h"
49 #include "chromeos/network/onc/onc_translator.h" 48 #include "chromeos/network/onc/onc_translator.h"
50 #include "chromeos/network/onc/onc_utils.h" 49 #include "chromeos/network/onc/onc_utils.h"
51 #include "components/onc/onc_constants.h" 50 #include "components/onc/onc_constants.h"
52 #include "content/public/browser/web_contents.h" 51 #include "content/public/browser/web_contents.h"
53 #include "content/public/browser/web_ui.h" 52 #include "content/public/browser/web_ui.h"
54 #include "grit/ui_chromeos_resources.h" 53 #include "grit/ui_chromeos_resources.h"
55 #include "third_party/cros_system_api/dbus/service_constants.h" 54 #include "third_party/cros_system_api/dbus/service_constants.h"
56 #include "ui/base/resource/resource_bundle.h" 55 #include "ui/base/resource/resource_bundle.h"
57 #include "ui/base/webui/web_ui_util.h" 56 #include "ui/base/webui/web_ui_util.h"
57 #include "ui/chromeos/network/network_connect.h"
58 #include "ui/chromeos/network/network_icon.h" 58 #include "ui/chromeos/network/network_icon.h"
59 #include "ui/gfx/image/image_skia.h" 59 #include "ui/gfx/image/image_skia.h"
60 60
61 namespace chromeos { 61 namespace chromeos {
62 namespace options { 62 namespace options {
63 63
64 namespace { 64 namespace {
65 65
66 // Keys for the network description dictionary passed to the web ui. Make sure 66 // Keys for the network description dictionary passed to the web ui. Make sure
67 // to keep the strings in sync with what the JavaScript side uses. 67 // to keep the strings in sync with what the JavaScript side uses.
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 240
241 scoped_ptr<base::DictionaryValue> PopulateConnectionDetails( 241 scoped_ptr<base::DictionaryValue> PopulateConnectionDetails(
242 const NetworkState* network, 242 const NetworkState* network,
243 const base::DictionaryValue& onc_properties) { 243 const base::DictionaryValue& onc_properties) {
244 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy()); 244 scoped_ptr<base::DictionaryValue> dictionary(onc_properties.DeepCopy());
245 245
246 // Append Service Path for now. 246 // Append Service Path for now.
247 dictionary->SetString(kNetworkInfoKeyServicePath, network->path()); 247 dictionary->SetString(kNetworkInfoKeyServicePath, network->path());
248 // Append a Chrome specific translated error message. 248 // Append a Chrome specific translated error message.
249 dictionary->SetString(kTagErrorMessage, 249 dictionary->SetString(kTagErrorMessage,
250 ash::NetworkConnect::Get()->GetErrorString( 250 ui::NetworkConnect::Get()->GetErrorString(
251 network->error(), network->path())); 251 network->error(), network->path()));
252 252
253 return dictionary.Pass(); 253 return dictionary.Pass();
254 } 254 }
255 255
256 // Helper methods for SetIPConfigProperties 256 // Helper methods for SetIPConfigProperties
257 bool AppendPropertyKeyIfPresent(const std::string& key, 257 bool AppendPropertyKeyIfPresent(const std::string& key,
258 const base::DictionaryValue& old_properties, 258 const base::DictionaryValue& old_properties,
259 std::vector<std::string>* property_keys) { 259 std::vector<std::string>* property_keys) {
260 if (old_properties.HasKey(key)) { 260 if (old_properties.HasKey(key)) {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 void InternetOptionsHandler::ShowMorePlanInfoCallback( 391 void InternetOptionsHandler::ShowMorePlanInfoCallback(
392 const base::ListValue* args) { 392 const base::ListValue* args) {
393 if (!web_ui()) 393 if (!web_ui())
394 return; 394 return;
395 std::string service_path; 395 std::string service_path;
396 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) { 396 if (args->GetSize() != 1 || !args->GetString(0, &service_path)) {
397 NOTREACHED(); 397 NOTREACHED();
398 return; 398 return;
399 } 399 }
400 ash::NetworkConnect::Get()->ShowMobileSetup(service_path); 400 ui::NetworkConnect::Get()->ShowMobileSetup(service_path);
401 } 401 }
402 402
403 void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) { 403 void InternetOptionsHandler::SetApnCallback(const base::ListValue* args) {
404 std::string service_path; 404 std::string service_path;
405 if (!args->GetString(0, &service_path)) { 405 if (!args->GetString(0, &service_path)) {
406 NOTREACHED(); 406 NOTREACHED();
407 return; 407 return;
408 } 408 }
409 NetworkHandler::Get()->network_configuration_handler()->GetProperties( 409 NetworkHandler::Get()->network_configuration_handler()->GetProperties(
410 service_path, 410 service_path,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 } 460 }
461 461
462 void InternetOptionsHandler::CarrierStatusCallback() { 462 void InternetOptionsHandler::CarrierStatusCallback() {
463 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); 463 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler();
464 const DeviceState* device = 464 const DeviceState* device =
465 handler->GetDeviceStateByType(NetworkTypePattern::Cellular()); 465 handler->GetDeviceStateByType(NetworkTypePattern::Cellular());
466 if (device && (device->carrier() == shill::kCarrierSprint)) { 466 if (device && (device->carrier() == shill::kCarrierSprint)) {
467 const NetworkState* network = 467 const NetworkState* network =
468 handler->FirstNetworkByType(NetworkTypePattern::Cellular()); 468 handler->FirstNetworkByType(NetworkTypePattern::Cellular());
469 if (network && network->path() == details_path_) { 469 if (network && network->path() == details_path_) {
470 ash::NetworkConnect::Get()->ActivateCellular(network->path()); 470 ui::NetworkConnect::Get()->ActivateCellular(network->path());
471 UpdateConnectionData(network->path()); 471 UpdateConnectionData(network->path());
472 } 472 }
473 } 473 }
474 UpdateCarrier(); 474 UpdateCarrier();
475 } 475 }
476 476
477 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) { 477 void InternetOptionsHandler::SetCarrierCallback(const base::ListValue* args) {
478 std::string service_path; 478 std::string service_path;
479 std::string carrier; 479 std::string carrier;
480 if (args->GetSize() != 2 || 480 if (args->GetSize() != 2 ||
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 const base::ListValue* args) { 579 const base::ListValue* args) {
580 NetworkHandler::Get()->network_state_handler()->RequestScan(); 580 NetworkHandler::Get()->network_state_handler()->RequestScan();
581 } 581 }
582 582
583 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) { 583 void InternetOptionsHandler::StartConnectCallback(const base::ListValue* args) {
584 std::string service_path; 584 std::string service_path;
585 if (!args->GetString(0, &service_path)) { 585 if (!args->GetString(0, &service_path)) {
586 NOTREACHED(); 586 NOTREACHED();
587 return; 587 return;
588 } 588 }
589 ash::NetworkConnect::Get()->ConnectToNetwork(service_path); 589 ui::NetworkConnect::Get()->ConnectToNetwork(service_path);
590 } 590 }
591 591
592 void InternetOptionsHandler::StartDisconnectCallback( 592 void InternetOptionsHandler::StartDisconnectCallback(
593 const base::ListValue* args) { 593 const base::ListValue* args) {
594 std::string service_path; 594 std::string service_path;
595 if (!args->GetString(0, &service_path)) { 595 if (!args->GetString(0, &service_path)) {
596 NOTREACHED(); 596 NOTREACHED();
597 return; 597 return;
598 } 598 }
599 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork( 599 NetworkHandler::Get()->network_connection_handler()->DisconnectNetwork(
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 NetworkHandler::Get()->network_configuration_handler()-> 885 NetworkHandler::Get()->network_configuration_handler()->
886 RemoveConfiguration( 886 RemoveConfiguration(
887 service_path, 887 service_path,
888 base::Bind(&base::DoNothing), 888 base::Bind(&base::DoNothing),
889 base::Bind(&ShillError, "NetworkCommand: " + command)); 889 base::Bind(&ShillError, "NetworkCommand: " + command));
890 } else if (command == kTagShowDetails) { 890 } else if (command == kTagShowDetails) {
891 SendShowDetailedInfo(service_path); 891 SendShowDetailedInfo(service_path);
892 } else if (command == kTagConfigure) { 892 } else if (command == kTagConfigure) {
893 NetworkConfigView::Show(service_path, GetNativeWindow()); 893 NetworkConfigView::Show(service_path, GetNativeWindow());
894 } else if (command == kTagActivate && type == shill::kTypeCellular) { 894 } else if (command == kTagActivate && type == shill::kTypeCellular) {
895 ash::NetworkConnect::Get()->ActivateCellular(service_path); 895 ui::NetworkConnect::Get()->ActivateCellular(service_path);
896 // Activation may update network properties (e.g. ActivationState), so 896 // Activation may update network properties (e.g. ActivationState), so
897 // request them here in case they change. 897 // request them here in case they change.
898 UpdateConnectionData(service_path); 898 UpdateConnectionData(service_path);
899 } else { 899 } else {
900 LOG(ERROR) << "Unknown internet options command: " << command; 900 LOG(ERROR) << "Unknown internet options command: " << command;
901 NOTREACHED(); 901 NOTREACHED();
902 } 902 }
903 } 903 }
904 904
905 void InternetOptionsHandler::AddConnection(const std::string& type) { 905 void InternetOptionsHandler::AddConnection(const std::string& type) {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 dictionary->SetBoolean( 1031 dictionary->SetBoolean(
1032 kTagWimaxAvailable, 1032 kTagWimaxAvailable,
1033 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax())); 1033 handler->IsTechnologyAvailable(NetworkTypePattern::Wimax()));
1034 dictionary->SetBoolean( 1034 dictionary->SetBoolean(
1035 kTagWimaxEnabled, 1035 kTagWimaxEnabled,
1036 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax())); 1036 handler->IsTechnologyEnabled(NetworkTypePattern::Wimax()));
1037 } 1037 }
1038 1038
1039 } // namespace options 1039 } // namespace options
1040 } // namespace chromeos 1040 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698