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" |
11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
12 #include "chrome/browser/automation/automation_provider_json.h" | 12 #include "chrome/browser/automation/automation_provider_json.h" |
13 #include "chrome/browser/automation/automation_provider_observers.h" | 13 #include "chrome/browser/automation/automation_provider_observers.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/audio_handler.h" | 15 #include "chrome/browser/chromeos/audio_handler.h" |
16 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
17 #include "chrome/browser/chromeos/cros/network_library.h" | 17 #include "chrome/browser/chromeos/cros/network_library.h" |
18 #include "chrome/browser/chromeos/cros/power_library.h" | 18 #include "chrome/browser/chromeos/cros/power_library.h" |
19 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 19 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
20 #include "chrome/browser/chromeos/cros/update_library.h" | 20 #include "chrome/browser/chromeos/cros/update_library.h" |
21 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen. h" | 21 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen. h" |
22 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 22 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
23 #include "chrome/browser/chromeos/login/login_display.h" | 23 #include "chrome/browser/chromeos/login/login_display.h" |
24 #include "chrome/browser/chromeos/login/login_display_host.h" | 24 #include "chrome/browser/chromeos/login/login_display_host.h" |
25 #include "chrome/browser/chromeos/login/screen_locker.h" | 25 #include "chrome/browser/chromeos/login/screen_locker.h" |
26 #include "chrome/browser/chromeos/login/webui_login_display.h" | 26 #include "chrome/browser/chromeos/login/webui_login_display.h" |
27 #include "chrome/browser/chromeos/login/wizard_controller.h" | 27 #include "chrome/browser/chromeos/login/wizard_controller.h" |
28 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 28 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
29 #include "chrome/browser/chromeos/proxy_cros_settings_provider.h" | 29 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h" |
30 #include "chrome/browser/chromeos/system/timezone_settings.h" | 30 #include "chrome/browser/chromeos/system/timezone_settings.h" |
31 #include "chrome/browser/policy/browser_policy_connector.h" | 31 #include "chrome/browser/policy/browser_policy_connector.h" |
32 #include "chrome/browser/policy/cloud_policy_cache_base.h" | 32 #include "chrome/browser/policy/cloud_policy_cache_base.h" |
33 #include "chrome/browser/policy/cloud_policy_data_store.h" | 33 #include "chrome/browser/policy/cloud_policy_data_store.h" |
34 #include "chrome/browser/policy/cloud_policy_subsystem.h" | 34 #include "chrome/browser/policy/cloud_policy_subsystem.h" |
35 #include "chrome/browser/policy/enterprise_install_attributes.h" | 35 #include "chrome/browser/policy/enterprise_install_attributes.h" |
36 #include "chrome/browser/prefs/pref_service.h" | 36 #include "chrome/browser/prefs/pref_service.h" |
37 #include "chrome/browser/ui/browser_window.h" | 37 #include "chrome/browser/ui/browser_window.h" |
38 #include "chrome/browser/ui/views/window.h" | 38 #include "chrome/browser/ui/views/window.h" |
39 #include "chrome/common/chrome_switches.h" | 39 #include "chrome/common/chrome_switches.h" |
(...skipping 21 matching lines...) Expand all 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(Browser* browser, const std::string& setting_name) { | 71 base::Value* GetProxySetting(Browser* browser, |
72 chromeos::ProxyCrosSettingsProvider settings_provider(browser->profile()); | 72 const std::string& setting_name) { |
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 base::Value* value; |
78 if (settings_provider.Get(setting_path, &value)) | 78 if (chromeos::ProxyCrosSettingsParser::GetProxyPrefValue( |
79 return value; | 79 browser->profile(), setting_path, &value)) { |
Mattias Nissler (ping if slow)
2011/11/08 09:25:22
+4 indentation
pastarmovj
2011/11/09 17:51:53
Done.
| |
80 return value; | |
81 } | |
80 } else { | 82 } else { |
81 Value* setting; | 83 base::Value* setting; |
82 if (settings_provider.Get(setting_path, &setting)) { | 84 if (chromeos::ProxyCrosSettingsParser::GetProxyPrefValue( |
85 browser->profile(), setting_path, &setting)) { | |
83 DictionaryValue* setting_dict = static_cast<DictionaryValue*>(setting); | 86 DictionaryValue* setting_dict = static_cast<DictionaryValue*>(setting); |
84 Value* value; | 87 base::Value* value; |
85 bool found = setting_dict->Remove("value", &value); | 88 bool found = setting_dict->Remove("value", &value); |
86 delete setting; | 89 delete setting; |
87 if (found) | 90 if (found) |
88 return value; | 91 return value; |
89 } | 92 } |
90 } | 93 } |
91 return NULL; | 94 return NULL; |
92 } | 95 } |
93 | 96 |
94 const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { | 97 const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
461 } | 464 } |
462 | 465 |
463 // Remembered Wifi Networks. | 466 // Remembered Wifi Networks. |
464 const chromeos::WifiNetworkVector& remembered_wifi = | 467 const chromeos::WifiNetworkVector& remembered_wifi = |
465 network_library->remembered_wifi_networks(); | 468 network_library->remembered_wifi_networks(); |
466 ListValue* items = new ListValue; | 469 ListValue* items = new ListValue; |
467 for (chromeos::WifiNetworkVector::const_iterator iter = | 470 for (chromeos::WifiNetworkVector::const_iterator iter = |
468 remembered_wifi.begin(); iter != remembered_wifi.end(); | 471 remembered_wifi.begin(); iter != remembered_wifi.end(); |
469 ++iter) { | 472 ++iter) { |
470 const chromeos::WifiNetwork* wifi = *iter; | 473 const chromeos::WifiNetwork* wifi = *iter; |
471 items->Append(Value::CreateStringValue(wifi->service_path())); | 474 items->Append(base::Value::CreateStringValue(wifi->service_path())); |
472 } | 475 } |
473 return_value->Set("remembered_wifi", items); | 476 return_value->Set("remembered_wifi", items); |
474 | 477 |
475 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 478 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
476 } | 479 } |
477 | 480 |
478 void TestingAutomationProvider::NetworkScan(DictionaryValue* args, | 481 void TestingAutomationProvider::NetworkScan(DictionaryValue* args, |
479 IPC::Message* reply_message) { | 482 IPC::Message* reply_message) { |
480 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 483 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
481 return; | 484 return; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
520 | 523 |
521 void TestingAutomationProvider::GetProxySettings(Browser* browser, | 524 void TestingAutomationProvider::GetProxySettings(Browser* browser, |
522 DictionaryValue* args, | 525 DictionaryValue* args, |
523 IPC::Message* reply_message) { | 526 IPC::Message* reply_message) { |
524 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", | 527 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", |
525 "httpurl", "httpport", "httpsurl", "httpsport", | 528 "httpurl", "httpport", "httpsurl", "httpsport", |
526 "type", "single", "ftpurl", "ftpport", | 529 "type", "single", "ftpurl", "ftpport", |
527 "socks", "socksport", "ignorelist" }; | 530 "socks", "socksport", "ignorelist" }; |
528 | 531 |
529 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 532 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
530 chromeos::ProxyCrosSettingsProvider settings_provider(browser->profile()); | |
531 | 533 |
532 for (size_t i = 0; i < arraysize(settings); ++i) { | 534 for (size_t i = 0; i < arraysize(settings); ++i) { |
533 Value* setting = GetProxySetting(browser, settings[i]); | 535 base::Value* setting = GetProxySetting(browser, settings[i]); |
534 if (setting) | 536 if (setting) |
535 return_value->Set(settings[i], setting); | 537 return_value->Set(settings[i], setting); |
536 } | 538 } |
537 | 539 |
538 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 540 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
539 } | 541 } |
540 | 542 |
541 void TestingAutomationProvider::SetProxySettings(Browser* browser, | 543 void TestingAutomationProvider::SetProxySettings(Browser* browser, |
542 DictionaryValue* args, | 544 DictionaryValue* args, |
543 IPC::Message* reply_message) { | 545 IPC::Message* reply_message) { |
544 AutomationJSONReply reply(this, reply_message); | 546 AutomationJSONReply reply(this, reply_message); |
545 std::string key; | 547 std::string key; |
546 Value* value; | 548 base::Value* value; |
547 if (!args->GetString("key", &key) || !args->Get("value", &value)) { | 549 if (!args->GetString("key", &key) || !args->Get("value", &value)) { |
548 reply.SendError("Invalid or missing args."); | 550 reply.SendError("Invalid or missing args."); |
549 return; | 551 return; |
550 } | 552 } |
551 | 553 |
552 std::string setting_path = "cros.session.proxy."; | 554 std::string setting_path = "cros.session.proxy."; |
553 setting_path.append(key); | 555 setting_path.append(key); |
554 | 556 |
555 // ProxyCrosSettingsProvider will own the Value* passed to Set(). | 557 // ProxyCrosSettingsProvider will own the Value* passed to Set(). |
556 chromeos::ProxyCrosSettingsProvider(browser->profile()).Set(setting_path, | 558 chromeos::ProxyCrosSettingsParser::SetProxyPrefValue( |
557 value->DeepCopy()); | 559 browser->profile(), setting_path, value); |
558 reply.SendSuccess(NULL); | 560 reply.SendSuccess(NULL); |
559 } | 561 } |
560 | 562 |
561 void TestingAutomationProvider::ConnectToCellularNetwork( | 563 void TestingAutomationProvider::ConnectToCellularNetwork( |
562 DictionaryValue* args, IPC::Message* reply_message) { | 564 DictionaryValue* args, IPC::Message* reply_message) { |
563 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 565 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
564 return; | 566 return; |
565 | 567 |
566 std::string service_path; | 568 std::string service_path; |
567 if (!args->GetString("service_path", &service_path)) { | 569 if (!args->GetString("service_path", &service_path)) { |
(...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1204 views::Widget* window = browser::CreateViewsWindow( | 1206 views::Widget* window = browser::CreateViewsWindow( |
1205 browser->window()->GetNativeHandle(), take_photo_dialog); | 1207 browser->window()->GetNativeHandle(), take_photo_dialog); |
1206 window->SetAlwaysOnTop(true); | 1208 window->SetAlwaysOnTop(true); |
1207 window->Show(); | 1209 window->Show(); |
1208 } | 1210 } |
1209 | 1211 |
1210 void TestingAutomationProvider::PowerChanged( | 1212 void TestingAutomationProvider::PowerChanged( |
1211 const chromeos::PowerSupplyStatus& status) { | 1213 const chromeos::PowerSupplyStatus& status) { |
1212 power_status = status; | 1214 power_status = status; |
1213 } | 1215 } |
OLD | NEW |