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

Side by Side Diff: chrome/browser/automation/testing_automation_provider_chromeos.cc

Issue 16045005: Migrate auto_tests about proxy configuration to browser_tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 6 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
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/automation/testing_automation_provider.h" 5 #include "chrome/browser/automation/testing_automation_provider.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/shell_delegate.h" 8 #include "ash/shell_delegate.h"
9 #include "ash/system/tray/system_tray_delegate.h" 9 #include "ash/system/tray/system_tray_delegate.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 } 73 }
74 74
75 DictionaryValue* GetWifiInfoDict(const chromeos::WifiNetwork* wifi) { 75 DictionaryValue* GetWifiInfoDict(const chromeos::WifiNetwork* wifi) {
76 DictionaryValue* item = GetNetworkInfoDict(wifi); 76 DictionaryValue* item = GetNetworkInfoDict(wifi);
77 item->SetInteger("strength", wifi->strength()); 77 item->SetInteger("strength", wifi->strength());
78 item->SetBoolean("encrypted", wifi->encrypted()); 78 item->SetBoolean("encrypted", wifi->encrypted());
79 item->SetString("encryption", wifi->GetEncryptionString()); 79 item->SetString("encryption", wifi->GetEncryptionString());
80 return item; 80 return item;
81 } 81 }
82 82
83 base::Value* GetProxySetting(const std::string& setting_name,
84 Profile* profile) {
85 std::string setting_path = "cros.session.proxy.";
86 setting_path.append(setting_name);
87 base::Value* setting;
88 if (chromeos::proxy_cros_settings_parser::GetProxyPrefValue(
89 profile, setting_path, &setting)) {
90 scoped_ptr<DictionaryValue> setting_dict(
91 static_cast<DictionaryValue*>(setting));
92 base::Value* value;
93 if (setting_dict->Remove("value", &value))
94 return value;
95 }
96
97 return NULL;
98 }
99
100 const char* UpdateStatusToString( 83 const char* UpdateStatusToString(
101 UpdateEngineClient::UpdateStatusOperation status) { 84 UpdateEngineClient::UpdateStatusOperation status) {
102 switch (status) { 85 switch (status) {
103 case UpdateEngineClient::UPDATE_STATUS_IDLE: 86 case UpdateEngineClient::UPDATE_STATUS_IDLE:
104 return "idle"; 87 return "idle";
105 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE: 88 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
106 return "checking for update"; 89 return "checking for update";
107 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE: 90 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
108 return "update available"; 91 return "update available";
109 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING: 92 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 network_library->EnableWifiNetworkDevice(enable); 657 network_library->EnableWifiNetworkDevice(enable);
675 } else if (device == "cellular") { 658 } else if (device == "cellular") {
676 network_library->EnableCellularNetworkDevice(enable); 659 network_library->EnableCellularNetworkDevice(enable);
677 } else { 660 } else {
678 reply.SendError( 661 reply.SendError(
679 "Unknown device. Valid devices are ethernet, wifi, cellular."); 662 "Unknown device. Valid devices are ethernet, wifi, cellular.");
680 return; 663 return;
681 } 664 }
682 } 665 }
683 666
684 void TestingAutomationProvider::GetProxySettings(DictionaryValue* args,
685 IPC::Message* reply_message) {
686 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport",
687 "httpurl", "httpport", "httpsurl", "httpsport",
688 "type", "single", "ftpurl", "ftpport",
689 "socks", "socksport", "ignorelist" };
690 AutomationJSONReply reply(this, reply_message);
691 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
692
693 std::string error_message;
694 Profile* profile =
695 automation_util::GetCurrentProfileOnChromeOS(&error_message);
696 if (!profile) {
697 reply.SendError(error_message);
698 return;
699 }
700 for (size_t i = 0; i < arraysize(settings); ++i) {
701 base::Value* setting =
702 GetProxySetting(settings[i], profile);
703 if (setting)
704 return_value->Set(settings[i], setting);
705 }
706 reply.SendSuccess(return_value.get());
707 }
708
709 void TestingAutomationProvider::SetSharedProxies( 667 void TestingAutomationProvider::SetSharedProxies(
710 DictionaryValue* args, 668 DictionaryValue* args,
711 IPC::Message* reply_message) { 669 IPC::Message* reply_message) {
712 670
713 AutomationJSONReply reply(this, reply_message); 671 AutomationJSONReply reply(this, reply_message);
714 base::Value* value; 672 base::Value* value;
715 if (!args->Get("value", &value)) { 673 if (!args->Get("value", &value)) {
716 reply.SendError("Invalid or missing value argument."); 674 reply.SendError("Invalid or missing value argument.");
717 return; 675 return;
718 } 676 }
719 std::string proxy_setting_type;
720 std::string setting_path = prefs::kUseSharedProxies;
721 std::string error_message; 677 std::string error_message;
722 Profile* profile = 678 Profile* profile =
723 automation_util::GetCurrentProfileOnChromeOS(&error_message); 679 automation_util::GetCurrentProfileOnChromeOS(&error_message);
724 if (!profile) { 680 if (!profile) {
725 reply.SendError(error_message); 681 reply.SendError(error_message);
726 return; 682 return;
727 } 683 }
728 PrefService* pref_service = profile->GetPrefs(); 684 PrefService* pref_service = profile->GetPrefs();
729 pref_service->Set(setting_path.c_str(), *value); 685 pref_service->Set(prefs::kUseSharedProxies, *value);
730 reply.SendSuccess(NULL);
731 }
732
733 void TestingAutomationProvider::RefreshInternetDetails(
734 DictionaryValue* args,
735 IPC::Message* reply_message) {
736
737 AutomationJSONReply reply(this, reply_message);
738 std::string service_path;
739 if (!args->GetString("service path", &service_path)) {
740 reply.SendError("missing service path.");
741 return;
742 }
743 std::string error_message;
744 Profile* profile =
745 automation_util::GetCurrentProfileOnChromeOS(&error_message);
746 if (!profile) {
747 reply.SendError(error_message);
748 return;
749 }
750 chromeos::ProxyConfigServiceImpl* config_service =
751 profile->GetProxyConfigTracker();
752 if (!config_service) {
753 reply.SendError("Unable to get proxy configuration.");
754 return;
755 }
756 config_service->UISetCurrentNetwork(service_path);
757 reply.SendSuccess(NULL); 686 reply.SendSuccess(NULL);
758 } 687 }
759 688
760 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, 689 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args,
761 IPC::Message* reply_message) { 690 IPC::Message* reply_message) {
762 AutomationJSONReply reply(this, reply_message); 691 AutomationJSONReply reply(this, reply_message);
763 std::string key; 692 std::string proxy_config;
764 base::Value* value; 693 if (!args->GetString("proxy_config", &proxy_config)) {
765 if (!args->GetString("key", &key) || !args->Get("value", &value)) {
766 reply.SendError("Invalid or missing args."); 694 reply.SendError("Invalid or missing args.");
767 return; 695 return;
768 } 696 }
769 std::string error_message; 697
770 Profile* profile = 698 NetworkLibrary* network_library = CrosLibrary::Get()->GetNetworkLibrary();
771 automation_util::GetCurrentProfileOnChromeOS(&error_message); 699 chromeos::Network* network =
772 if (!profile) { 700 const_cast<chromeos::Network*>(network_library->active_network());
773 reply.SendError(error_message); 701
702 if (!network) {
703 reply.SendError("No network connected.");
774 return; 704 return;
775 } 705 }
776 // ProxyCrosSettingsProvider will own the Value* passed to Set(). 706
777 std::string setting_path = "cros.session.proxy."; 707 network->SetProxyConfig(proxy_config);
778 setting_path.append(key);
779 chromeos::proxy_cros_settings_parser::SetProxyPrefValue(
780 profile, setting_path, value);
781 reply.SendSuccess(NULL); 708 reply.SendSuccess(NULL);
782 } 709 }
783 710
784 void TestingAutomationProvider::ConnectToCellularNetwork( 711 void TestingAutomationProvider::ConnectToCellularNetwork(
785 DictionaryValue* args, IPC::Message* reply_message) { 712 DictionaryValue* args, IPC::Message* reply_message) {
786 std::string service_path; 713 std::string service_path;
787 if (!args->GetString("service_path", &service_path)) { 714 if (!args->GetString("service_path", &service_path)) {
788 AutomationJSONReply(this, reply_message).SendError( 715 AutomationJSONReply(this, reply_message).SendError(
789 "Invalid or missing args."); 716 "Invalid or missing args.");
790 return; 717 return;
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1267 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1341 AddObserver(power_manager_observer_); 1268 AddObserver(power_manager_observer_);
1342 } 1269 }
1343 1270
1344 void TestingAutomationProvider::RemoveChromeosObservers() { 1271 void TestingAutomationProvider::RemoveChromeosObservers() {
1345 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> 1272 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->
1346 RemoveObserver(power_manager_observer_); 1273 RemoveObserver(power_manager_observer_);
1347 delete power_manager_observer_; 1274 delete power_manager_observer_;
1348 power_manager_observer_ = NULL; 1275 power_manager_observer_ = NULL;
1349 } 1276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698