| OLD | NEW |
| 1 // Copyright (c) 2011 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 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ | 5 #ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
| 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ | 6 #define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| (...skipping 15 matching lines...) Expand all Loading... |
| 27 const std::string& printer_id); | 27 const std::string& printer_id); |
| 28 static GURL GetUrlForPrinterList(const GURL& cloud_print_server_url, | 28 static GURL GetUrlForPrinterList(const GURL& cloud_print_server_url, |
| 29 const std::string& proxy_id); | 29 const std::string& proxy_id); |
| 30 static GURL GetUrlForJobFetch(const GURL& cloud_print_server_url, | 30 static GURL GetUrlForJobFetch(const GURL& cloud_print_server_url, |
| 31 const std::string& printer_id, | 31 const std::string& printer_id, |
| 32 const std::string& reason); | 32 const std::string& reason); |
| 33 static GURL GetUrlForJobStatusUpdate(const GURL& cloud_print_server_url, | 33 static GURL GetUrlForJobStatusUpdate(const GURL& cloud_print_server_url, |
| 34 const std::string& job_id, | 34 const std::string& job_id, |
| 35 cloud_print::PrintJobStatus status); | 35 cloud_print::PrintJobStatus status); |
| 36 static GURL GetUrlForJobStatusUpdate( | 36 static GURL GetUrlForJobStatusUpdate( |
| 37 const GURL& cloud_print_server_url, const std::string& job_id, | 37 const GURL& cloud_print_server_url, |
| 38 const std::string& job_id, |
| 38 const cloud_print::PrintJobDetails& details); | 39 const cloud_print::PrintJobDetails& details); |
| 39 static GURL GetUrlForUserMessage(const GURL& cloud_print_server_url, | 40 static GURL GetUrlForUserMessage(const GURL& cloud_print_server_url, |
| 40 const std::string& message_id); | 41 const std::string& message_id); |
| 41 static GURL GetUrlForGetAuthCode(const GURL& cloud_print_server_url, | 42 static GURL GetUrlForGetAuthCode(const GURL& cloud_print_server_url, |
| 42 const std::string& oauth_client_id, | 43 const std::string& oauth_client_id, |
| 43 const std::string& proxy_id); | 44 const std::string& proxy_id); |
| 44 | 45 |
| 45 | |
| 46 // Parses the response data for any cloud print server request. The method | |
| 47 // returns false if there was an error in parsing the JSON. The succeeded | |
| 48 // value returns the value of the "success" value in the response JSON. | |
| 49 // Returns the response as a dictionary value. | |
| 50 static bool ParseResponseJSON(const std::string& response_data, | |
| 51 bool* succeeded, | |
| 52 base::DictionaryValue** response_dict); | |
| 53 | |
| 54 // Prepares one value as part of a multi-part upload request. | |
| 55 static void AddMultipartValueForUpload( | |
| 56 const std::string& value_name, const std::string& value, | |
| 57 const std::string& mime_boundary, const std::string& content_type, | |
| 58 std::string* post_data); | |
| 59 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). | |
| 60 static void CreateMimeBoundaryForUpload(std::string *out); | |
| 61 // Generates an MD5 hash of the contents of a string map. | 46 // Generates an MD5 hash of the contents of a string map. |
| 62 static std::string GenerateHashOfStringMap( | 47 static std::string GenerateHashOfStringMap( |
| 63 const std::map<std::string, std::string>& string_map); | 48 const std::map<std::string, std::string>& string_map); |
| 64 static void GenerateMultipartPostDataForPrinterTags( | 49 static void GenerateMultipartPostDataForPrinterTags( |
| 65 const std::map<std::string, std::string>& printer_tags, | 50 const std::map<std::string, std::string>& printer_tags, |
| 66 const std::string& mime_boundary, | 51 const std::string& mime_boundary, |
| 67 std::string* post_data); | 52 std::string* post_data); |
| 68 | 53 |
| 69 // Returns true is tags indicate a dry run (test) job. | 54 // Returns true is tags indicate a dry run (test) job. |
| 70 static bool IsDryRunJob(const std::vector<std::string>& tags); | 55 static bool IsDryRunJob(const std::vector<std::string>& tags); |
| 71 | 56 |
| 72 static std::string GetCloudPrintAuthHeader(); | 57 static std::string GetCloudPrintAuthHeader(); |
| 73 | 58 |
| 74 private: | 59 private: |
| 75 CloudPrintHelpers() {} | 60 CloudPrintHelpers() {} |
| 76 }; | 61 }; |
| 77 | 62 |
| 78 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ | 63 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
| OLD | NEW |