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 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 24 matching lines...) Expand all Loading... |
35 | 35 |
36 LocalDiscoveryUIHandler::Factory* g_factory = NULL; | 36 LocalDiscoveryUIHandler::Factory* g_factory = NULL; |
37 int g_num_visible = 0; | 37 int g_num_visible = 0; |
38 | 38 |
39 } // namespace | 39 } // namespace |
40 | 40 |
41 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() : is_visible_(false) { | 41 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler() : is_visible_(false) { |
42 } | 42 } |
43 | 43 |
44 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler( | 44 LocalDiscoveryUIHandler::LocalDiscoveryUIHandler( |
45 scoped_ptr<PrivetDeviceLister> privet_lister) { | 45 scoped_ptr<PrivetDeviceLister> privet_lister) : is_visible_(false) { |
46 privet_lister.swap(privet_lister_); | 46 privet_lister.swap(privet_lister_); |
47 } | 47 } |
48 | 48 |
49 LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { | 49 LocalDiscoveryUIHandler::~LocalDiscoveryUIHandler() { |
50 ResetCurrentRegistration(); | 50 ResetCurrentRegistration(); |
51 SetIsVisible(false); | 51 SetIsVisible(false); |
52 if (service_discovery_client_.get()) { | 52 if (service_discovery_client_.get()) { |
53 service_discovery_client_ = NULL; | 53 service_discovery_client_ = NULL; |
54 ServiceDiscoveryHostClientFactory::ReleaseClient(); | 54 ServiceDiscoveryHostClientFactory::ReleaseClient(); |
55 } | 55 } |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 | 305 |
306 void LocalDiscoveryUIHandler::DeviceRemoved(const std::string& name) { | 306 void LocalDiscoveryUIHandler::DeviceRemoved(const std::string& name) { |
307 device_descriptions_.erase(name); | 307 device_descriptions_.erase(name); |
308 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 308 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
309 base::StringValue name_value(name); | 309 base::StringValue name_value(name); |
310 | 310 |
311 web_ui()->CallJavascriptFunction("local_discovery.onUnregisteredDeviceUpdate", | 311 web_ui()->CallJavascriptFunction("local_discovery.onUnregisteredDeviceUpdate", |
312 name_value, *null_value); | 312 name_value, *null_value); |
313 } | 313 } |
314 | 314 |
| 315 void LocalDiscoveryUIHandler::DeviceCacheFlushed() { |
| 316 web_ui()->CallJavascriptFunction("local_discovery.onDeviceCacheFlushed"); |
| 317 privet_lister_->DiscoverNewDevices(false); |
| 318 } |
| 319 |
315 void LocalDiscoveryUIHandler::OnCloudPrintPrinterListReady() { | 320 void LocalDiscoveryUIHandler::OnCloudPrintPrinterListReady() { |
316 base::ListValue printer_object_list; | 321 base::ListValue printer_object_list; |
317 std::set<std::string> local_ids; | 322 std::set<std::string> local_ids; |
318 | 323 |
319 for (DeviceDescriptionMap::iterator i = device_descriptions_.begin(); | 324 for (DeviceDescriptionMap::iterator i = device_descriptions_.begin(); |
320 i != device_descriptions_.end(); | 325 i != device_descriptions_.end(); |
321 i++) { | 326 i++) { |
322 std::string device_id = i->second.id; | 327 std::string device_id = i->second.id; |
323 if (!device_id.empty()) { | 328 if (!device_id.empty()) { |
324 const CloudPrintPrinterList::PrinterDetails* details = | 329 const CloudPrintPrinterList::PrinterDetails* details = |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); | 401 scoped_ptr<base::DictionaryValue> return_value(new base::DictionaryValue); |
397 | 402 |
398 return_value->SetString("id", description.id); | 403 return_value->SetString("id", description.id); |
399 return_value->SetString("display_name", description.display_name); | 404 return_value->SetString("display_name", description.display_name); |
400 return_value->SetString("description", description.description); | 405 return_value->SetString("description", description.description); |
401 | 406 |
402 return return_value.Pass(); | 407 return return_value.Pass(); |
403 } | 408 } |
404 | 409 |
405 } // namespace local_discovery | 410 } // namespace local_discovery |
OLD | NEW |