OLD | NEW |
(Empty) | |
| 1 // Copyright 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_BROWSER_CHROME_TO_MOBILE_RECEIVE_CHROME_TO_MOBILE_RECEIVE_UTIL_H_ |
| 6 #define CHROME_BROWSER_CHROME_TO_MOBILE_RECEIVE_CHROME_TO_MOBILE_RECEIVE_UTIL_H_ |
| 7 |
| 8 #include <map> |
| 9 #include <set> |
| 10 #include <string> |
| 11 |
| 12 #include "base/values.h" |
| 13 #include "googleurl/src/gurl.h" |
| 14 |
| 15 namespace cloud_print { |
| 16 class CloudPrintRequest; |
| 17 } // namespace cloud_print |
| 18 |
| 19 namespace chrome_to_mobile_receive { |
| 20 |
| 21 // Constants used in receiving chrome_to_mobile jobs. |
| 22 // The id of a snapshot. |
| 23 extern const char kSnapshotIdTag[]; |
| 24 // The tag name of the type of print jobs for snapshots. |
| 25 extern const char kSnapshotTypeTag[]; |
| 26 // The type of print jobs that contain url for snapshots that have only url. |
| 27 extern const char kSnapshotTypeURL[]; |
| 28 // The type of print jobs that contain url for snapshots sent with offline data. |
| 29 extern const char kSnapshotTypeURLWithDelayedSnapshot[]; |
| 30 // The type of print jobs that contain the offline data for snapshots. |
| 31 extern const char kSnapshotTypeSnapshot[]; |
| 32 // The tag for the original url in a snapshot. |
| 33 extern const char kSnapshotOriginalUrlTag[]; |
| 34 // The tag prefix of the proxy used to receive chrome_to_mobile jobs. |
| 35 extern const char kProxyTagPrefix[]; |
| 36 // The tag name of the tags hash for the printer associated with this device |
| 37 // to receive chrome_to_mobile jobs. |
| 38 extern const char kTagsHashTagName[]; |
| 39 |
| 40 extern const char kChromeToMobileClientParameter[]; |
| 41 |
| 42 // Returns the URL of the google cloud print server. |
| 43 GURL GetCloudPrintServerURL(); |
| 44 |
| 45 // Returns the id of the print proxy with which this device should be |
| 46 // registered. This method can be platform-specific. |
| 47 std::string GenerateProxyIdValue(); |
| 48 |
| 49 // Returns the name of the printer associated with this device to receive |
| 50 // chrome-to-mobile jobs. This method can be platform-specific. |
| 51 std::string GenreatePrinterName(); |
| 52 |
| 53 // Returns a description of the device as a cloud printer. This mehtod can be |
| 54 // platform-specific. |
| 55 std::string GeneratePrinterDescription(); |
| 56 |
| 57 // Returns the type of this device as a cloud printer. This information is used |
| 58 // to check if the printer is a chrome-to-mobile job recipient when special |
| 59 // action is needed for chrome-to-mobile on cloud print server. |
| 60 std::string GeneratePrinterType(); |
| 61 |
| 62 // Returns the post data for updating the printer with |printer_tags|. The |
| 63 // post mime boundary is returned in pointer parameter |post_mime_boundary|. |
| 64 std::string GeneratePrinterUpdatePostData( |
| 65 const std::map<std::string, std::string>& printer_tags, |
| 66 std::string* post_mime_boundary); |
| 67 |
| 68 // Returns the post data for registering the printer with |printer_tags|. The |
| 69 // post mime boundary is returned in |post_mime_boundary|. |
| 70 std::string GeneratePrinterRegistrationPostData( |
| 71 const std::map<std::string, std::string>& printer_tags, |
| 72 std::string* post_mime_boundary); |
| 73 |
| 74 // Parses the |index|th entry in |job_list| to get snapshot url job information, |
| 75 // where |job_list| is the job json returned in a cloud print fetch response. |
| 76 // If it is a valid snashot url job, the parsed data are returned in the pointer |
| 77 // parameters and true is returned. Otherwise, false is returned. |
| 78 bool ParseSnapshotURLJobInformationFromCloudPrintFetchJobList( |
| 79 const ListValue* job_list, |
| 80 int index, |
| 81 std::string* job_id, |
| 82 std::string* snapshot_id, |
| 83 std::string* snapshot_type, |
| 84 std::string* original_url, |
| 85 std::string* title, |
| 86 std::string* job_creation_time); |
| 87 |
| 88 // Parses the |index|th entry in |job_list| to get snapshot offline data job |
| 89 // information, where |job_list| is the job json returned in a cloud print fetch |
| 90 // response. |
| 91 // If it is a valid snashot offline data job, the parsed data are |
| 92 // returned in the pointer parameters and true is returned. Otherwise, false is |
| 93 // returned. |
| 94 bool ParseSnapshotOfflineDataJobInformationFromCloudPrintFetchJobList( |
| 95 const ListValue* job_list, |
| 96 int index, |
| 97 std::string* job_id, |
| 98 std::string* snapshot_id, |
| 99 std::string* offline_data_download_url); |
| 100 |
| 101 // This method parses print-to-phone job information from the |index|th entry in |
| 102 // |job_list|, where |job_list| is the job json returned in a cloud print fetch |
| 103 // response. |
| 104 // It returns true if the |index|th entry in |job_list| is a print-to-phone job; |
| 105 // parsed data are returned in the pointer parameters. It returns false therwise |
| 106 // and the values in the pointer parameters should be ignored. |
| 107 bool ParseQueuedPrintToPhoneJobFromFetchJobList( |
| 108 const ListValue* job_list, |
| 109 int index, |
| 110 std::string* job_id, |
| 111 std::string* title, |
| 112 std::string* data_download_url); |
| 113 |
| 114 } // namespace chrome_to_mobile_receive |
| 115 |
| 116 |
| 117 #endif // CHROME_BROWSER_CHROME_TO_MOBILE_RECEIVE_CHROME_TO_MOBILE_RECEIVE_UTIL
_H_ |
OLD | NEW |