| 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_settings.h" |
| 16 #include "chrome/browser/chromeos/cros/cros_library.h" | 17 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 17 #include "chrome/browser/chromeos/cros/network_library.h" | 18 #include "chrome/browser/chromeos/cros/network_library.h" |
| 18 #include "chrome/browser/chromeos/cros/power_library.h" | 19 #include "chrome/browser/chromeos/cros/power_library.h" |
| 19 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | 20 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
| 20 #include "chrome/browser/chromeos/cros/update_library.h" | 21 #include "chrome/browser/chromeos/cros/update_library.h" |
| 21 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" | 22 #include "chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.
h" |
| 22 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 23 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 23 #include "chrome/browser/chromeos/login/login_display.h" | 24 #include "chrome/browser/chromeos/login/login_display.h" |
| 24 #include "chrome/browser/chromeos/login/login_display_host.h" | 25 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 25 #include "chrome/browser/chromeos/login/screen_locker.h" | 26 #include "chrome/browser/chromeos/login/screen_locker.h" |
| 26 #include "chrome/browser/chromeos/login/webui_login_display.h" | 27 #include "chrome/browser/chromeos/login/webui_login_display.h" |
| 27 #include "chrome/browser/chromeos/login/wizard_controller.h" | 28 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 28 #include "chrome/browser/chromeos/options/take_photo_dialog.h" | 29 #include "chrome/browser/chromeos/options/take_photo_dialog.h" |
| 29 #include "chrome/browser/chromeos/proxy_cros_settings_provider.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(const std::string& setting_name) { | 71 const Value* GetProxySetting(const std::string& setting_name) { |
| 72 chromeos::ProxyCrosSettingsProvider settings_provider; | |
| 73 std::string setting_path = "cros.session.proxy."; | 72 std::string setting_path = "cros.session.proxy."; |
| 74 setting_path.append(setting_name); | 73 setting_path.append(setting_name); |
| 75 | 74 |
| 76 if (setting_name == "ignorelist") { | 75 return chromeos::CrosSettings::Get()->GetPref(setting_path); |
| 77 Value* value; | |
| 78 if (settings_provider.Get(setting_path, &value)) | |
| 79 return value; | |
| 80 } else { | |
| 81 Value* setting; | |
| 82 if (settings_provider.Get(setting_path, &setting)) { | |
| 83 DictionaryValue* setting_dict = static_cast<DictionaryValue*>(setting); | |
| 84 Value* value; | |
| 85 bool found = setting_dict->Remove("value", &value); | |
| 86 delete setting; | |
| 87 if (found) | |
| 88 return value; | |
| 89 } | |
| 90 } | |
| 91 return NULL; | |
| 92 } | 76 } |
| 93 | 77 |
| 94 const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { | 78 const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { |
| 95 switch (status) { | 79 switch (status) { |
| 96 case chromeos::UPDATE_STATUS_IDLE: | 80 case chromeos::UPDATE_STATUS_IDLE: |
| 97 return "idle"; | 81 return "idle"; |
| 98 case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE: | 82 case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE: |
| 99 return "checking for update"; | 83 return "checking for update"; |
| 100 case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE: | 84 case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE: |
| 101 return "update available"; | 85 return "update available"; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 } | 501 } |
| 518 | 502 |
| 519 void TestingAutomationProvider::GetProxySettings(DictionaryValue* args, | 503 void TestingAutomationProvider::GetProxySettings(DictionaryValue* args, |
| 520 IPC::Message* reply_message) { | 504 IPC::Message* reply_message) { |
| 521 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", | 505 const char* settings[] = { "pacurl", "singlehttp", "singlehttpport", |
| 522 "httpurl", "httpport", "httpsurl", "httpsport", | 506 "httpurl", "httpport", "httpsurl", "httpsport", |
| 523 "type", "single", "ftpurl", "ftpport", | 507 "type", "single", "ftpurl", "ftpport", |
| 524 "socks", "socksport", "ignorelist" }; | 508 "socks", "socksport", "ignorelist" }; |
| 525 | 509 |
| 526 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 510 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
| 527 chromeos::ProxyCrosSettingsProvider settings_provider; | |
| 528 | 511 |
| 529 for (size_t i = 0; i < arraysize(settings); ++i) { | 512 for (size_t i = 0; i < arraysize(settings); ++i) { |
| 530 Value* setting = GetProxySetting(settings[i]); | 513 const Value* setting = GetProxySetting(settings[i]); |
| 531 if (setting) | 514 if (setting) |
| 532 return_value->Set(settings[i], setting); | 515 return_value->Set(settings[i], setting->DeepCopy()); |
| 533 } | 516 } |
| 534 | 517 |
| 535 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); | 518 AutomationJSONReply(this, reply_message).SendSuccess(return_value.get()); |
| 536 } | 519 } |
| 537 | 520 |
| 538 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, | 521 void TestingAutomationProvider::SetProxySettings(DictionaryValue* args, |
| 539 IPC::Message* reply_message) { | 522 IPC::Message* reply_message) { |
| 540 AutomationJSONReply reply(this, reply_message); | 523 AutomationJSONReply reply(this, reply_message); |
| 541 std::string key; | 524 std::string key; |
| 542 Value* value; | 525 Value* value; |
| 543 if (!args->GetString("key", &key) || !args->Get("value", &value)) { | 526 if (!args->GetString("key", &key) || !args->Get("value", &value)) { |
| 544 reply.SendError("Invalid or missing args."); | 527 reply.SendError("Invalid or missing args."); |
| 545 return; | 528 return; |
| 546 } | 529 } |
| 547 | 530 |
| 548 std::string setting_path = "cros.session.proxy."; | 531 std::string setting_path = "cros.session.proxy."; |
| 549 setting_path.append(key); | 532 setting_path.append(key); |
| 550 | 533 |
| 551 // ProxyCrosSettingsProvider will own the Value* passed to Set(). | 534 // ProxyCrosSettingsProvider will own the Value* passed to Set(). |
| 552 chromeos::ProxyCrosSettingsProvider().Set(setting_path, value->DeepCopy()); | 535 chromeos::CrosSettings::Get()->Set(setting_path, value->DeepCopy()); |
| 553 reply.SendSuccess(NULL); | 536 reply.SendSuccess(NULL); |
| 554 } | 537 } |
| 555 | 538 |
| 556 void TestingAutomationProvider::ConnectToWifiNetwork( | 539 void TestingAutomationProvider::ConnectToWifiNetwork( |
| 557 DictionaryValue* args, IPC::Message* reply_message) { | 540 DictionaryValue* args, IPC::Message* reply_message) { |
| 558 if (!EnsureCrosLibraryLoaded(this, reply_message)) | 541 if (!EnsureCrosLibraryLoaded(this, reply_message)) |
| 559 return; | 542 return; |
| 560 | 543 |
| 561 AutomationJSONReply reply(this, reply_message); | 544 AutomationJSONReply reply(this, reply_message); |
| 562 std::string service_path, password; | 545 std::string service_path, password; |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 | 1129 |
| 1147 // Set up an observer (it will delete itself). | 1130 // Set up an observer (it will delete itself). |
| 1148 take_photo_dialog->AddObserver(new PhotoCaptureObserver( | 1131 take_photo_dialog->AddObserver(new PhotoCaptureObserver( |
| 1149 this, reply_message)); | 1132 this, reply_message)); |
| 1150 | 1133 |
| 1151 views::Widget* window = browser::CreateViewsWindow( | 1134 views::Widget* window = browser::CreateViewsWindow( |
| 1152 browser->window()->GetNativeHandle(), take_photo_dialog); | 1135 browser->window()->GetNativeHandle(), take_photo_dialog); |
| 1153 window->SetAlwaysOnTop(true); | 1136 window->SetAlwaysOnTop(true); |
| 1154 window->Show(); | 1137 window->Show(); |
| 1155 } | 1138 } |
| OLD | NEW |