OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/help/help_handler.h" | 5 #include "chrome/browser/ui/webui/help/help_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
476 base::Bind(&chromeos::version_loader::GetFirmware), | 476 base::Bind(&chromeos::version_loader::GetFirmware), |
477 base::Bind(&HelpHandler::OnOSFirmware, weak_factory_.GetWeakPtr())); | 477 base::Bind(&HelpHandler::OnOSFirmware, weak_factory_.GetWeakPtr())); |
478 | 478 |
479 web_ui()->CallJavascriptFunctionUnsafe( | 479 web_ui()->CallJavascriptFunctionUnsafe( |
480 "help.HelpPage.updateEnableReleaseChannel", | 480 "help.HelpPage.updateEnableReleaseChannel", |
481 base::Value(CanChangeChannel(Profile::FromWebUI(web_ui())))); | 481 base::Value(CanChangeChannel(Profile::FromWebUI(web_ui())))); |
482 | 482 |
483 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); | 483 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
484 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); | 484 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); |
485 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setBuildDate", | 485 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setBuildDate", |
486 base::StringValue(build_date)); | 486 base::Value(build_date)); |
487 #endif // defined(OS_CHROMEOS) | 487 #endif // defined(OS_CHROMEOS) |
488 | 488 |
489 RefreshUpdateStatus(); | 489 RefreshUpdateStatus(); |
490 | 490 |
491 web_ui()->CallJavascriptFunctionUnsafe( | 491 web_ui()->CallJavascriptFunctionUnsafe( |
492 "help.HelpPage.setObsoleteSystem", | 492 "help.HelpPage.setObsoleteSystem", |
493 base::Value(ObsoleteSystem::IsObsoleteNowOrSoon())); | 493 base::Value(ObsoleteSystem::IsObsoleteNowOrSoon())); |
494 web_ui()->CallJavascriptFunctionUnsafe( | 494 web_ui()->CallJavascriptFunctionUnsafe( |
495 "help.HelpPage.setObsoleteSystemEndOfTheLine", | 495 "help.HelpPage.setObsoleteSystemEndOfTheLine", |
496 base::Value(ObsoleteSystem::IsObsoleteNowOrSoon() && | 496 base::Value(ObsoleteSystem::IsObsoleteNowOrSoon() && |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 break; | 630 break; |
631 case VersionUpdater::DISABLED: | 631 case VersionUpdater::DISABLED: |
632 status_str = "disabled"; | 632 status_str = "disabled"; |
633 break; | 633 break; |
634 case VersionUpdater::DISABLED_BY_ADMIN: | 634 case VersionUpdater::DISABLED_BY_ADMIN: |
635 status_str = "disabled_by_admin"; | 635 status_str = "disabled_by_admin"; |
636 break; | 636 break; |
637 } | 637 } |
638 | 638 |
639 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setUpdateStatus", | 639 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setUpdateStatus", |
640 base::StringValue(status_str), | 640 base::Value(status_str), |
641 base::StringValue(message)); | 641 base::Value(message)); |
642 | 642 |
643 if (status == VersionUpdater::UPDATING) { | 643 if (status == VersionUpdater::UPDATING) { |
644 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setProgress", | 644 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setProgress", |
645 base::Value(progress)); | 645 base::Value(progress)); |
646 } | 646 } |
647 | 647 |
648 #if defined(OS_CHROMEOS) | 648 #if defined(OS_CHROMEOS) |
649 if (status == VersionUpdater::FAILED_OFFLINE || | 649 if (status == VersionUpdater::FAILED_OFFLINE || |
650 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { | 650 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { |
651 base::string16 types_msg = GetAllowedConnectionTypesMessage(); | 651 base::string16 types_msg = GetAllowedConnectionTypesMessage(); |
652 if (!types_msg.empty()) { | 652 if (!types_msg.empty()) { |
653 web_ui()->CallJavascriptFunctionUnsafe( | 653 web_ui()->CallJavascriptFunctionUnsafe( |
654 "help.HelpPage.setAndShowAllowedConnectionTypesMsg", | 654 "help.HelpPage.setAndShowAllowedConnectionTypesMsg", |
655 base::StringValue(types_msg)); | 655 base::Value(types_msg)); |
656 } else { | 656 } else { |
657 web_ui()->CallJavascriptFunctionUnsafe( | 657 web_ui()->CallJavascriptFunctionUnsafe( |
658 "help.HelpPage.showAllowedConnectionTypesMsg", base::Value(false)); | 658 "help.HelpPage.showAllowedConnectionTypesMsg", base::Value(false)); |
659 } | 659 } |
660 } else { | 660 } else { |
661 web_ui()->CallJavascriptFunctionUnsafe( | 661 web_ui()->CallJavascriptFunctionUnsafe( |
662 "help.HelpPage.showAllowedConnectionTypesMsg", base::Value(false)); | 662 "help.HelpPage.showAllowedConnectionTypesMsg", base::Value(false)); |
663 } | 663 } |
664 #endif // defined(OS_CHROMEOS) | 664 #endif // defined(OS_CHROMEOS) |
665 } | 665 } |
666 | 666 |
667 #if defined(OS_MACOSX) | 667 #if defined(OS_MACOSX) |
668 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state) { | 668 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state) { |
669 std::string state_str; | 669 std::string state_str; |
670 switch (state) { | 670 switch (state) { |
671 case VersionUpdater::PROMOTE_HIDDEN: | 671 case VersionUpdater::PROMOTE_HIDDEN: |
672 case VersionUpdater::PROMOTED: | 672 case VersionUpdater::PROMOTED: |
673 state_str = "hidden"; | 673 state_str = "hidden"; |
674 break; | 674 break; |
675 case VersionUpdater::PROMOTE_ENABLED: | 675 case VersionUpdater::PROMOTE_ENABLED: |
676 state_str = "enabled"; | 676 state_str = "enabled"; |
677 break; | 677 break; |
678 case VersionUpdater::PROMOTE_DISABLED: | 678 case VersionUpdater::PROMOTE_DISABLED: |
679 state_str = "disabled"; | 679 state_str = "disabled"; |
680 break; | 680 break; |
681 } | 681 } |
682 | 682 |
683 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setPromotionState", | 683 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setPromotionState", |
684 base::StringValue(state_str)); | 684 base::Value(state_str)); |
685 } | 685 } |
686 #endif // defined(OS_MACOSX) | 686 #endif // defined(OS_MACOSX) |
687 | 687 |
688 #if defined(OS_CHROMEOS) | 688 #if defined(OS_CHROMEOS) |
689 void HelpHandler::OnOSVersion(const std::string& version) { | 689 void HelpHandler::OnOSVersion(const std::string& version) { |
690 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSVersion", | 690 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSVersion", |
691 base::StringValue(version)); | 691 base::Value(version)); |
692 } | 692 } |
693 | 693 |
694 void HelpHandler::OnARCVersion(const std::string& firmware) { | 694 void HelpHandler::OnARCVersion(const std::string& firmware) { |
695 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setARCVersion", | 695 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setARCVersion", |
696 base::StringValue(firmware)); | 696 base::Value(firmware)); |
697 } | 697 } |
698 | 698 |
699 void HelpHandler::OnOSFirmware(const std::string& firmware) { | 699 void HelpHandler::OnOSFirmware(const std::string& firmware) { |
700 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSFirmware", | 700 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSFirmware", |
701 base::StringValue(firmware)); | 701 base::Value(firmware)); |
702 } | 702 } |
703 | 703 |
704 void HelpHandler::OnCurrentChannel(const std::string& channel) { | 704 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
705 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateCurrentChannel", | 705 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateCurrentChannel", |
706 base::StringValue(channel)); | 706 base::Value(channel)); |
707 } | 707 } |
708 | 708 |
709 void HelpHandler::OnTargetChannel(const std::string& channel) { | 709 void HelpHandler::OnTargetChannel(const std::string& channel) { |
710 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateTargetChannel", | 710 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateTargetChannel", |
711 base::StringValue(channel)); | 711 base::Value(channel)); |
712 } | 712 } |
713 | 713 |
714 void HelpHandler::OnRegulatoryLabelDirFound(const base::FilePath& path) { | 714 void HelpHandler::OnRegulatoryLabelDirFound(const base::FilePath& path) { |
715 if (path.empty()) | 715 if (path.empty()) |
716 return; | 716 return; |
717 | 717 |
718 base::PostTaskWithTraitsAndReplyWithResult( | 718 base::PostTaskWithTraitsAndReplyWithResult( |
719 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 719 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
720 base::TaskPriority::BACKGROUND), | 720 base::TaskPriority::BACKGROUND), |
721 base::Bind(&ReadRegulatoryLabelText, path), | 721 base::Bind(&ReadRegulatoryLabelText, path), |
722 base::Bind(&HelpHandler::OnRegulatoryLabelTextRead, | 722 base::Bind(&HelpHandler::OnRegulatoryLabelTextRead, |
723 weak_factory_.GetWeakPtr())); | 723 weak_factory_.GetWeakPtr())); |
724 | 724 |
725 // Send the image path to the WebUI. | 725 // Send the image path to the WebUI. |
726 OnRegulatoryLabelImageFound(path.AppendASCII(kRegulatoryLabelImageFilename)); | 726 OnRegulatoryLabelImageFound(path.AppendASCII(kRegulatoryLabelImageFilename)); |
727 } | 727 } |
728 | 728 |
729 void HelpHandler::OnRegulatoryLabelImageFound(const base::FilePath& path) { | 729 void HelpHandler::OnRegulatoryLabelImageFound(const base::FilePath& path) { |
730 std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost + | 730 std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost + |
731 "/" + path.MaybeAsASCII(); | 731 "/" + path.MaybeAsASCII(); |
732 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setRegulatoryLabelPath", | 732 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setRegulatoryLabelPath", |
733 base::StringValue(url)); | 733 base::Value(url)); |
734 } | 734 } |
735 | 735 |
736 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { | 736 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { |
737 // Remove unnecessary whitespace. | 737 // Remove unnecessary whitespace. |
738 web_ui()->CallJavascriptFunctionUnsafe( | 738 web_ui()->CallJavascriptFunctionUnsafe( |
739 "help.HelpPage.setRegulatoryLabelText", | 739 "help.HelpPage.setRegulatoryLabelText", |
740 base::StringValue(base::CollapseWhitespaceASCII(text, true))); | 740 base::Value(base::CollapseWhitespaceASCII(text, true))); |
741 } | 741 } |
742 | 742 |
743 void HelpHandler::OnEolStatus(update_engine::EndOfLifeStatus status) { | 743 void HelpHandler::OnEolStatus(update_engine::EndOfLifeStatus status) { |
744 // Security only state is no longer supported. | 744 // Security only state is no longer supported. |
745 if (status == update_engine::EndOfLifeStatus::kSecurityOnly || | 745 if (status == update_engine::EndOfLifeStatus::kSecurityOnly || |
746 IsEnterpriseManaged()) { | 746 IsEnterpriseManaged()) { |
747 return; | 747 return; |
748 } | 748 } |
749 | 749 |
750 if (status == update_engine::EndOfLifeStatus::kSupported) { | 750 if (status == update_engine::EndOfLifeStatus::kSupported) { |
751 web_ui()->CallJavascriptFunctionUnsafe( | 751 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateEolMessage", |
752 "help.HelpPage.updateEolMessage", base::StringValue("device_supported"), | 752 base::Value("device_supported"), |
753 base::StringValue("")); | 753 base::Value("")); |
754 } else { | 754 } else { |
755 web_ui()->CallJavascriptFunctionUnsafe( | 755 web_ui()->CallJavascriptFunctionUnsafe( |
756 "help.HelpPage.updateEolMessage", base::StringValue("device_endoflife"), | 756 "help.HelpPage.updateEolMessage", base::Value("device_endoflife"), |
757 base::StringValue(l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_EOL))); | 757 base::Value(l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_EOL))); |
758 } | 758 } |
759 } | 759 } |
760 | 760 |
761 #endif // defined(OS_CHROMEOS) | 761 #endif // defined(OS_CHROMEOS) |
OLD | NEW |