| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/i18n/time_formatting.h" | 8 #include "base/i18n/time_formatting.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/time.h" | 10 #include "base/time.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { | 62 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { |
| 63 DictionaryValue* item = new DictionaryValue; | 63 DictionaryValue* item = new DictionaryValue; |
| 64 item->SetString("name", network->name()); | 64 item->SetString("name", network->name()); |
| 65 item->SetString("device_path", network->device_path()); | 65 item->SetString("device_path", network->device_path()); |
| 66 item->SetString("ip_address", network->ip_address()); | 66 item->SetString("ip_address", network->ip_address()); |
| 67 item->SetString("status", network->GetStateString()); | 67 item->SetString("status", network->GetStateString()); |
| 68 return item; | 68 return item; |
| 69 } | 69 } |
| 70 | 70 |
| 71 Value* GetProxySetting(const std::string& setting_name) { | 71 Value* GetProxySetting(Browser* browser, const std::string& setting_name) { |
| 72 chromeos::ProxyCrosSettingsProvider settings_provider; | 72 chromeos::ProxyCrosSettingsProvider settings_provider(browser->profile()); |
| 73 std::string setting_path = "cros.session.proxy."; | 73 std::string setting_path = "cros.session.proxy."; |
| 74 setting_path.append(setting_name); | 74 setting_path.append(setting_name); |
| 75 | 75 |
| 76 if (setting_name == "ignorelist") { | 76 if (setting_name == "ignorelist") { |
| 77 Value* value; | 77 Value* value; |
| 78 if (settings_provider.Get(setting_path, &value)) | 78 if (settings_provider.Get(setting_path, &value)) |
| 79 return value; | 79 return value; |
| 80 } else { | 80 } else { |
| 81 Value* setting; | 81 Value* setting; |
| 82 if (settings_provider.Get(setting_path, &setting)) { | 82 if (settings_provider.Get(setting_path, &setting)) { |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 network_library->EnableWifiNetworkDevice(enable); | 511 network_library->EnableWifiNetworkDevice(enable); |
| 512 } else if (device == "cellular") { | 512 } else if (device == "cellular") { |
| 513 network_library->EnableCellularNetworkDevice(enable); | 513 network_library->EnableCellularNetworkDevice(enable); |
| 514 } else { | 514 } else { |
| 515 reply.SendError( | 515 reply.SendError( |
| 516 "Unknown device. Valid devices are ethernet, wifi, cellular."); | 516 "Unknown device. Valid devices are ethernet, wifi, cellular."); |
| 517 return; | 517 return; |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 | 520 |
| 521 void TestingAutomationProvider::GetProxySettings(DictionaryValue* args, | 521 void TestingAutomationProvider::GetProxySettings(Browser* browser, |
| 522 DictionaryValue* args, |
| 522 IPC::Message* reply_message) { | 523 IPC::Message* reply_message) { |
| 523 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", | 524 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", |
| 524 "httpurl", "httpport", "httpsurl", "httpsport", | 525 "httpurl", "httpport", "httpsurl", "httpsport", |
| 525 "type", "single", "ftpurl", "ftpport", | 526 "type", "single", "ftpurl", "ftpport", |
| 526 "socks", "socksport", "ignorelist" }; | 527 "socks", "socksport", "ignorelist" }; |
| 527 | 528 |
| 528 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 529 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 529 chromeos::ProxyCrosSettingsProvider settings_provider; | 530 chromeos::ProxyCrosSettingsProvider settings_provider(browser->profile()); |
| 530 | 531 |
| 531 for (size_t i = 0; i < arraysize(settings); ++i) { | 532 for (size_t i = 0; i < arraysize(settings); ++i) { |
| 532 Value* setting = GetProxySetting(settings[i]); | 533 Value* setting = GetProxySetting(browser, settings[i]); |
| 533 if (setting) | 534 if (setting) |
| 534 return_value->Set(settings[i], setting); | 535 return_value->Set(settings[i], setting); |
| 535 } | 536 } |
| 536 | 537 |
| 537 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 538 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 538 } | 539 } |
| 539 | 540 |
| 540 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, | 541 void TestingAutomationProvider::SetProxySettings(Browser* browser, |
| 541 IPC::Message* reply_message) { | 542 DictionaryValue* args, |
| 543 IPC::Message* reply_message) { |
| 542 AutomationJSONReply reply(this, reply_message); | 544 AutomationJSONReply reply(this, reply_message); |
| 543 std::string key; | 545 std::string key; |
| 544 Value* value; | 546 Value* value; |
| 545 if (!args->GetString("key", &key) || !args->Get("value", &value)) { | 547 if (!args->GetString("key", &key) || !args->Get("value", &value)) { |
| 546 reply.SendError("Invalid or missing args."); | 548 reply.SendError("Invalid or missing args."); |
| 547 return; | 549 return; |
| 548 } | 550 } |
| 549 | 551 |
| 550 std::string setting_path = "cros.session.proxy."; | 552 std::string setting_path = "cros.session.proxy."; |
| 551 setting_path.append(key); | 553 setting_path.append(key); |
| 552 | 554 |
| 553 // ProxyCrosSettingsProvider will own the Value* passed to Set(). | 555 // ProxyCrosSettingsProvider will own the Value* passed to Set(). |
| 554 chromeos::ProxyCrosSettingsProvider().Set(setting_path, value->DeepCopy()); | 556 chromeos::ProxyCrosSettingsProvider(browser->profile()).Set(setting_path, |
| 557 value->DeepCopy()); |
| 555 reply.SendSuccess(NULL); | 558 reply.SendSuccess(NULL); |
| 556 } | 559 } |
| 557 | 560 |
| 558 void TestingAutomationProvider::ConnectToCellularNetwork( | 561 void TestingAutomationProvider::ConnectToCellularNetwork( |
| 559 DictionaryValue* args, IPC::Message* reply_message) { | 562 DictionaryValue* args, IPC::Message* reply_message) { |
| 560 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 563 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
| 561 return; | 564 return; |
| 562 | 565 |
| 563 std::string service_path; | 566 std::string service_path; |
| 564 if (!args->GetString("service_path", &service_path)) { | 567 if (!args->GetString("service_path", &service_path)) { |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 views::Widget* window = browser::CreateViewsWindow( | 1204 views::Widget* window = browser::CreateViewsWindow( |
| 1202 browser->window()->GetNativeHandle(), take_photo_dialog); | 1205 browser->window()->GetNativeHandle(), take_photo_dialog); |
| 1203 window->SetAlwaysOnTop(true); | 1206 window->SetAlwaysOnTop(true); |
| 1204 window->Show(); | 1207 window->Show(); |
| 1205 } | 1208 } |
| 1206 | 1209 |
| 1207 void TestingAutomationProvider::PowerChanged( | 1210 void TestingAutomationProvider::PowerChanged( |
| 1208 const chromeos::PowerSupplyStatus& status) { | 1211 const chromeos::PowerSupplyStatus& status) { |
| 1209 power_status = status; | 1212 power_status = status; |
| 1210 } | 1213 } |
| OLD | NEW |