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

Side by Side Diff: chrome/browser/local_discovery/gcd_registration_ticket_creator.cc

Issue 307353008: GCD registration ticket creation flow (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months 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
(Empty)
1 // Copyright 2014 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 #include "chrome/browser/local_discovery/gcd_registration_ticket_creator.h"
6
7 #include "chrome/browser/local_discovery/gcd_constants.h"
8 #include "chrome/common/cloud_print/cloud_print_constants.h"
9 #include "components/cloud_devices/common/cloud_devices_urls.h"
10
11 namespace local_discovery {
12
13 namespace {
14
Vitaly Buka (NO REVIEWS) 2014/06/03 21:30:49 empty lines inconsistent
Noam Samuel 2014/06/03 21:48:13 Done.
15 const char kUploadData[] = "{ \"userEmail\": \"me\" }";
16 const char kKindRegistrationTicket[] = "clouddevices#registrationTicket";
17 const char kGCDKeyId[] = "id";
18 }
19
20 GCDRegistrationTicketCreator::GCDRegistrationTicketCreator(
21 const ResponseCallback& callback)
22 : callback_(callback) {
23 }
24
25 GCDRegistrationTicketCreator::~GCDRegistrationTicketCreator() {
26 }
27
28 void GCDRegistrationTicketCreator::GetUploadData(std::string* upload_type,
29 std::string* upload_data) {
30 *upload_data = kUploadData;
31
32 // TODO(noamsml): Move this constant to cloud_devices component.
33 *upload_type = cloud_print::kContentTypeJSON;
34 }
35
36 net::URLFetcher::RequestType GCDRegistrationTicketCreator::GetRequestType() {
37 return net::URLFetcher::POST;
38 }
39
40 void GCDRegistrationTicketCreator::OnGCDAPIFlowError(
41 GCDApiFlow::Status status) {
42 callback_.Run(std::string());
43 }
44
45 void GCDRegistrationTicketCreator::OnGCDAPIFlowComplete(
46 const base::DictionaryValue& value) {
47 std::string kind;
48 std::string id;
49 if (!value.GetString(kGCDKeyKind, &kind) || kind != kKindRegistrationTicket ||
50 !value.GetString(kGCDKeyId, &id)) {
51 callback_.Run(std::string());
52 return;
53 }
54
55 callback_.Run(id);
56 }
57
58 GURL GCDRegistrationTicketCreator::GetURL() {
59 return cloud_devices::GetCloudDevicesRelativeURL("registrationTickets");
60 }
61
62 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698