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 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 network_library->EnableWifiNetworkDevice(enable); | 509 network_library->EnableWifiNetworkDevice(enable); |
510 } else if (device == "cellular") { | 510 } else if (device == "cellular") { |
511 network_library->EnableCellularNetworkDevice(enable); | 511 network_library->EnableCellularNetworkDevice(enable); |
512 } else { | 512 } else { |
513 reply.SendError( | 513 reply.SendError( |
514 "Unknown device. Valid devices are ethernet, wifi, cellular."); | 514 "Unknown device. Valid devices are ethernet, wifi, cellular."); |
515 return; | 515 return; |
516 } | 516 } |
517 } | 517 } |
518 | 518 |
519 void TestingAutomationProvider::GetProxySettings(DictionaryValue* args, | 519 void TestingAutomationProvider::GetProxySettings(Browser* browser, |
520 DictionaryValue* args, | |
520 IPC::Message* reply_message) { | 521 IPC::Message* reply_message) { |
521 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", | 522 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", |
522 "httpurl", "httpport", "httpsurl", "httpsport", | 523 "httpurl", "httpport", "httpsurl", "httpsport", |
523 "type", "single", "ftpurl", "ftpport", | 524 "type", "single", "ftpurl", "ftpport", |
524 "socks", "socksport", "ignorelist" }; | 525 "socks", "socksport", "ignorelist" }; |
525 | 526 |
526 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 527 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
527 chromeos::ProxyCrosSettingsProvider settings_provider; | 528 chromeos::ProxyCrosSettingsProvider settings_provider(browser->profile()); |
528 | 529 |
529 for (size_t i = 0; i < arraysize(settings); ++i) { | 530 for (size_t i = 0; i < arraysize(settings); ++i) { |
530 Value* setting = GetProxySetting(settings[i]); | 531 Value* setting = GetProxySetting(browser, settings[i]); |
531 if (setting) | 532 if (setting) |
532 return_value->Set(settings[i], setting); | 533 return_value->Set(settings[i], setting); |
533 } | 534 } |
534 | 535 |
535 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 536 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
536 } | 537 } |
537 | 538 |
538 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, | 539 void TestingAutomationProvider::SetProxySettings(Browser* browser, |
540 DictionaryValue* args, | |
539 IPC::Message* reply_message) { | 541 IPC::Message* reply_message) { |
Mattias Nissler (ping if slow)
2011/10/25 12:43:11
indentation
kuan
2011/10/25 16:01:50
Done.
| |
540 AutomationJSONReply reply(this, reply_message); | 542 AutomationJSONReply reply(this, reply_message); |
541 std::string key; | 543 std::string key; |
542 Value* value; | 544 Value* value; |
543 if (!args->GetString("key", &key) || !args->Get("value", &value)) { | 545 if (!args->GetString("key", &key) || !args->Get("value", &value)) { |
544 reply.SendError("Invalid or missing args."); | 546 reply.SendError("Invalid or missing args."); |
545 return; | 547 return; |
546 } | 548 } |
547 | 549 |
548 std::string setting_path = "cros.session.proxy."; | 550 std::string setting_path = "cros.session.proxy."; |
549 setting_path.append(key); | 551 setting_path.append(key); |
550 | 552 |
551 // ProxyCrosSettingsProvider will own the Value* passed to Set(). | 553 // ProxyCrosSettingsProvider will own the Value* passed to Set(). |
552 chromeos::ProxyCrosSettingsProvider().Set(setting_path, value->DeepCopy()); | 554 chromeos::ProxyCrosSettingsProvider(browser->profile()).Set(setting_path, |
555 value->DeepCopy()); | |
553 reply.SendSuccess(NULL); | 556 reply.SendSuccess(NULL); |
554 } | 557 } |
555 | 558 |
556 void TestingAutomationProvider::ConnectToCellularNetwork( | 559 void TestingAutomationProvider::ConnectToCellularNetwork( |
557 DictionaryValue* args, IPC::Message* reply_message) { | 560 DictionaryValue* args, IPC::Message* reply_message) { |
558 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 561 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
559 return; | 562 return; |
560 | 563 |
561 std::string service_path; | 564 std::string service_path; |
562 if (!args->GetString("service_path", &service_path)) { | 565 if (!args->GetString("service_path", &service_path)) { |
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1194 | 1197 |
1195 // Set up an observer (it will delete itself). | 1198 // Set up an observer (it will delete itself). |
1196 take_photo_dialog->AddObserver(new PhotoCaptureObserver( | 1199 take_photo_dialog->AddObserver(new PhotoCaptureObserver( |
1197 this, reply_message)); | 1200 this, reply_message)); |
1198 | 1201 |
1199 views::Widget* window = browser::CreateViewsWindow( | 1202 views::Widget* window = browser::CreateViewsWindow( |
1200 browser->window()->GetNativeHandle(), take_photo_dialog); | 1203 browser->window()->GetNativeHandle(), take_photo_dialog); |
1201 window->SetAlwaysOnTop(true); | 1204 window->SetAlwaysOnTop(true); |
1202 window->Show(); | 1205 window->Show(); |
1203 } | 1206 } |
OLD | NEW |