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

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

Issue 8585025: chromeos: Change all clients of UpdateLibrary to use UpdateEngineClient. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/chromeos/dbus/dbus_thread_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/dbus/dbus_thread_manager.h"
21 #include "chrome/browser/chromeos/dbus/update_engine_client.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_parser.h" 30 #include "chrome/browser/chromeos/proxy_cros_settings_parser.h"
30 #include "chrome/browser/chromeos/system/timezone_settings.h" 31 #include "chrome/browser/chromeos/system/timezone_settings.h"
31 #include "chrome/browser/policy/browser_policy_connector.h" 32 #include "chrome/browser/policy/browser_policy_connector.h"
32 #include "chrome/browser/policy/cloud_policy_cache_base.h" 33 #include "chrome/browser/policy/cloud_policy_cache_base.h"
33 #include "chrome/browser/policy/cloud_policy_data_store.h" 34 #include "chrome/browser/policy/cloud_policy_data_store.h"
34 #include "chrome/browser/policy/cloud_policy_subsystem.h" 35 #include "chrome/browser/policy/cloud_policy_subsystem.h"
35 #include "chrome/browser/policy/enterprise_install_attributes.h" 36 #include "chrome/browser/policy/enterprise_install_attributes.h"
36 #include "chrome/browser/prefs/pref_service.h" 37 #include "chrome/browser/prefs/pref_service.h"
37 #include "chrome/browser/ui/browser_window.h" 38 #include "chrome/browser/ui/browser_window.h"
38 #include "chrome/browser/ui/views/window.h" 39 #include "chrome/browser/ui/views/window.h"
39 #include "chrome/common/pref_names.h" 40 #include "chrome/common/pref_names.h"
40 #include "net/base/network_change_notifier.h" 41 #include "net/base/network_change_notifier.h"
41 #include "policy/policy_constants.h" 42 #include "policy/policy_constants.h"
42 #include "ui/views/widget/widget.h" 43 #include "ui/views/widget/widget.h"
43 44
44 using chromeos::CrosLibrary; 45 using chromeos::CrosLibrary;
46 using chromeos::DBusThreadManager;
45 using chromeos::NetworkLibrary; 47 using chromeos::NetworkLibrary;
46 using chromeos::UpdateLibrary; 48 using chromeos::UpdateEngineClient;
47 using chromeos::UserManager; 49 using chromeos::UserManager;
48 50
49 namespace { 51 namespace {
50 52
51 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) { 53 DictionaryValue* GetNetworkInfoDict(const chromeos::Network* network) {
52 DictionaryValue* item = new DictionaryValue; 54 DictionaryValue* item = new DictionaryValue;
53 item->SetString("name", network->name()); 55 item->SetString("name", network->name());
54 item->SetString("device_path", network->device_path()); 56 item->SetString("device_path", network->device_path());
55 item->SetString("ip_address", network->ip_address()); 57 item->SetString("ip_address", network->ip_address());
56 item->SetString("status", network->GetStateString()); 58 item->SetString("status", network->GetStateString());
(...skipping 19 matching lines...) Expand all
76 base::Value* value; 78 base::Value* value;
77 bool found = setting_dict->Remove("value", &value); 79 bool found = setting_dict->Remove("value", &value);
78 delete setting; 80 delete setting;
79 if (found) 81 if (found)
80 return value; 82 return value;
81 } 83 }
82 } 84 }
83 return NULL; 85 return NULL;
84 } 86 }
85 87
86 const char* UpdateStatusToString(chromeos::UpdateStatusOperation status) { 88 const char* UpdateStatusToString(
89 UpdateEngineClient::UpdateStatusOperation status) {
87 switch (status) { 90 switch (status) {
88 case chromeos::UPDATE_STATUS_IDLE: 91 case UpdateEngineClient::UPDATE_STATUS_IDLE:
89 return "idle"; 92 return "idle";
90 case chromeos::UPDATE_STATUS_CHECKING_FOR_UPDATE: 93 case UpdateEngineClient::UPDATE_STATUS_CHECKING_FOR_UPDATE:
91 return "checking for update"; 94 return "checking for update";
92 case chromeos::UPDATE_STATUS_UPDATE_AVAILABLE: 95 case UpdateEngineClient::UPDATE_STATUS_UPDATE_AVAILABLE:
93 return "update available"; 96 return "update available";
94 case chromeos::UPDATE_STATUS_DOWNLOADING: 97 case UpdateEngineClient::UPDATE_STATUS_DOWNLOADING:
95 return "downloading"; 98 return "downloading";
96 case chromeos::UPDATE_STATUS_VERIFYING: 99 case UpdateEngineClient::UPDATE_STATUS_VERIFYING:
97 return "verifying"; 100 return "verifying";
98 case chromeos::UPDATE_STATUS_FINALIZING: 101 case UpdateEngineClient::UPDATE_STATUS_FINALIZING:
99 return "finalizing"; 102 return "finalizing";
100 case chromeos::UPDATE_STATUS_UPDATED_NEED_REBOOT: 103 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
101 return "updated need reboot"; 104 return "updated need reboot";
102 case chromeos::UPDATE_STATUS_REPORTING_ERROR_EVENT: 105 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT:
103 return "reporting error event"; 106 return "reporting error event";
104 default: 107 default:
105 return "unknown"; 108 return "unknown";
106 } 109 }
107 } 110 }
108 111
109 void GetReleaseTrackCallback(void* user_data, const char* track) { 112 void GetReleaseTrackCallback(AutomationJSONReply* reply,
110 AutomationJSONReply* reply = static_cast<AutomationJSONReply*>(user_data); 113 const std::string& track) {
111 114 if (track.empty()) {
112 if (track == NULL) {
113 reply->SendError("Unable to get release track."); 115 reply->SendError("Unable to get release track.");
114 delete reply; 116 delete reply;
115 return; 117 return;
116 } 118 }
117 119
118 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 120 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
119 return_value->SetString("release_track", track); 121 return_value->SetString("release_track", track);
120 122
121 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); 123 const UpdateEngineClient::Status& status =
122 const UpdateLibrary::Status& status = update_library->status(); 124 DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus();
123 chromeos::UpdateStatusOperation update_status = status.status; 125 UpdateEngineClient::UpdateStatusOperation update_status =
126 status.status;
124 return_value->SetString("status", UpdateStatusToString(update_status)); 127 return_value->SetString("status", UpdateStatusToString(update_status));
125 if (update_status == chromeos::UPDATE_STATUS_DOWNLOADING) 128 if (update_status == UpdateEngineClient::UPDATE_STATUS_DOWNLOADING)
126 return_value->SetDouble("download_progress", status.download_progress); 129 return_value->SetDouble("download_progress", status.download_progress);
127 if (status.last_checked_time > 0) 130 if (status.last_checked_time > 0)
128 return_value->SetInteger("last_checked_time", status.last_checked_time); 131 return_value->SetInteger("last_checked_time", status.last_checked_time);
129 if (status.new_size > 0) 132 if (status.new_size > 0)
130 return_value->SetInteger("new_size", status.new_size); 133 return_value->SetInteger("new_size", status.new_size);
131 134
132 reply->SendSuccess(return_value.get()); 135 reply->SendSuccess(return_value.get());
133 delete reply; 136 delete reply;
134 } 137 }
135 138
136 void UpdateCheckCallback(void* user_data, chromeos::UpdateResult result, 139 void UpdateCheckCallback(AutomationJSONReply* reply,
137 const char* error_msg) { 140 UpdateEngineClient::UpdateCheckResult result) {
138 AutomationJSONReply* reply = static_cast<AutomationJSONReply*>(user_data); 141 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS)
139 if (result == chromeos::UPDATE_RESULT_SUCCESS)
140 reply->SendSuccess(NULL); 142 reply->SendSuccess(NULL);
141 else 143 else
142 reply->SendError(error_msg); 144 reply->SendError("update check failed");
143 delete reply; 145 delete reply;
144 } 146 }
145 147
146 const std::string VPNProviderTypeToString( 148 const std::string VPNProviderTypeToString(
147 chromeos::ProviderType provider_type) { 149 chromeos::ProviderType provider_type) {
148 switch (provider_type) { 150 switch (provider_type) {
149 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK: 151 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_PSK:
150 return std::string("L2TP_IPSEC_PSK"); 152 return std::string("L2TP_IPSEC_PSK");
151 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT: 153 case chromeos::PROVIDER_TYPE_L2TP_IPSEC_USER_CERT:
152 return std::string("L2TP_IPSEC_USER_CERT"); 154 return std::string("L2TP_IPSEC_USER_CERT");
(...skipping 892 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 1047
1046 icu::TimeZone* timezone = 1048 icu::TimeZone* timezone =
1047 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id)); 1049 icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(timezone_id));
1048 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone); 1050 chromeos::system::TimezoneSettings::GetInstance()->SetTimezone(*timezone);
1049 delete timezone; 1051 delete timezone;
1050 AutomationJSONReply(this, reply_message).SendSuccess(NULL); 1052 AutomationJSONReply(this, reply_message).SendSuccess(NULL);
1051 } 1053 }
1052 1054
1053 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, 1055 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args,
1054 IPC::Message* reply_message) { 1056 IPC::Message* reply_message) {
1055 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary();
1056 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); 1057 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
1057 update_library->GetReleaseTrack(GetReleaseTrackCallback, reply); 1058 DBusThreadManager::Get()->GetUpdateEngineClient()
1059 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply));
1058 } 1060 }
1059 1061
1060 void TestingAutomationProvider::UpdateCheck( 1062 void TestingAutomationProvider::UpdateCheck(
1061 DictionaryValue* args, 1063 DictionaryValue* args,
1062 IPC::Message* reply_message) { 1064 IPC::Message* reply_message) {
1063 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary();
1064 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); 1065 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message);
1065 update_library->RequestUpdateCheck(UpdateCheckCallback, reply); 1066 DBusThreadManager::Get()->GetUpdateEngineClient()
1067 ->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply));
1066 } 1068 }
1067 1069
1068 void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, 1070 void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args,
1069 IPC::Message* reply_message) { 1071 IPC::Message* reply_message) {
1070 AutomationJSONReply reply(this, reply_message); 1072 AutomationJSONReply reply(this, reply_message);
1071 std::string track; 1073 std::string track;
1072 if (!args->GetString("track", &track)) { 1074 if (!args->GetString("track", &track)) {
1073 reply.SendError("Invalid or missing args."); 1075 reply.SendError("Invalid or missing args.");
1074 return; 1076 return;
1075 } 1077 }
1076 1078
1077 UpdateLibrary* update_library = CrosLibrary::Get()->GetUpdateLibrary(); 1079 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(track);
1078 update_library->SetReleaseTrack(track);
1079 reply.SendSuccess(NULL); 1080 reply.SendSuccess(NULL);
1080 } 1081 }
1081 1082
1082 void TestingAutomationProvider::GetVolumeInfo(DictionaryValue* args, 1083 void TestingAutomationProvider::GetVolumeInfo(DictionaryValue* args,
1083 IPC::Message* reply_message) { 1084 IPC::Message* reply_message) {
1084 AutomationJSONReply reply(this, reply_message); 1085 AutomationJSONReply reply(this, reply_message);
1085 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); 1086 scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
1086 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); 1087 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance();
1087 if (!audio_handler) { 1088 if (!audio_handler) {
1088 reply.SendError("AudioHandler not initialized."); 1089 reply.SendError("AudioHandler not initialized.");
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 views::Widget* window = browser::CreateViewsWindow( 1142 views::Widget* window = browser::CreateViewsWindow(
1142 browser->window()->GetNativeHandle(), take_photo_dialog); 1143 browser->window()->GetNativeHandle(), take_photo_dialog);
1143 window->SetAlwaysOnTop(true); 1144 window->SetAlwaysOnTop(true);
1144 window->Show(); 1145 window->Show();
1145 } 1146 }
1146 1147
1147 void TestingAutomationProvider::PowerChanged( 1148 void TestingAutomationProvider::PowerChanged(
1148 const chromeos::PowerSupplyStatus& status) { 1149 const chromeos::PowerSupplyStatus& status) {
1149 power_status = status; 1150 power_status = status;
1150 } 1151 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/dbus/dbus_thread_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698