OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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_device_list.h" | 5 #include "chrome/browser/local_discovery/cloud_device_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 "components/cloud_devices/common/cloud_devices_urls.h" | 10 #include "components/cloud_devices/common/cloud_devices_urls.h" |
11 | 11 |
12 namespace local_discovery { | 12 namespace local_discovery { |
13 | 13 |
14 CloudDeviceList::CloudDeviceList(net::URLRequestContextGetter* request_context, | 14 CloudDeviceList::CloudDeviceList(net::URLRequestContextGetter* request_context, |
15 OAuth2TokenService* token_service, | 15 OAuth2TokenService* token_service, |
16 const std::string& account_id, | 16 const std::string& account_id, |
17 CloudDeviceListDelegate* delegate) | 17 CloudDeviceListDelegate* delegate) |
18 : request_context_(request_context), | 18 : delegate_(delegate), |
19 delegate_(delegate), | 19 api_flow_(request_context, |
20 api_flow_(request_context_, | |
21 token_service, | 20 token_service, |
22 account_id, | 21 account_id, |
23 cloud_devices::GetCloudDevicesRelativeURL("devices"), | |
24 this) { | 22 this) { |
25 } | 23 } |
26 | 24 |
27 CloudDeviceList::~CloudDeviceList() { | 25 CloudDeviceList::~CloudDeviceList() { |
28 } | 26 } |
29 | 27 |
30 void CloudDeviceList::Start() { | 28 void CloudDeviceList::Start() { |
31 api_flow_.Start(); | 29 api_flow_.Start(); |
32 } | 30 } |
33 | 31 |
(...skipping 21 matching lines...) Expand all Loading... |
55 | 53 |
56 if (!FillDeviceDetails(device, &details)) | 54 if (!FillDeviceDetails(device, &details)) |
57 continue; | 55 continue; |
58 | 56 |
59 device_list_.push_back(details); | 57 device_list_.push_back(details); |
60 } | 58 } |
61 | 59 |
62 delegate_->OnDeviceListReady(); | 60 delegate_->OnDeviceListReady(); |
63 } | 61 } |
64 | 62 |
65 bool CloudDeviceList::GCDIsCloudPrint() { | 63 GURL CloudDeviceList::GetURL() { |
66 return false; | 64 return cloud_devices::GetCloudDevicesRelativeURL("devices"); |
67 } | 65 } |
68 | 66 |
69 bool CloudDeviceList::FillDeviceDetails( | 67 bool CloudDeviceList::FillDeviceDetails( |
70 const base::DictionaryValue* device_value, | 68 const base::DictionaryValue* device_value, |
71 CloudDeviceListDelegate::Device* details) { | 69 CloudDeviceListDelegate::Device* details) { |
72 if (!device_value->GetString("id", &details->id)) | 70 if (!device_value->GetString("id", &details->id)) |
73 return false; | 71 return false; |
74 | 72 |
75 if (!device_value->GetString("displayName", &details->display_name) && | 73 if (!device_value->GetString("displayName", &details->display_name) && |
76 !device_value->GetString("systemName", &details->display_name)) { | 74 !device_value->GetString("systemName", &details->display_name)) { |
77 return false; | 75 return false; |
78 } | 76 } |
79 | 77 |
80 if (!device_value->GetString("deviceKind", &details->type)) | 78 if (!device_value->GetString("deviceKind", &details->type)) |
81 return false; | 79 return false; |
82 | 80 |
83 // Non-essential. | 81 // Non-essential. |
84 device_value->GetString("description", &details->description); | 82 device_value->GetString("description", &details->description); |
85 | 83 |
86 return true; | 84 return true; |
87 } | 85 } |
88 | 86 |
89 } // namespace local_discovery | 87 } // namespace local_discovery |
OLD | NEW |