OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
| 6 #define CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 class GURL; |
| 11 |
| 12 namespace base { |
| 13 class DictionaryValue; |
| 14 } |
| 15 |
| 16 // Helper consts and methods for both cloud print and chrome browser. |
| 17 namespace cloud_print { |
| 18 |
| 19 // Values in the respone JSON from the cloud print server |
| 20 extern const char kPrinterListValue[]; |
| 21 extern const char kSuccessValue[]; |
| 22 |
| 23 extern const char kChromeCloudPrintProxyHeader[]; |
| 24 |
| 25 // Appends a relative path to the url making sure to append a '/' if the |
| 26 // URL's path does not end with a slash. It is assumed that |path| does not |
| 27 // begin with a '/'. |
| 28 // NOTE: Since we ALWAYS want to append here, we simply append the path string |
| 29 // instead of calling url_utils::ResolveRelative. The input |url| may or may not |
| 30 // contain a '/' at the end. |
| 31 std::string AppendPathToUrl(const GURL& url, const std::string& path); |
| 32 |
| 33 GURL GetUrlForSearch(const GURL& cloud_print_server_url); |
| 34 GURL GetUrlForSubmit(const GURL& cloud_print_server_url); |
| 35 |
| 36 // Parses the response data for any cloud print server request. The method |
| 37 // returns false if there was an error in parsing the JSON. The succeeded |
| 38 // value returns the value of the "success" value in the response JSON. |
| 39 // Returns the response as a dictionary value. |
| 40 bool ParseResponseJSON(const std::string& response_data, |
| 41 bool* succeeded, |
| 42 base::DictionaryValue** response_dict); |
| 43 |
| 44 // Prepares one value as part of a multi-part upload request. |
| 45 void AddMultipartValueForUpload(const std::string& value_name, |
| 46 const std::string& value, |
| 47 const std::string& mime_boundary, |
| 48 const std::string& content_type, |
| 49 std::string* post_data); |
| 50 |
| 51 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). |
| 52 void CreateMimeBoundaryForUpload(std::string *out); |
| 53 |
| 54 } // namespace cloud_print |
| 55 |
| 56 #endif // CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ |
OLD | NEW |