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/ui/webui/local_discovery/local_discovery_ui_handler.h" | 5 #include "chrome/browser/ui/webui/local_discovery/local_discovery_ui_handler.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
14 #include "base/values.h" | 15 #include "base/values.h" |
15 #include "build/build_config.h" | 16 #include "build/build_config.h" |
16 #include "chrome/browser/local_discovery/cloud_device_list.h" | 17 #include "chrome/browser/local_discovery/cloud_device_list.h" |
17 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" | 18 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 60 |
60 scoped_ptr<base::DictionaryValue> CreateDeviceInfo( | 61 scoped_ptr<base::DictionaryValue> CreateDeviceInfo( |
61 const CloudDeviceListDelegate::Device& description) { | 62 const CloudDeviceListDelegate::Device& description) { |
62 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); | 63 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
63 | 64 |
64 return_value->SetString(kDictionaryKeyID, description.id); | 65 return_value->SetString(kDictionaryKeyID, description.id); |
65 return_value->SetString(kDictionaryKeyDisplayName, description.display_name); | 66 return_value->SetString(kDictionaryKeyDisplayName, description.display_name); |
66 return_value->SetString(kDictionaryKeyDescription, description.description); | 67 return_value->SetString(kDictionaryKeyDescription, description.description); |
67 return_value->SetString(kDictionaryKeyType, description.type); | 68 return_value->SetString(kDictionaryKeyType, description.type); |
68 | 69 |
69 return return_value.Pass(); | 70 return return_value; |
70 } | 71 } |
71 | 72 |
72 void ReadDevicesList( | 73 void ReadDevicesList( |
73 const std::vector<CloudDeviceListDelegate::Device>& devices, | 74 const std::vector<CloudDeviceListDelegate::Device>& devices, |
74 const std::set<std::string>& local_ids, | 75 const std::set<std::string>& local_ids, |
75 base::ListValue* devices_list) { | 76 base::ListValue* devices_list) { |
76 for (CloudDeviceList::iterator i = devices.begin(); i != devices.end(); i++) { | 77 for (CloudDeviceList::iterator i = devices.begin(); i != devices.end(); i++) { |
77 if (local_ids.count(i->id) > 0) { | 78 if (local_ids.count(i->id) > 0) { |
78 devices_list->Append(CreateDeviceInfo(*i).release()); | 79 devices_list->Append(CreateDeviceInfo(*i).release()); |
79 } | 80 } |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 const base::ListValue* args) { | 262 const base::ListValue* args) { |
262 Browser* browser = chrome::FindBrowserWithWebContents( | 263 Browser* browser = chrome::FindBrowserWithWebContents( |
263 web_ui()->GetWebContents()); | 264 web_ui()->GetWebContents()); |
264 DCHECK(browser); | 265 DCHECK(browser); |
265 chrome::ShowBrowserSignin( | 266 chrome::ShowBrowserSignin( |
266 browser, signin_metrics::AccessPoint::ACCESS_POINT_DEVICES_PAGE); | 267 browser, signin_metrics::AccessPoint::ACCESS_POINT_DEVICES_PAGE); |
267 } | 268 } |
268 | 269 |
269 void LocalDiscoveryUIHandler::StartRegisterHTTP( | 270 void LocalDiscoveryUIHandler::StartRegisterHTTP( |
270 scoped_ptr<PrivetHTTPClient> http_client) { | 271 scoped_ptr<PrivetHTTPClient> http_client) { |
271 current_http_client_ = PrivetV1HTTPClient::CreateDefault(http_client.Pass()); | 272 current_http_client_ = |
| 273 PrivetV1HTTPClient::CreateDefault(std::move(http_client)); |
272 | 274 |
273 std::string user = GetSyncAccount(); | 275 std::string user = GetSyncAccount(); |
274 | 276 |
275 if (!current_http_client_) { | 277 if (!current_http_client_) { |
276 SendRegisterError(); | 278 SendRegisterError(); |
277 return; | 279 return; |
278 } | 280 } |
279 | 281 |
280 current_register_operation_ = | 282 current_register_operation_ = |
281 current_http_client_->CreateRegisterOperation(user, this); | 283 current_http_client_->CreateRegisterOperation(user, this); |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
642 | 644 |
643 void LocalDiscoveryUIHandler::RefreshCloudPrintStatusFromService() { | 645 void LocalDiscoveryUIHandler::RefreshCloudPrintStatusFromService() { |
644 if (cloud_print_connector_ui_enabled_) | 646 if (cloud_print_connector_ui_enabled_) |
645 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> | 647 CloudPrintProxyServiceFactory::GetForProfile(Profile::FromWebUI(web_ui()))-> |
646 RefreshStatusFromService(); | 648 RefreshStatusFromService(); |
647 } | 649 } |
648 | 650 |
649 #endif // cloud print connector option stuff | 651 #endif // cloud print connector option stuff |
650 | 652 |
651 } // namespace local_discovery | 653 } // namespace local_discovery |
OLD | NEW |