OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
11 #include "chrome/browser/local_discovery/privet_url_fetcher.h" | 11 #include "chrome/browser/local_discovery/privet_url_fetcher.h" |
| 12 #include "chrome/browser/local_discovery/pwg_raster_converter.h" |
12 #include "net/base/host_port_pair.h" | 13 #include "net/base/host_port_pair.h" |
13 | 14 |
| 15 namespace base { |
| 16 class RefCountedBytes; |
| 17 } |
| 18 |
14 namespace local_discovery { | 19 namespace local_discovery { |
15 | 20 |
16 class PrivetHTTPClient; | 21 class PrivetHTTPClient; |
17 | 22 |
18 // Represents a request to /privet/info. Will store a cached response and token | 23 // Represents a request to /privet/info. Will store a cached response and token |
19 // in the PrivetHTTPClient that created. | 24 // in the PrivetHTTPClient that created. |
20 class PrivetInfoOperation { | 25 class PrivetInfoOperation { |
21 public: | 26 public: |
22 class Delegate { | 27 class Delegate { |
23 public: | 28 public: |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 virtual void Start() = 0; | 114 virtual void Start() = 0; |
110 | 115 |
111 virtual PrivetHTTPClient* GetHTTPClient() = 0; | 116 virtual PrivetHTTPClient* GetHTTPClient() = 0; |
112 }; | 117 }; |
113 | 118 |
114 class PrivetLocalPrintOperation { | 119 class PrivetLocalPrintOperation { |
115 public: | 120 public: |
116 class Delegate { | 121 class Delegate { |
117 public: | 122 public: |
118 virtual ~Delegate() {} | 123 virtual ~Delegate() {} |
119 virtual void OnPrivetPrintingRequestPDF( | |
120 const PrivetLocalPrintOperation* print_operation) = 0; | |
121 virtual void OnPrivetPrintingRequestPWGRaster( | |
122 const PrivetLocalPrintOperation* print_operation) = 0; | |
123 virtual void OnPrivetPrintingDone( | 124 virtual void OnPrivetPrintingDone( |
124 const PrivetLocalPrintOperation* print_operation) = 0; | 125 const PrivetLocalPrintOperation* print_operation) = 0; |
125 virtual void OnPrivetPrintingError( | 126 virtual void OnPrivetPrintingError( |
126 const PrivetLocalPrintOperation* print_operation, int http_code) = 0; | 127 const PrivetLocalPrintOperation* print_operation, int http_code) = 0; |
127 }; | 128 }; |
128 | 129 |
129 virtual ~PrivetLocalPrintOperation() {} | 130 virtual ~PrivetLocalPrintOperation() {} |
130 | 131 |
131 virtual void Start() = 0; | 132 virtual void Start() = 0; |
132 | 133 |
133 // One of thsese should be called ONLY after |OnPrivetPrintingRequestPDF| or | 134 |
134 // |OnPrivetPrintingRequestPWGRaster| are called on the delegate. Data should | 135 // Required print data. MUST be called before calling |Start()|. |
135 // be in PDF or PWG format depending on what is requested by the local print | 136 virtual void SetData(base::RefCountedBytes* data) = 0; |
136 // operation. | |
137 virtual void SendData(const std::string& data) = 0; | |
138 virtual void SendDataFile(const base::FilePath& data) = 0; | |
139 | 137 |
140 // Optional attributes for /submitdoc. Call before calling |Start()| | 138 // Optional attributes for /submitdoc. Call before calling |Start()| |
141 // |ticket| should be in CJT format. | 139 // |ticket| should be in CJT format. |
142 virtual void SetTicket(const std::string& ticket) = 0; | 140 virtual void SetTicket(const std::string& ticket) = 0; |
143 // Username and jobname are for display only. | 141 // Username and jobname are for display only. |
144 virtual void SetUsername(const std::string& username) = 0; | 142 virtual void SetUsername(const std::string& username) = 0; |
145 virtual void SetJobname(const std::string& jobname) = 0; | 143 virtual void SetJobname(const std::string& jobname) = 0; |
146 // If |offline| is true, we will indicate to the printer not to post the job | 144 // If |offline| is true, we will indicate to the printer not to post the job |
147 // to Google Cloud Print. | 145 // to Google Cloud Print. |
148 virtual void SetOffline(bool offline) = 0; | 146 virtual void SetOffline(bool offline) = 0; |
149 | 147 |
| 148 // For testing, inject an alternative PWG raster converter. |
| 149 virtual void SetPWGRasterConverterForTesting( |
| 150 scoped_ptr<PWGRasterConverter> pwg_raster_converter) = 0; |
| 151 |
150 virtual PrivetHTTPClient* GetHTTPClient() = 0; | 152 virtual PrivetHTTPClient* GetHTTPClient() = 0; |
151 }; | 153 }; |
152 | 154 |
153 // Privet HTTP client. Must not outlive the operations it creates. | 155 // Privet HTTP client. Must not outlive the operations it creates. |
154 class PrivetHTTPClient { | 156 class PrivetHTTPClient { |
155 public: | 157 public: |
156 virtual ~PrivetHTTPClient() {} | 158 virtual ~PrivetHTTPClient() {} |
157 virtual const base::DictionaryValue* GetCachedInfo() const = 0; | 159 virtual const base::DictionaryValue* GetCachedInfo() const = 0; |
158 | 160 |
159 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( | 161 virtual scoped_ptr<PrivetRegisterOperation> CreateRegisterOperation( |
160 const std::string& user, | 162 const std::string& user, |
161 PrivetRegisterOperation::Delegate* delegate) = 0; | 163 PrivetRegisterOperation::Delegate* delegate) = 0; |
162 virtual scoped_ptr<PrivetInfoOperation> CreateInfoOperation( | 164 virtual scoped_ptr<PrivetInfoOperation> CreateInfoOperation( |
163 PrivetInfoOperation::Delegate* delegate) = 0; | 165 PrivetInfoOperation::Delegate* delegate) = 0; |
164 virtual scoped_ptr<PrivetCapabilitiesOperation> CreateCapabilitiesOperation( | 166 virtual scoped_ptr<PrivetCapabilitiesOperation> CreateCapabilitiesOperation( |
165 PrivetCapabilitiesOperation::Delegate* delegate) = 0; | 167 PrivetCapabilitiesOperation::Delegate* delegate) = 0; |
166 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( | 168 virtual scoped_ptr<PrivetLocalPrintOperation> CreateLocalPrintOperation( |
167 PrivetLocalPrintOperation::Delegate* delegate) = 0; | 169 PrivetLocalPrintOperation::Delegate* delegate) = 0; |
168 | 170 |
169 // A name for the HTTP client, e.g. the device name for the privet device. | 171 // A name for the HTTP client, e.g. the device name for the privet device. |
170 virtual const std::string& GetName() = 0; | 172 virtual const std::string& GetName() = 0; |
171 }; | 173 }; |
172 | 174 |
173 } // namespace local_discovery | 175 } // namespace local_discovery |
174 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ | 176 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVET_HTTP_H_ |
OLD | NEW |