Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: chrome/browser/ui/webui/help/help_handler.cc

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

Powered by Google App Engine
This is Rietveld 408576698