Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: chrome/common/cloud_print/cloud_print_helpers.h

Issue 11360151: Move common cloud print methods from service/cloud_print to common/cloud_print. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 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_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 5 #ifndef CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
6 #define CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 6 #define CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
7 7
8 #include <map>
8 #include <string> 9 #include <string>
10 #include <vector>
9 11
10 class GURL; 12 class GURL;
11 13
12 namespace base { 14 namespace base {
13 class DictionaryValue; 15 class DictionaryValue;
14 } 16 }
15 17
16 // Helper consts and methods for both cloud print and chrome browser. 18 // Helper consts and methods for both cloud print and chrome browser.
17 namespace cloud_print { 19 namespace cloud_print {
18 20
19 // Values in the respone JSON from the cloud print server 21 typedef std::map<std::string, std::string> PrinterTags;
msw 2012/11/17 00:22:30 nit: comment on the significance of printer tags.
Chen Yu 2012/11/26 12:07:06 Done.
20 extern const char kPrinterListValue[];
21 extern const char kSuccessValue[];
22
23 extern const char kChromeCloudPrintProxyHeader[];
24 22
25 // Appends a relative path to the url making sure to append a '/' if the 23 // 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 24 // URL's path does not end with a slash. It is assumed that |path| does not
27 // begin with a '/'. 25 // begin with a '/'.
28 // NOTE: Since we ALWAYS want to append here, we simply append the path string 26 // 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 27 // instead of calling url_utils::ResolveRelative. The input |url| may or may not
30 // contain a '/' at the end. 28 // contain a '/' at the end.
31 std::string AppendPathToUrl(const GURL& url, const std::string& path); 29 std::string AppendPathToUrl(const GURL& url, const std::string& path);
32 30
33 GURL GetUrlForSearch(const GURL& cloud_print_server_url); 31 GURL GetUrlForSearch(const GURL& cloud_print_server_url);
34 GURL GetUrlForSubmit(const GURL& cloud_print_server_url); 32 GURL GetUrlForSubmit(const GURL& cloud_print_server_url);
33 GURL GetUrlForPrinterList(const GURL& cloud_print_server_url,
34 const std::string& proxy_id);
35 GURL GetUrlForPrinterRegistration(const GURL& cloud_print_server_url);
36 GURL GetUrlForPrinterUpdate(const GURL& cloud_print_server_url,
37 const std::string& printer_id);
38 GURL GetUrlForPrinterDelete(const GURL& cloud_print_server_url,
39 const std::string& printer_id,
40 const std::string& reason);
41 GURL GetUrlForJobFetch(const GURL& cloud_print_server_url,
42 const std::string& printer_id,
43 const std::string& reason);
44 GURL GetUrlForJobDelete(const GURL& cloud_print_server_url,
45 const std::string& job_id);
46 GURL GetUrlForJobStatusUpdate(const GURL& cloud_print_server_url,
47 const std::string& job_id,
48 const std::string& status_string);
49 GURL GetUrlForUserMessage(const GURL& cloud_print_server_url,
50 const std::string& message_id);
51 GURL GetUrlForGetAuthCode(const GURL& cloud_print_server_url,
52 const std::string& oauth_client_id,
53 const std::string& proxy_id);
35 54
36 // Parses the response data for any cloud print server request. The method 55 // 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 56 // 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. 57 // value returns the value of the "success" value in the response JSON.
39 // Returns the response as a dictionary value. 58 // Returns the response as a dictionary value.
40 bool ParseResponseJSON(const std::string& response_data, 59 bool ParseResponseJSON(const std::string& response_data,
41 bool* succeeded, 60 bool* succeeded,
42 base::DictionaryValue** response_dict); 61 base::DictionaryValue** response_dict);
43 62
44 // Prepares one value as part of a multi-part upload request. 63 // Prepares one value as part of a multi-part upload request.
45 void AddMultipartValueForUpload(const std::string& value_name, 64 void AddMultipartValueForUpload(const std::string& value_name,
46 const std::string& value, 65 const std::string& value,
47 const std::string& mime_boundary, 66 const std::string& mime_boundary,
48 const std::string& content_type, 67 const std::string& content_type,
49 std::string* post_data); 68 std::string* post_data);
50 69
70 // Returns the mime type of multipart with |mime_boundary|.
msw 2012/11/17 00:22:30 nit: MIME
Chen Yu 2012/11/26 12:07:06 Done.
71 std::string GetMultipartMimeType(const std::string& mime_boundary);
72
51 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits). 73 // Create a MIME boundary marker (27 '-' characters followed by 16 hex digits).
52 void CreateMimeBoundaryForUpload(std::string *out); 74 void CreateMimeBoundaryForUpload(std::string *out);
53 75
76 // Returns an MD5 hash for printer tags from |printer_tags| and the default tags
msw 2012/11/17 00:22:30 nit: remove "printer tags from", |printer_tags| al
Chen Yu 2012/11/26 12:07:06 Done.
77 // required by cloud print server.
78 std::string GetHashOfPrinterTags(const PrinterTags& printer_tags);
79
80 // Returns an post data for printer tags from |printer_tags| and the default
msw 2012/11/17 00:22:30 nit: s/an/the/ and perhaps just say "Get the post
Chen Yu 2012/11/26 12:07:06 Done.
81 // tags required by cloud print server.
82 std::string GetPostDataForPrinterTags(
83 const PrinterTags& printer_tags,
84 const std::string& mime_boundary,
85 const std::string& proxy_tag_prefix,
86 const std::string& tags_hash_tag_name);
87
88 // Returns true is tags indicate a dry run (test) job.
msw 2012/11/17 00:22:30 nit: s/is/if/
Chen Yu 2012/11/26 12:07:06 Done.
89 bool IsDryRunJob(const std::vector<std::string>& tags,
90 const std::string& tag_dry_run_flag);
91
92 // Created CloudPrint auth header from the auth token.
msw 2012/11/17 00:22:30 nit: "Get the cloud print auth header from |auth_t
Chen Yu 2012/11/26 12:07:06 Done.
93 std::string GetCloudPrintAuthHeader(const std::string& auth_token);
94
54 } // namespace cloud_print 95 } // namespace cloud_print
55 96
56 #endif // CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_ 97 #endif // CHROME_COMMON_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698