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/cloud_print_printer_list.h" | 5 #include "chrome/browser/local_discovery/cloud_print_printer_list.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "chrome/common/cloud_print/cloud_print_constants.h" | 10 #include "chrome/common/cloud_print/cloud_print_constants.h" |
11 #include "components/cloud_devices/common/cloud_devices_urls.h" | 11 #include "components/cloud_devices/common/cloud_devices_urls.h" |
12 | 12 |
13 namespace local_discovery { | 13 namespace local_discovery { |
14 | 14 |
15 CloudPrintPrinterList::CloudPrintPrinterList( | 15 CloudPrintPrinterList::CloudPrintPrinterList( |
16 net::URLRequestContextGetter* request_context, | 16 net::URLRequestContextGetter* request_context, |
17 OAuth2TokenService* token_service, | 17 OAuth2TokenService* token_service, |
18 const std::string& account_id, | 18 const std::string& account_id, |
19 CloudDeviceListDelegate* delegate) | 19 CloudDeviceListDelegate* delegate) |
20 : request_context_(request_context), | 20 : delegate_(delegate), |
21 delegate_(delegate), | 21 api_flow_(request_context, |
22 api_flow_(request_context_, | |
23 token_service, | 22 token_service, |
24 account_id, | 23 account_id, |
25 cloud_devices::GetCloudPrintRelativeURL("search"), | |
26 this) { | 24 this) { |
27 } | 25 } |
28 | 26 |
29 CloudPrintPrinterList::~CloudPrintPrinterList() { | 27 CloudPrintPrinterList::~CloudPrintPrinterList() { |
30 } | 28 } |
31 | 29 |
32 void CloudPrintPrinterList::Start() { | 30 void CloudPrintPrinterList::Start() { |
33 api_flow_.Start(); | 31 api_flow_.Start(); |
34 } | 32 } |
35 | 33 |
(...skipping 23 matching lines...) Expand all Loading... |
59 | 57 |
60 if (!FillPrinterDetails(printer, &printer_details)) | 58 if (!FillPrinterDetails(printer, &printer_details)) |
61 continue; | 59 continue; |
62 | 60 |
63 printer_list_.push_back(printer_details); | 61 printer_list_.push_back(printer_details); |
64 } | 62 } |
65 | 63 |
66 delegate_->OnDeviceListReady(); | 64 delegate_->OnDeviceListReady(); |
67 } | 65 } |
68 | 66 |
69 bool CloudPrintPrinterList::GCDIsCloudPrint() { return true; } | 67 GURL CloudPrintPrinterList::GetURL() { |
| 68 return cloud_devices::GetCloudPrintRelativeURL("search"); |
| 69 } |
70 | 70 |
71 bool CloudPrintPrinterList::FillPrinterDetails( | 71 bool CloudPrintPrinterList::FillPrinterDetails( |
72 const base::DictionaryValue* printer_value, | 72 const base::DictionaryValue* printer_value, |
73 CloudDeviceListDelegate::Device* printer_details) { | 73 CloudDeviceListDelegate::Device* printer_details) { |
74 if (!printer_value->GetString(cloud_print::kIdValue, &printer_details->id)) | 74 if (!printer_value->GetString(cloud_print::kIdValue, &printer_details->id)) |
75 return false; | 75 return false; |
76 | 76 |
77 if (!printer_value->GetString(cloud_print::kDisplayNameValue, | 77 if (!printer_value->GetString(cloud_print::kDisplayNameValue, |
78 &printer_details->display_name)) { | 78 &printer_details->display_name)) { |
79 return false; | 79 return false; |
80 } | 80 } |
81 | 81 |
82 // Non-essential. | 82 // Non-essential. |
83 printer_value->GetString(cloud_print::kPrinterDescValue, | 83 printer_value->GetString(cloud_print::kPrinterDescValue, |
84 &printer_details->description); | 84 &printer_details->description); |
85 | 85 |
86 printer_details->type = CloudDeviceListDelegate::kDeviceTypePrinter; | 86 printer_details->type = CloudDeviceListDelegate::kDeviceTypePrinter; |
87 | 87 |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 } // namespace local_discovery | 91 } // namespace local_discovery |
OLD | NEW |