OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/settings/about_handler.h" | 5 #include "chrome/browser/ui/webui/settings/about_handler.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 VersionUpdater::PromoteCallback()); | 478 VersionUpdater::PromoteCallback()); |
479 } | 479 } |
480 } | 480 } |
481 | 481 |
482 void AboutHandler::HandleGetVersionInfo(const base::ListValue* args) { | 482 void AboutHandler::HandleGetVersionInfo(const base::ListValue* args) { |
483 CHECK_EQ(1U, args->GetSize()); | 483 CHECK_EQ(1U, args->GetSize()); |
484 std::string callback_id; | 484 std::string callback_id; |
485 CHECK(args->GetString(0, &callback_id)); | 485 CHECK(args->GetString(0, &callback_id)); |
486 | 486 |
487 base::PostTaskWithTraitsAndReplyWithResult( | 487 base::PostTaskWithTraitsAndReplyWithResult( |
488 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 488 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
489 base::TaskPriority::USER_VISIBLE), | |
490 base::Bind(&GetVersionInfo), | 489 base::Bind(&GetVersionInfo), |
491 base::Bind(&AboutHandler::OnGetVersionInfoReady, | 490 base::Bind(&AboutHandler::OnGetVersionInfoReady, |
492 weak_factory_.GetWeakPtr(), callback_id)); | 491 weak_factory_.GetWeakPtr(), callback_id)); |
493 } | 492 } |
494 | 493 |
495 void AboutHandler::OnGetVersionInfoReady( | 494 void AboutHandler::OnGetVersionInfoReady( |
496 std::string callback_id, | 495 std::string callback_id, |
497 std::unique_ptr<base::DictionaryValue> version_info) { | 496 std::unique_ptr<base::DictionaryValue> version_info) { |
498 ResolveJavascriptCallback(base::Value(callback_id), *version_info); | 497 ResolveJavascriptCallback(base::Value(callback_id), *version_info); |
499 } | 498 } |
500 | 499 |
501 void AboutHandler::HandleGetRegulatoryInfo(const base::ListValue* args) { | 500 void AboutHandler::HandleGetRegulatoryInfo(const base::ListValue* args) { |
502 CHECK_EQ(1U, args->GetSize()); | 501 CHECK_EQ(1U, args->GetSize()); |
503 std::string callback_id; | 502 std::string callback_id; |
504 CHECK(args->GetString(0, &callback_id)); | 503 CHECK(args->GetString(0, &callback_id)); |
505 | 504 |
506 base::PostTaskWithTraitsAndReplyWithResult( | 505 base::PostTaskWithTraitsAndReplyWithResult( |
507 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 506 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
508 base::TaskPriority::USER_VISIBLE), | |
509 base::Bind(&FindRegulatoryLabelDir), | 507 base::Bind(&FindRegulatoryLabelDir), |
510 base::Bind(&AboutHandler::OnRegulatoryLabelDirFound, | 508 base::Bind(&AboutHandler::OnRegulatoryLabelDirFound, |
511 weak_factory_.GetWeakPtr(), callback_id)); | 509 weak_factory_.GetWeakPtr(), callback_id)); |
512 } | 510 } |
513 | 511 |
514 void AboutHandler::HandleGetChannelInfo(const base::ListValue* args) { | 512 void AboutHandler::HandleGetChannelInfo(const base::ListValue* args) { |
515 CHECK_EQ(1U, args->GetSize()); | 513 CHECK_EQ(1U, args->GetSize()); |
516 std::string callback_id; | 514 std::string callback_id; |
517 CHECK(args->GetString(0, &callback_id)); | 515 CHECK(args->GetString(0, &callback_id)); |
518 version_updater_->GetChannel( | 516 version_updater_->GetChannel( |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 #if defined(OS_CHROMEOS) | 616 #if defined(OS_CHROMEOS) |
619 void AboutHandler::OnRegulatoryLabelDirFound( | 617 void AboutHandler::OnRegulatoryLabelDirFound( |
620 std::string callback_id, | 618 std::string callback_id, |
621 const base::FilePath& label_dir_path) { | 619 const base::FilePath& label_dir_path) { |
622 if (label_dir_path.empty()) { | 620 if (label_dir_path.empty()) { |
623 ResolveJavascriptCallback(base::Value(callback_id), base::Value()); | 621 ResolveJavascriptCallback(base::Value(callback_id), base::Value()); |
624 return; | 622 return; |
625 } | 623 } |
626 | 624 |
627 base::PostTaskWithTraitsAndReplyWithResult( | 625 base::PostTaskWithTraitsAndReplyWithResult( |
628 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 626 FROM_HERE, {base::MayBlock(), base::TaskPriority::USER_VISIBLE}, |
629 base::TaskPriority::USER_VISIBLE), | |
630 base::Bind(&ReadRegulatoryLabelText, label_dir_path), | 627 base::Bind(&ReadRegulatoryLabelText, label_dir_path), |
631 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, | 628 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, |
632 weak_factory_.GetWeakPtr(), callback_id, label_dir_path)); | 629 weak_factory_.GetWeakPtr(), callback_id, label_dir_path)); |
633 } | 630 } |
634 | 631 |
635 void AboutHandler::OnRegulatoryLabelTextRead( | 632 void AboutHandler::OnRegulatoryLabelTextRead( |
636 std::string callback_id, | 633 std::string callback_id, |
637 const base::FilePath& label_dir_path, | 634 const base::FilePath& label_dir_path, |
638 const std::string& text) { | 635 const std::string& text) { |
639 std::unique_ptr<base::DictionaryValue> regulatory_info( | 636 std::unique_ptr<base::DictionaryValue> regulatory_info( |
640 new base::DictionaryValue); | 637 new base::DictionaryValue); |
641 // Remove unnecessary whitespace. | 638 // Remove unnecessary whitespace. |
642 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true)); | 639 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true)); |
643 | 640 |
644 std::string image_path = | 641 std::string image_path = |
645 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); | 642 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); |
646 std::string url = | 643 std::string url = |
647 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; | 644 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; |
648 regulatory_info->SetString("url", url); | 645 regulatory_info->SetString("url", url); |
649 | 646 |
650 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info); | 647 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info); |
651 } | 648 } |
652 #endif // defined(OS_CHROMEOS) | 649 #endif // defined(OS_CHROMEOS) |
653 | 650 |
654 } // namespace settings | 651 } // namespace settings |
OLD | NEW |