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/service/cloud_print/cloud_print_url_fetcher.h" | 5 #include "chrome/service/cloud_print/cloud_print_url_fetcher.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 action = RETRY_REQUEST; | 195 action = RETRY_REQUEST; |
196 else | 196 else |
197 action = delegate_->HandleRawData(source, source->GetURL(), data); | 197 action = delegate_->HandleRawData(source, source->GetURL(), data); |
198 | 198 |
199 if (action == CONTINUE_PROCESSING) { | 199 if (action == CONTINUE_PROCESSING) { |
200 // If the delegate is not interested in handling the raw response data, | 200 // If the delegate is not interested in handling the raw response data, |
201 // we assume that a JSON response is expected. If we do not get a JSON | 201 // we assume that a JSON response is expected. If we do not get a JSON |
202 // response, we will retry (to handle the case where we got redirected | 202 // response, we will retry (to handle the case where we got redirected |
203 // to a non-cloudprint-server URL eg. for authentication). | 203 // to a non-cloudprint-server URL eg. for authentication). |
204 bool succeeded = false; | 204 bool succeeded = false; |
205 scoped_ptr<base::DictionaryValue> response_dict = | 205 std::unique_ptr<base::DictionaryValue> response_dict = |
206 ParseResponseJSON(data, &succeeded); | 206 ParseResponseJSON(data, &succeeded); |
207 | 207 |
208 if (response_dict) { | 208 if (response_dict) { |
209 action = delegate_->HandleJSONData(source, | 209 action = delegate_->HandleJSONData(source, |
210 source->GetURL(), | 210 source->GetURL(), |
211 response_dict.get(), | 211 response_dict.get(), |
212 succeeded); | 212 succeeded); |
213 } else { | 213 } else { |
214 action = RETRY_REQUEST; | 214 action = RETRY_REQUEST; |
215 } | 215 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 ServiceURLRequestContextGetter* getter = | 300 ServiceURLRequestContextGetter* getter = |
301 g_service_process->GetServiceURLRequestContextGetter(); | 301 g_service_process->GetServiceURLRequestContextGetter(); |
302 // Now set up the user agent for cloudprint. | 302 // Now set up the user agent for cloudprint. |
303 std::string user_agent = getter->user_agent(); | 303 std::string user_agent = getter->user_agent(); |
304 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); | 304 base::StringAppendF(&user_agent, " %s", kCloudPrintUserAgent); |
305 getter->set_user_agent(user_agent); | 305 getter->set_user_agent(user_agent); |
306 return getter; | 306 return getter; |
307 } | 307 } |
308 | 308 |
309 } // namespace cloud_print | 309 } // namespace cloud_print |
OLD | NEW |