| 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/service/cloud_print/cloud_print_helpers.h" | 5 #include "chrome/service/cloud_print/cloud_print_helpers.h" |
| 6 | 6 |
| 7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| 11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 12 #include "base/stringprintf.h" | 12 #include "base/stringprintf.h" |
| 13 #include "base/task.h" | 13 #include "base/task.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "base/values.h" | 15 #include "base/values.h" |
| 16 #include "chrome/service/cloud_print/cloud_print_consts.h" | 16 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 17 #include "chrome/service/cloud_print/cloud_print_token_store.h" |
| 17 #include "chrome/service/service_process.h" | 18 #include "chrome/service/service_process.h" |
| 18 #include "content/common/net/url_fetcher.h" | 19 #include "content/common/net/url_fetcher.h" |
| 19 | 20 |
| 20 std::string StringFromJobStatus(cloud_print::PrintJobStatus status) { | 21 std::string StringFromJobStatus(cloud_print::PrintJobStatus status) { |
| 21 std::string ret; | 22 std::string ret; |
| 22 switch (status) { | 23 switch (status) { |
| 23 case cloud_print::PRINT_JOB_STATUS_IN_PROGRESS: | 24 case cloud_print::PRINT_JOB_STATUS_IN_PROGRESS: |
| 24 ret = "in_progress"; | 25 ret = "in_progress"; |
| 25 break; | 26 break; |
| 26 case cloud_print::PRINT_JOB_STATUS_ERROR: | 27 case cloud_print::PRINT_JOB_STATUS_ERROR: |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 } | 261 } |
| 261 | 262 |
| 262 bool CloudPrintHelpers::IsDryRunJob(const std::vector<std::string>& tags) { | 263 bool CloudPrintHelpers::IsDryRunJob(const std::vector<std::string>& tags) { |
| 263 std::vector<std::string>::const_iterator it; | 264 std::vector<std::string>::const_iterator it; |
| 264 for (it = tags.begin(); it != tags.end(); ++it) { | 265 for (it = tags.begin(); it != tags.end(); ++it) { |
| 265 if (*it == kTagDryRunFlag) | 266 if (*it == kTagDryRunFlag) |
| 266 return true; | 267 return true; |
| 267 } | 268 } |
| 268 return false; | 269 return false; |
| 269 } | 270 } |
| 271 |
| 272 std::string CloudPrintHelpers::GetCloudPrintAuthHeader() { |
| 273 std::string header; |
| 274 CloudPrintTokenStore* token_store = CloudPrintTokenStore::current(); |
| 275 if (!token_store || token_store->token().empty()) { |
| 276 // Using LOG here for critical errors. GCP connector may run in the headless |
| 277 // mode and error indication might be useful for user in that case. |
| 278 LOG(ERROR) << "CP_PROXY: Missing OAuth token for request"; |
| 279 } |
| 280 |
| 281 if (token_store) { |
| 282 header = "Authorization: OAuth "; |
| 283 header += token_store->token(); |
| 284 } |
| 285 return header; |
| 286 } |
| 287 |
| OLD | NEW |