| 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 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 480 base::Bind(&chromeos::version_loader::GetARCVersion), | 480 base::Bind(&chromeos::version_loader::GetARCVersion), |
| 481 base::Bind(&HelpHandler::OnARCVersion, | 481 base::Bind(&HelpHandler::OnARCVersion, |
| 482 weak_factory_.GetWeakPtr())); | 482 weak_factory_.GetWeakPtr())); |
| 483 base::PostTaskAndReplyWithResult( | 483 base::PostTaskAndReplyWithResult( |
| 484 content::BrowserThread::GetBlockingPool(), | 484 content::BrowserThread::GetBlockingPool(), |
| 485 FROM_HERE, | 485 FROM_HERE, |
| 486 base::Bind(&chromeos::version_loader::GetFirmware), | 486 base::Bind(&chromeos::version_loader::GetFirmware), |
| 487 base::Bind(&HelpHandler::OnOSFirmware, | 487 base::Bind(&HelpHandler::OnOSFirmware, |
| 488 weak_factory_.GetWeakPtr())); | 488 weak_factory_.GetWeakPtr())); |
| 489 | 489 |
| 490 web_ui()->CallJavascriptFunction( | 490 web_ui()->CallJavascriptFunctionUnsafe( |
| 491 "help.HelpPage.updateEnableReleaseChannel", | 491 "help.HelpPage.updateEnableReleaseChannel", |
| 492 base::FundamentalValue(CanChangeChannel(Profile::FromWebUI(web_ui())))); | 492 base::FundamentalValue(CanChangeChannel(Profile::FromWebUI(web_ui())))); |
| 493 | 493 |
| 494 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); | 494 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
| 495 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); | 495 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); |
| 496 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | 496 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setBuildDate", |
| 497 base::StringValue(build_date)); | 497 base::StringValue(build_date)); |
| 498 #endif // defined(OS_CHROMEOS) | 498 #endif // defined(OS_CHROMEOS) |
| 499 | 499 |
| 500 RefreshUpdateStatus(); | 500 RefreshUpdateStatus(); |
| 501 | 501 |
| 502 web_ui()->CallJavascriptFunction( | 502 web_ui()->CallJavascriptFunctionUnsafe( |
| 503 "help.HelpPage.setObsoleteSystem", | 503 "help.HelpPage.setObsoleteSystem", |
| 504 base::FundamentalValue(ObsoleteSystem::IsObsoleteNowOrSoon())); | 504 base::FundamentalValue(ObsoleteSystem::IsObsoleteNowOrSoon())); |
| 505 web_ui()->CallJavascriptFunction( | 505 web_ui()->CallJavascriptFunctionUnsafe( |
| 506 "help.HelpPage.setObsoleteSystemEndOfTheLine", | 506 "help.HelpPage.setObsoleteSystemEndOfTheLine", |
| 507 base::FundamentalValue(ObsoleteSystem::IsObsoleteNowOrSoon() && | 507 base::FundamentalValue(ObsoleteSystem::IsObsoleteNowOrSoon() && |
| 508 ObsoleteSystem::IsEndOfTheLine())); | 508 ObsoleteSystem::IsEndOfTheLine())); |
| 509 | 509 |
| 510 #if defined(OS_CHROMEOS) | 510 #if defined(OS_CHROMEOS) |
| 511 web_ui()->CallJavascriptFunction( | 511 web_ui()->CallJavascriptFunctionUnsafe( |
| 512 "help.HelpPage.updateIsEnterpriseManaged", | 512 "help.HelpPage.updateIsEnterpriseManaged", |
| 513 base::FundamentalValue(IsEnterpriseManaged())); | 513 base::FundamentalValue(IsEnterpriseManaged())); |
| 514 // First argument to GetChannel() is a flag that indicates whether | 514 // First argument to GetChannel() is a flag that indicates whether |
| 515 // current channel should be returned (if true) or target channel | 515 // current channel should be returned (if true) or target channel |
| 516 // (otherwise). | 516 // (otherwise). |
| 517 version_updater_->GetChannel(true, | 517 version_updater_->GetChannel(true, |
| 518 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | 518 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); |
| 519 version_updater_->GetChannel(false, | 519 version_updater_->GetChannel(false, |
| 520 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | 520 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); |
| 521 | 521 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 634 status_str = "failed"; | 634 status_str = "failed"; |
| 635 break; | 635 break; |
| 636 case VersionUpdater::DISABLED: | 636 case VersionUpdater::DISABLED: |
| 637 status_str = "disabled"; | 637 status_str = "disabled"; |
| 638 break; | 638 break; |
| 639 case VersionUpdater::DISABLED_BY_ADMIN: | 639 case VersionUpdater::DISABLED_BY_ADMIN: |
| 640 status_str = "disabled_by_admin"; | 640 status_str = "disabled_by_admin"; |
| 641 break; | 641 break; |
| 642 } | 642 } |
| 643 | 643 |
| 644 web_ui()->CallJavascriptFunction("help.HelpPage.setUpdateStatus", | 644 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setUpdateStatus", |
| 645 base::StringValue(status_str), | 645 base::StringValue(status_str), |
| 646 base::StringValue(message)); | 646 base::StringValue(message)); |
| 647 | 647 |
| 648 if (status == VersionUpdater::UPDATING) { | 648 if (status == VersionUpdater::UPDATING) { |
| 649 web_ui()->CallJavascriptFunction("help.HelpPage.setProgress", | 649 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setProgress", |
| 650 base::FundamentalValue(progress)); | 650 base::FundamentalValue(progress)); |
| 651 } | 651 } |
| 652 | 652 |
| 653 #if defined(OS_CHROMEOS) | 653 #if defined(OS_CHROMEOS) |
| 654 if (status == VersionUpdater::FAILED_OFFLINE || | 654 if (status == VersionUpdater::FAILED_OFFLINE || |
| 655 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { | 655 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { |
| 656 base::string16 types_msg = GetAllowedConnectionTypesMessage(); | 656 base::string16 types_msg = GetAllowedConnectionTypesMessage(); |
| 657 if (!types_msg.empty()) { | 657 if (!types_msg.empty()) { |
| 658 web_ui()->CallJavascriptFunction( | 658 web_ui()->CallJavascriptFunctionUnsafe( |
| 659 "help.HelpPage.setAndShowAllowedConnectionTypesMsg", | 659 "help.HelpPage.setAndShowAllowedConnectionTypesMsg", |
| 660 base::StringValue(types_msg)); | 660 base::StringValue(types_msg)); |
| 661 } else { | 661 } else { |
| 662 web_ui()->CallJavascriptFunction( | 662 web_ui()->CallJavascriptFunctionUnsafe( |
| 663 "help.HelpPage.showAllowedConnectionTypesMsg", | 663 "help.HelpPage.showAllowedConnectionTypesMsg", |
| 664 base::FundamentalValue(false)); | 664 base::FundamentalValue(false)); |
| 665 } | 665 } |
| 666 } else { | 666 } else { |
| 667 web_ui()->CallJavascriptFunction( | 667 web_ui()->CallJavascriptFunctionUnsafe( |
| 668 "help.HelpPage.showAllowedConnectionTypesMsg", | 668 "help.HelpPage.showAllowedConnectionTypesMsg", |
| 669 base::FundamentalValue(false)); | 669 base::FundamentalValue(false)); |
| 670 } | 670 } |
| 671 #endif // defined(OS_CHROMEOS) | 671 #endif // defined(OS_CHROMEOS) |
| 672 } | 672 } |
| 673 | 673 |
| 674 #if defined(OS_MACOSX) | 674 #if defined(OS_MACOSX) |
| 675 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state) { | 675 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state) { |
| 676 std::string state_str; | 676 std::string state_str; |
| 677 switch (state) { | 677 switch (state) { |
| 678 case VersionUpdater::PROMOTE_HIDDEN: | 678 case VersionUpdater::PROMOTE_HIDDEN: |
| 679 state_str = "hidden"; | 679 state_str = "hidden"; |
| 680 break; | 680 break; |
| 681 case VersionUpdater::PROMOTE_ENABLED: | 681 case VersionUpdater::PROMOTE_ENABLED: |
| 682 state_str = "enabled"; | 682 state_str = "enabled"; |
| 683 break; | 683 break; |
| 684 case VersionUpdater::PROMOTE_DISABLED: | 684 case VersionUpdater::PROMOTE_DISABLED: |
| 685 state_str = "disabled"; | 685 state_str = "disabled"; |
| 686 break; | 686 break; |
| 687 } | 687 } |
| 688 | 688 |
| 689 web_ui()->CallJavascriptFunction("help.HelpPage.setPromotionState", | 689 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setPromotionState", |
| 690 base::StringValue(state_str)); | 690 base::StringValue(state_str)); |
| 691 } | 691 } |
| 692 #endif // defined(OS_MACOSX) | 692 #endif // defined(OS_MACOSX) |
| 693 | 693 |
| 694 #if defined(OS_CHROMEOS) | 694 #if defined(OS_CHROMEOS) |
| 695 void HelpHandler::OnOSVersion(const std::string& version) { | 695 void HelpHandler::OnOSVersion(const std::string& version) { |
| 696 web_ui()->CallJavascriptFunction("help.HelpPage.setOSVersion", | 696 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSVersion", |
| 697 base::StringValue(version)); | 697 base::StringValue(version)); |
| 698 } | 698 } |
| 699 | 699 |
| 700 void HelpHandler::OnARCVersion(const std::string& firmware) { | 700 void HelpHandler::OnARCVersion(const std::string& firmware) { |
| 701 web_ui()->CallJavascriptFunction("help.HelpPage.setARCVersion", | 701 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setARCVersion", |
| 702 base::StringValue(firmware)); | 702 base::StringValue(firmware)); |
| 703 } | 703 } |
| 704 | 704 |
| 705 void HelpHandler::OnOSFirmware(const std::string& firmware) { | 705 void HelpHandler::OnOSFirmware(const std::string& firmware) { |
| 706 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware", | 706 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setOSFirmware", |
| 707 base::StringValue(firmware)); | 707 base::StringValue(firmware)); |
| 708 } | 708 } |
| 709 | 709 |
| 710 void HelpHandler::OnCurrentChannel(const std::string& channel) { | 710 void HelpHandler::OnCurrentChannel(const std::string& channel) { |
| 711 web_ui()->CallJavascriptFunction( | 711 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateCurrentChannel", |
| 712 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 712 base::StringValue(channel)); |
| 713 } | 713 } |
| 714 | 714 |
| 715 void HelpHandler::OnTargetChannel(const std::string& channel) { | 715 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 716 web_ui()->CallJavascriptFunction( | 716 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.updateTargetChannel", |
| 717 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 717 base::StringValue(channel)); |
| 718 } | 718 } |
| 719 | 719 |
| 720 void HelpHandler::OnRegulatoryLabelDirFound(const base::FilePath& path) { | 720 void HelpHandler::OnRegulatoryLabelDirFound(const base::FilePath& path) { |
| 721 if (path.empty()) | 721 if (path.empty()) |
| 722 return; | 722 return; |
| 723 | 723 |
| 724 base::PostTaskAndReplyWithResult( | 724 base::PostTaskAndReplyWithResult( |
| 725 content::BrowserThread::GetBlockingPool(), FROM_HERE, | 725 content::BrowserThread::GetBlockingPool(), FROM_HERE, |
| 726 base::Bind(&ReadRegulatoryLabelText, path), | 726 base::Bind(&ReadRegulatoryLabelText, path), |
| 727 base::Bind(&HelpHandler::OnRegulatoryLabelTextRead, | 727 base::Bind(&HelpHandler::OnRegulatoryLabelTextRead, |
| 728 weak_factory_.GetWeakPtr())); | 728 weak_factory_.GetWeakPtr())); |
| 729 | 729 |
| 730 // Send the image path to the WebUI. | 730 // Send the image path to the WebUI. |
| 731 OnRegulatoryLabelImageFound(path.AppendASCII(kRegulatoryLabelImageFilename)); | 731 OnRegulatoryLabelImageFound(path.AppendASCII(kRegulatoryLabelImageFilename)); |
| 732 } | 732 } |
| 733 | 733 |
| 734 void HelpHandler::OnRegulatoryLabelImageFound(const base::FilePath& path) { | 734 void HelpHandler::OnRegulatoryLabelImageFound(const base::FilePath& path) { |
| 735 std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost + | 735 std::string url = std::string("chrome://") + chrome::kChromeOSAssetHost + |
| 736 "/" + path.MaybeAsASCII(); | 736 "/" + path.MaybeAsASCII(); |
| 737 web_ui()->CallJavascriptFunction("help.HelpPage.setRegulatoryLabelPath", | 737 web_ui()->CallJavascriptFunctionUnsafe("help.HelpPage.setRegulatoryLabelPath", |
| 738 base::StringValue(url)); | 738 base::StringValue(url)); |
| 739 } | 739 } |
| 740 | 740 |
| 741 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { | 741 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { |
| 742 // Remove unnecessary whitespace. | 742 // Remove unnecessary whitespace. |
| 743 web_ui()->CallJavascriptFunction( | 743 web_ui()->CallJavascriptFunctionUnsafe( |
| 744 "help.HelpPage.setRegulatoryLabelText", | 744 "help.HelpPage.setRegulatoryLabelText", |
| 745 base::StringValue(base::CollapseWhitespaceASCII(text, true))); | 745 base::StringValue(base::CollapseWhitespaceASCII(text, true))); |
| 746 } | 746 } |
| 747 | 747 |
| 748 #endif // defined(OS_CHROMEOS) | 748 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |