| 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/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 555 } | 555 } |
| 556 | 556 |
| 557 void LocalDiscoveryUIHandler::PrivetClientToV3( | 557 void LocalDiscoveryUIHandler::PrivetClientToV3( |
| 558 const PrivetClientCallback& callback, | 558 const PrivetClientCallback& callback, |
| 559 scoped_ptr<PrivetHTTPClient> client) { | 559 scoped_ptr<PrivetHTTPClient> client) { |
| 560 callback.Run(client.Pass()); | 560 callback.Run(client.Pass()); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { | 563 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { |
| 564 base::FundamentalValue logged_in_value(!GetSyncAccount().empty()); | 564 base::FundamentalValue logged_in_value(!GetSyncAccount().empty()); |
| 565 web_ui()->CallJavascriptFunction("local_discovery.setUserLoggedIn", | 565 base::FundamentalValue is_supervised_value(IsUserSupervisedOrOffTheRecord()); |
| 566 logged_in_value); | 566 web_ui()->CallJavascriptFunction( |
| 567 "local_discovery.setUserLoggedIn", logged_in_value, is_supervised_value); |
| 567 } | 568 } |
| 568 | 569 |
| 569 void LocalDiscoveryUIHandler::CheckListingDone() { | 570 void LocalDiscoveryUIHandler::CheckListingDone() { |
| 570 int started = 0; | 571 int started = 0; |
| 571 if (cloud_print_printer_list_) | 572 if (cloud_print_printer_list_) |
| 572 ++started; | 573 ++started; |
| 573 if (cloud_device_list_) | 574 if (cloud_device_list_) |
| 574 ++started; | 575 ++started; |
| 575 | 576 |
| 576 if (started > failed_list_count_ + succeded_list_count_) | 577 if (started > failed_list_count_ + succeded_list_count_) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 627 callback); | 628 callback); |
| 628 privet_resolution_ = | 629 privet_resolution_ = |
| 629 privet_http_factory_->CreatePrivetHTTP(device, | 630 privet_http_factory_->CreatePrivetHTTP(device, |
| 630 found->second.address, | 631 found->second.address, |
| 631 new_callback).Pass(); | 632 new_callback).Pass(); |
| 632 if (!privet_resolution_) | 633 if (!privet_resolution_) |
| 633 return callback.Run(scoped_ptr<PrivetHTTPClient>()); | 634 return callback.Run(scoped_ptr<PrivetHTTPClient>()); |
| 634 privet_resolution_->Start(); | 635 privet_resolution_->Start(); |
| 635 } | 636 } |
| 636 | 637 |
| 638 bool LocalDiscoveryUIHandler::IsUserSupervisedOrOffTheRecord() { |
| 639 Profile* profile = Profile::FromWebUI(web_ui()); |
| 640 |
| 641 return profile->IsSupervised() || profile->IsOffTheRecord(); |
| 642 } |
| 643 |
| 637 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 644 #if defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
| 638 void LocalDiscoveryUIHandler::StartCloudPrintConnector() { | 645 void LocalDiscoveryUIHandler::StartCloudPrintConnector() { |
| 639 Profile* profile = Profile::FromWebUI(web_ui()); | 646 Profile* profile = Profile::FromWebUI(web_ui()); |
| 640 | 647 |
| 641 base::Closure cloud_print_callback = base::Bind( | 648 base::Closure cloud_print_callback = base::Bind( |
| 642 &LocalDiscoveryUIHandler::OnCloudPrintPrefsChanged, | 649 &LocalDiscoveryUIHandler::OnCloudPrintPrefsChanged, |
| 643 base::Unretained(this)); | 650 base::Unretained(this)); |
| 644 | 651 |
| 645 if (cloud_print_connector_email_.GetPrefName().empty()) { | 652 if (cloud_print_connector_email_.GetPrefName().empty()) { |
| 646 cloud_print_connector_email_.Init( | 653 cloud_print_connector_email_.Init( |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 781 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); | 788 scoped_ptr<base::Value> null_value(base::Value::CreateNullValue()); |
| 782 | 789 |
| 783 web_ui()->CallJavascriptFunction( | 790 web_ui()->CallJavascriptFunction( |
| 784 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); | 791 "local_discovery.onUnregisteredDeviceUpdate", service_key, *null_value); |
| 785 } | 792 } |
| 786 } | 793 } |
| 787 | 794 |
| 788 #endif // ENABLE_WIFI_BOOTSTRAPPING | 795 #endif // ENABLE_WIFI_BOOTSTRAPPING |
| 789 | 796 |
| 790 } // namespace local_discovery | 797 } // namespace local_discovery |
| OLD | NEW |