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 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
466 current_register_operation_->Cancel(); | 466 current_register_operation_->Cancel(); |
467 current_register_operation_.reset(); | 467 current_register_operation_.reset(); |
468 } | 468 } |
469 | 469 |
470 confirm_api_call_flow_.reset(); | 470 confirm_api_call_flow_.reset(); |
471 privet_resolution_.reset(); | 471 privet_resolution_.reset(); |
472 current_http_client_.reset(); | 472 current_http_client_.reset(); |
473 } | 473 } |
474 | 474 |
475 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { | 475 void LocalDiscoveryUIHandler::CheckUserLoggedIn() { |
476 base::FundamentalValue logged_in_value(!GetSyncAccount().empty()); | 476 base::Value logged_in_value(!GetSyncAccount().empty()); |
477 base::FundamentalValue is_supervised_value(IsUserSupervisedOrOffTheRecord()); | 477 base::Value is_supervised_value(IsUserSupervisedOrOffTheRecord()); |
478 web_ui()->CallJavascriptFunctionUnsafe("local_discovery.setUserLoggedIn", | 478 web_ui()->CallJavascriptFunctionUnsafe("local_discovery.setUserLoggedIn", |
479 logged_in_value, is_supervised_value); | 479 logged_in_value, is_supervised_value); |
480 } | 480 } |
481 | 481 |
482 void LocalDiscoveryUIHandler::CheckListingDone() { | 482 void LocalDiscoveryUIHandler::CheckListingDone() { |
483 int started = cloud_print_printer_list_ ? 1 : 0; | 483 int started = cloud_print_printer_list_ ? 1 : 0; |
484 if (started > failed_list_count_ + succeded_list_count_) | 484 if (started > failed_list_count_ + succeded_list_count_) |
485 return; | 485 return; |
486 | 486 |
487 if (succeded_list_count_ <= 0) { | 487 if (succeded_list_count_ <= 0) { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 const base::ListValue* args) { | 572 const base::ListValue* args) { |
573 content::RecordAction( | 573 content::RecordAction( |
574 base::UserMetricsAction("Options_DisableCloudPrintProxy")); | 574 base::UserMetricsAction("Options_DisableCloudPrintProxy")); |
575 GetCloudPrintProxyService()->DisableForUser(); | 575 GetCloudPrintProxyService()->DisableForUser(); |
576 } | 576 } |
577 | 577 |
578 void LocalDiscoveryUIHandler::SetupCloudPrintConnectorSection() { | 578 void LocalDiscoveryUIHandler::SetupCloudPrintConnectorSection() { |
579 bool cloud_print_connector_allowed = | 579 bool cloud_print_connector_allowed = |
580 !cloud_print_connector_enabled_.IsManaged() || | 580 !cloud_print_connector_enabled_.IsManaged() || |
581 cloud_print_connector_enabled_.GetValue(); | 581 cloud_print_connector_enabled_.GetValue(); |
582 base::FundamentalValue allowed(cloud_print_connector_allowed); | 582 base::Value allowed(cloud_print_connector_allowed); |
583 | 583 |
584 std::string email; | 584 std::string email; |
585 Profile* profile = Profile::FromWebUI(web_ui()); | 585 Profile* profile = Profile::FromWebUI(web_ui()); |
586 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && | 586 if (profile->GetPrefs()->HasPrefPath(prefs::kCloudPrintEmail) && |
587 cloud_print_connector_allowed) { | 587 cloud_print_connector_allowed) { |
588 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); | 588 email = profile->GetPrefs()->GetString(prefs::kCloudPrintEmail); |
589 } | 589 } |
590 base::FundamentalValue disabled(email.empty()); | 590 base::Value disabled(email.empty()); |
591 | 591 |
592 base::string16 label_str; | 592 base::string16 label_str; |
593 if (email.empty()) { | 593 if (email.empty()) { |
594 label_str = l10n_util::GetStringFUTF16( | 594 label_str = l10n_util::GetStringFUTF16( |
595 IDS_LOCAL_DISCOVERY_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, | 595 IDS_LOCAL_DISCOVERY_CLOUD_PRINT_CONNECTOR_DISABLED_LABEL, |
596 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); | 596 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT)); |
597 } else { | 597 } else { |
598 label_str = l10n_util::GetStringFUTF16( | 598 label_str = l10n_util::GetStringFUTF16( |
599 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, | 599 IDS_OPTIONS_CLOUD_PRINT_CONNECTOR_ENABLED_LABEL, |
600 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), | 600 l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT), |
(...skipping 12 matching lines...) Expand all Loading... |
613 service->RefreshStatusFromService(); | 613 service->RefreshStatusFromService(); |
614 } | 614 } |
615 | 615 |
616 CloudPrintProxyService* LocalDiscoveryUIHandler::GetCloudPrintProxyService() { | 616 CloudPrintProxyService* LocalDiscoveryUIHandler::GetCloudPrintProxyService() { |
617 return CloudPrintProxyServiceFactory::GetForProfile( | 617 return CloudPrintProxyServiceFactory::GetForProfile( |
618 Profile::FromWebUI(web_ui())); | 618 Profile::FromWebUI(web_ui())); |
619 } | 619 } |
620 #endif // defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) | 620 #endif // defined(CLOUD_PRINT_CONNECTOR_UI_AVAILABLE) |
621 | 621 |
622 } // namespace local_discovery | 622 } // namespace local_discovery |
OLD | NEW |