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 #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> |
(...skipping 16 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 const std::string& oauth_client_id, | |
43 const std::string& proxy_id); | |
44 | 42 |
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. | 43 // Generates an MD5 hash of the contents of a string map. |
62 static std::string GenerateHashOfStringMap( | 44 static std::string GenerateHashOfStringMap( |
63 const std::map<std::string, std::string>& string_map); | 45 const std::map<std::string, std::string>& string_map); |
64 static void GenerateMultipartPostDataForPrinterTags( | 46 static void GenerateMultipartPostDataForPrinterTags( |
65 const std::map<std::string, std::string>& printer_tags, | 47 const std::map<std::string, std::string>& printer_tags, |
66 const std::string& mime_boundary, | 48 const std::string& mime_boundary, |
67 std::string* post_data); | 49 std::string* post_data); |
68 | 50 |
69 // Returns true is tags indicate a dry run (test) job. | 51 // Returns true is tags indicate a dry run (test) job. |
70 static bool IsDryRunJob(const std::vector<std::string>& tags); | 52 static bool IsDryRunJob(const std::vector<std::string>& tags); |
71 | 53 |
72 static std::string GetCloudPrintAuthHeader(); | 54 static std::string GetCloudPrintAuthHeader(); |
73 | 55 |
74 private: | 56 private: |
75 CloudPrintHelpers() {} | 57 CloudPrintHelpers() {} |
76 }; | 58 }; |
77 | 59 |
78 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ | 60 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
OLD | NEW |