OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/system/tray/system_tray_delegate.h" | 9 #include "ash/system/tray/system_tray_delegate.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 return "finalizing"; | 96 return "finalizing"; |
97 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: | 97 case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT: |
98 return "updated need reboot"; | 98 return "updated need reboot"; |
99 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: | 99 case UpdateEngineClient::UPDATE_STATUS_REPORTING_ERROR_EVENT: |
100 return "reporting error event"; | 100 return "reporting error event"; |
101 default: | 101 default: |
102 return "unknown"; | 102 return "unknown"; |
103 } | 103 } |
104 } | 104 } |
105 | 105 |
106 void GetReleaseTrackCallback(AutomationJSONReply* reply, | |
107 const std::string& track) { | |
108 if (track.empty()) { | |
109 reply->SendError("Unable to get release track."); | |
110 delete reply; | |
111 return; | |
112 } | |
113 | |
114 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | |
115 return_value->SetString("release_track", track); | |
116 | |
117 const UpdateEngineClient::Status& status = | |
118 DBusThreadManager::Get()->GetUpdateEngineClient()->GetLastStatus(); | |
119 UpdateEngineClient::UpdateStatusOperation update_status = | |
120 status.status; | |
121 return_value->SetString("status", UpdateStatusToString(update_status)); | |
122 if (update_status == UpdateEngineClient::UPDATE_STATUS_DOWNLOADING) | |
123 return_value->SetDouble("download_progress", status.download_progress); | |
124 if (status.last_checked_time > 0) | |
125 return_value->SetInteger("last_checked_time", status.last_checked_time); | |
126 if (status.new_size > 0) | |
127 return_value->SetInteger("new_size", status.new_size); | |
128 | |
129 reply->SendSuccess(return_value.get()); | |
130 delete reply; | |
131 } | |
132 | |
133 void UpdateCheckCallback(AutomationJSONReply* reply, | 106 void UpdateCheckCallback(AutomationJSONReply* reply, |
134 UpdateEngineClient::UpdateCheckResult result) { | 107 UpdateEngineClient::UpdateCheckResult result) { |
135 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS) | 108 if (result == UpdateEngineClient::UPDATE_RESULT_SUCCESS) |
136 reply->SendSuccess(NULL); | 109 reply->SendSuccess(NULL); |
137 else | 110 else |
138 reply->SendError("update check failed"); | 111 reply->SendError("update check failed"); |
139 delete reply; | 112 delete reply; |
140 } | 113 } |
141 | 114 |
142 const std::string VPNProviderTypeToString( | 115 const std::string VPNProviderTypeToString( |
(...skipping 1004 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1147 std::string timezone_id; | 1120 std::string timezone_id; |
1148 if (!args->GetString("timezone", &timezone_id)) { | 1121 if (!args->GetString("timezone", &timezone_id)) { |
1149 reply.SendError("Invalid or missing args."); | 1122 reply.SendError("Invalid or missing args."); |
1150 return; | 1123 return; |
1151 } | 1124 } |
1152 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); | 1125 chromeos::CrosSettings* settings = chromeos::CrosSettings::Get(); |
1153 settings->SetString(chromeos::kSystemTimezone, timezone_id); | 1126 settings->SetString(chromeos::kSystemTimezone, timezone_id); |
1154 reply.SendSuccess(NULL); | 1127 reply.SendSuccess(NULL); |
1155 } | 1128 } |
1156 | 1129 |
1157 void TestingAutomationProvider::GetUpdateInfo(DictionaryValue* args, | |
1158 IPC::Message* reply_message) { | |
1159 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); | |
1160 DBusThreadManager::Get()->GetUpdateEngineClient() | |
1161 ->GetReleaseTrack(base::Bind(GetReleaseTrackCallback, reply)); | |
1162 } | |
1163 | |
1164 void TestingAutomationProvider::UpdateCheck( | 1130 void TestingAutomationProvider::UpdateCheck( |
1165 DictionaryValue* args, | 1131 DictionaryValue* args, |
1166 IPC::Message* reply_message) { | 1132 IPC::Message* reply_message) { |
1167 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); | 1133 AutomationJSONReply* reply = new AutomationJSONReply(this, reply_message); |
1168 DBusThreadManager::Get()->GetUpdateEngineClient() | 1134 DBusThreadManager::Get()->GetUpdateEngineClient() |
1169 ->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply)); | 1135 ->RequestUpdateCheck(base::Bind(UpdateCheckCallback, reply)); |
1170 } | 1136 } |
1171 | 1137 |
1172 void TestingAutomationProvider::SetReleaseTrack(DictionaryValue* args, | |
1173 IPC::Message* reply_message) { | |
1174 AutomationJSONReply reply(this, reply_message); | |
1175 std::string track; | |
1176 if (!args->GetString("track", &track)) { | |
1177 reply.SendError("Invalid or missing args."); | |
1178 return; | |
1179 } | |
1180 | |
1181 DBusThreadManager::Get()->GetUpdateEngineClient()->SetReleaseTrack(track); | |
1182 reply.SendSuccess(NULL); | |
1183 } | |
1184 | |
1185 void TestingAutomationProvider::GetVolumeInfo(DictionaryValue* args, | 1138 void TestingAutomationProvider::GetVolumeInfo(DictionaryValue* args, |
1186 IPC::Message* reply_message) { | 1139 IPC::Message* reply_message) { |
1187 AutomationJSONReply reply(this, reply_message); | 1140 AutomationJSONReply reply(this, reply_message); |
1188 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); | 1141 scoped_ptr<DictionaryValue> return_value(new DictionaryValue); |
1189 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); | 1142 chromeos::AudioHandler* audio_handler = chromeos::AudioHandler::GetInstance(); |
1190 if (!audio_handler) { | 1143 if (!audio_handler) { |
1191 reply.SendError("AudioHandler not initialized."); | 1144 reply.SendError("AudioHandler not initialized."); |
1192 return; | 1145 return; |
1193 } | 1146 } |
1194 return_value->SetDouble("volume", audio_handler->GetVolumePercent()); | 1147 return_value->SetDouble("volume", audio_handler->GetVolumePercent()); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 | 1192 |
1240 void TestingAutomationProvider::AddChromeosObservers() { | 1193 void TestingAutomationProvider::AddChromeosObservers() { |
1241 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1194 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
1242 AddObserver(this); | 1195 AddObserver(this); |
1243 } | 1196 } |
1244 | 1197 |
1245 void TestingAutomationProvider::RemoveChromeosObservers() { | 1198 void TestingAutomationProvider::RemoveChromeosObservers() { |
1246 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> | 1199 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()-> |
1247 RemoveObserver(this); | 1200 RemoveObserver(this); |
1248 } | 1201 } |
OLD | NEW |