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 #include "chrome/browser/local_discovery/privet_http_impl.h" | 5 #include "chrome/browser/local_discovery/privet_http_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "chrome/browser/local_discovery/privet_constants.h" | 10 #include "chrome/browser/local_discovery/privet_constants.h" |
11 #include "net/base/url_util.h" | 11 #include "net/base/url_util.h" |
12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
13 | 13 |
14 namespace local_discovery { | 14 namespace local_discovery { |
15 | 15 |
16 namespace { | 16 namespace { |
17 const char kUrlPlaceHolder[] = "http://host/"; | 17 const char kUrlPlaceHolder[] = "http://host/"; |
18 const char kPrivetRegisterActionArgName[] = "action"; | 18 const char kPrivetRegisterActionArgName[] = "action"; |
19 const char kPrivetRegisterUserArgName[] = "user"; | 19 const char kPrivetRegisterUserArgName[] = "user"; |
20 | 20 |
21 const char kPrivetInfoPath[] = "/privet/info"; | |
22 const char kPrivetRegisterPath[] = "/privet/register"; | |
23 const char kPrivetCapabilitiesPath[] = "/privet/capabilities"; | |
24 const char kPrivetSubmitdocPath[] = "/privet/printer/submitdoc"; | |
25 const char kPrivetCreatejobPath[] = "/privet/printer/createjob"; | |
26 | |
27 const char kPrivetURLKeyUser[] = "user"; | 21 const char kPrivetURLKeyUser[] = "user"; |
28 const char kPrivetURLKeyJobname[] = "jobname"; | 22 const char kPrivetURLKeyJobname[] = "jobname"; |
29 const char kPrivetURLKeyOffline[] = "offline"; | 23 const char kPrivetURLKeyOffline[] = "offline"; |
30 const char kPrivetURLValueOffline[] = "1"; | 24 const char kPrivetURLValueOffline[] = "1"; |
31 | 25 |
32 const char kPrivetContentTypePDF[] = "application/pdf"; | 26 const char kPrivetContentTypePDF[] = "application/pdf"; |
33 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; | 27 const char kPrivetContentTypePWGRaster[] = "image/pwg-raster"; |
34 | 28 |
35 const char kPrivetCDDKeySupportedContentTypes[] = | 29 const char kPrivetCDDKeySupportedContentTypes[] = |
36 "printer.supported_content_type"; | 30 "printer.supported_content_type"; |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 value.GetString(kPrivetKeyDeviceID, &id); | 228 value.GetString(kPrivetKeyDeviceID, &id); |
235 ongoing_ = false; | 229 ongoing_ = false; |
236 expected_id_ = id; | 230 expected_id_ = id; |
237 StartInfoOperation(); | 231 StartInfoOperation(); |
238 } | 232 } |
239 | 233 |
240 void PrivetRegisterOperationImpl::OnPrivetInfoDone( | 234 void PrivetRegisterOperationImpl::OnPrivetInfoDone( |
241 PrivetInfoOperation* operation, | 235 PrivetInfoOperation* operation, |
242 int http_code, | 236 int http_code, |
243 const base::DictionaryValue* value) { | 237 const base::DictionaryValue* value) { |
244 // TODO (noamsml): Simplify error case. | 238 // TODO(noamsml): Simplify error case. |
245 if (!value) { | 239 if (!value) { |
246 delegate_->OnPrivetRegisterError(this, | 240 delegate_->OnPrivetRegisterError(this, |
247 kPrivetActionNameInfo, | 241 kPrivetActionNameInfo, |
248 FAILURE_NETWORK, | 242 FAILURE_NETWORK, |
249 -1, | 243 -1, |
250 NULL); | 244 NULL); |
251 return; | 245 return; |
252 } | 246 } |
253 | 247 |
254 if (!value->HasKey(kPrivetInfoKeyID)) { | 248 if (!value->HasKey(kPrivetInfoKeyID)) { |
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
674 TokenCallbackVector token_callbacks; | 668 TokenCallbackVector token_callbacks; |
675 token_callbacks_.swap(token_callbacks); | 669 token_callbacks_.swap(token_callbacks); |
676 | 670 |
677 for (TokenCallbackVector::iterator i = token_callbacks.begin(); | 671 for (TokenCallbackVector::iterator i = token_callbacks.begin(); |
678 i != token_callbacks.end(); i++) { | 672 i != token_callbacks.end(); i++) { |
679 i->Run(token); | 673 i->Run(token); |
680 } | 674 } |
681 } | 675 } |
682 | 676 |
683 } // namespace local_discovery | 677 } // namespace local_discovery |
OLD | NEW |