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> |
11 | 11 |
12 #include "chrome/service/cloud_print/print_system.h" | 12 #include "chrome/service/cloud_print/print_system.h" |
13 #include "googleurl/src/gurl.h" | 13 #include "googleurl/src/gurl.h" |
14 | 14 |
15 class DictionaryValue; | |
16 class Task; | 15 class Task; |
17 class URLFetcher; | 16 class URLFetcher; |
18 | 17 |
| 18 namespace base { |
| 19 class DictionaryValue; |
| 20 } |
| 21 |
19 // Helper methods for the cloud print proxy code. | 22 // Helper methods for the cloud print proxy code. |
20 class CloudPrintHelpers { | 23 class CloudPrintHelpers { |
21 public: | 24 public: |
22 static GURL GetUrlForPrinterRegistration(const GURL& cloud_print_server_url); | 25 static GURL GetUrlForPrinterRegistration(const GURL& cloud_print_server_url); |
23 static GURL GetUrlForPrinterUpdate(const GURL& cloud_print_server_url, | 26 static GURL GetUrlForPrinterUpdate(const GURL& cloud_print_server_url, |
24 const std::string& printer_id); | 27 const std::string& printer_id); |
25 static GURL GetUrlForPrinterDelete(const GURL& cloud_print_server_url, | 28 static GURL GetUrlForPrinterDelete(const GURL& cloud_print_server_url, |
26 const std::string& printer_id); | 29 const std::string& printer_id); |
27 static GURL GetUrlForPrinterList(const GURL& cloud_print_server_url, | 30 static GURL GetUrlForPrinterList(const GURL& cloud_print_server_url, |
28 const std::string& proxy_id); | 31 const std::string& proxy_id); |
(...skipping 11 matching lines...) Expand all Loading... |
40 static GURL GetUrlForGetAuthCode(const GURL& cloud_print_server_url, | 43 static GURL GetUrlForGetAuthCode(const GURL& cloud_print_server_url, |
41 const std::string& oauth_client_id, | 44 const std::string& oauth_client_id, |
42 const std::string& proxy_id); | 45 const std::string& proxy_id); |
43 | 46 |
44 | 47 |
45 // Parses the response data for any cloud print server request. The method | 48 // Parses the response data for any cloud print server request. The method |
46 // returns false if there was an error in parsing the JSON. The succeeded | 49 // returns false if there was an error in parsing the JSON. The succeeded |
47 // value returns the value of the "success" value in the response JSON. | 50 // value returns the value of the "success" value in the response JSON. |
48 // Returns the response as a dictionary value. | 51 // Returns the response as a dictionary value. |
49 static bool ParseResponseJSON(const std::string& response_data, | 52 static bool ParseResponseJSON(const std::string& response_data, |
50 bool* succeeded, DictionaryValue** response_dict); | 53 bool* succeeded, |
| 54 base::DictionaryValue** response_dict); |
51 | 55 |
52 // Prepares one value as part of a multi-part upload request. | 56 // Prepares one value as part of a multi-part upload request. |
53 static void AddMultipartValueForUpload( | 57 static void AddMultipartValueForUpload( |
54 const std::string& value_name, const std::string& value, | 58 const std::string& value_name, const std::string& value, |
55 const std::string& mime_boundary, const std::string& content_type, | 59 const std::string& mime_boundary, const std::string& content_type, |
56 std::string* post_data); | 60 std::string* post_data); |
57 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). | 61 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). |
58 static void CreateMimeBoundaryForUpload(std::string *out); | 62 static void CreateMimeBoundaryForUpload(std::string *out); |
59 // Generates an MD5 hash of the contents of a string map. | 63 // Generates an MD5 hash of the contents of a string map. |
60 static std::string GenerateHashOfStringMap( | 64 static std::string GenerateHashOfStringMap( |
61 const std::map<std::string, std::string>& string_map); | 65 const std::map<std::string, std::string>& string_map); |
62 static void GenerateMultipartPostDataForPrinterTags( | 66 static void GenerateMultipartPostDataForPrinterTags( |
63 const std::map<std::string, std::string>& printer_tags, | 67 const std::map<std::string, std::string>& printer_tags, |
64 const std::string& mime_boundary, | 68 const std::string& mime_boundary, |
65 std::string* post_data); | 69 std::string* post_data); |
66 | 70 |
67 // Returns true is tags indicate a dry run (test) job. | 71 // Returns true is tags indicate a dry run (test) job. |
68 static bool IsDryRunJob(const std::vector<std::string>& tags); | 72 static bool IsDryRunJob(const std::vector<std::string>& tags); |
69 private: | 73 private: |
70 CloudPrintHelpers() { | 74 CloudPrintHelpers() { |
71 } | 75 } |
72 }; | 76 }; |
73 | 77 |
74 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ | 78 #endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
75 | |
OLD | NEW |