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

Side by Side Diff: chrome/browser/ui/webui/settings/about_handler.cc

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 years, 9 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 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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( 489 FROM_HERE, base::TaskTraits().MayBlock().WithPriority(
490 base::TaskPriority::USER_VISIBLE), 490 base::TaskPriority::USER_VISIBLE),
491 base::Bind(&GetVersionInfo), 491 base::Bind(&GetVersionInfo),
492 base::Bind(&AboutHandler::OnGetVersionInfoReady, 492 base::Bind(&AboutHandler::OnGetVersionInfoReady,
493 weak_factory_.GetWeakPtr(), callback_id)); 493 weak_factory_.GetWeakPtr(), callback_id));
494 } 494 }
495 495
496 void AboutHandler::OnGetVersionInfoReady( 496 void AboutHandler::OnGetVersionInfoReady(
497 std::string callback_id, 497 std::string callback_id,
498 std::unique_ptr<base::DictionaryValue> version_info) { 498 std::unique_ptr<base::DictionaryValue> version_info) {
499 ResolveJavascriptCallback(base::StringValue(callback_id), *version_info); 499 ResolveJavascriptCallback(base::Value(callback_id), *version_info);
500 } 500 }
501 501
502 void AboutHandler::HandleGetRegulatoryInfo(const base::ListValue* args) { 502 void AboutHandler::HandleGetRegulatoryInfo(const base::ListValue* args) {
503 CHECK_EQ(1U, args->GetSize()); 503 CHECK_EQ(1U, args->GetSize());
504 std::string callback_id; 504 std::string callback_id;
505 CHECK(args->GetString(0, &callback_id)); 505 CHECK(args->GetString(0, &callback_id));
506 506
507 base::PostTaskWithTraitsAndReplyWithResult( 507 base::PostTaskWithTraitsAndReplyWithResult(
508 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( 508 FROM_HERE, base::TaskTraits().MayBlock().WithPriority(
509 base::TaskPriority::USER_VISIBLE), 509 base::TaskPriority::USER_VISIBLE),
(...skipping 23 matching lines...) Expand all
533 void AboutHandler::OnGetTargetChannel(std::string callback_id, 533 void AboutHandler::OnGetTargetChannel(std::string callback_id,
534 const std::string& current_channel, 534 const std::string& current_channel,
535 const std::string& target_channel) { 535 const std::string& target_channel) {
536 std::unique_ptr<base::DictionaryValue> channel_info( 536 std::unique_ptr<base::DictionaryValue> channel_info(
537 new base::DictionaryValue); 537 new base::DictionaryValue);
538 channel_info->SetString("currentChannel", current_channel); 538 channel_info->SetString("currentChannel", current_channel);
539 channel_info->SetString("targetChannel", target_channel); 539 channel_info->SetString("targetChannel", target_channel);
540 channel_info->SetBoolean("canChangeChannel", 540 channel_info->SetBoolean("canChangeChannel",
541 CanChangeChannel(Profile::FromWebUI(web_ui()))); 541 CanChangeChannel(Profile::FromWebUI(web_ui())));
542 542
543 ResolveJavascriptCallback(base::StringValue(callback_id), *channel_info); 543 ResolveJavascriptCallback(base::Value(callback_id), *channel_info);
544 } 544 }
545 545
546 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) { 546 void AboutHandler::HandleRequestUpdate(const base::ListValue* args) {
547 RequestUpdate(); 547 RequestUpdate();
548 } 548 }
549 549
550 #endif // defined(OS_CHROMEOS) 550 #endif // defined(OS_CHROMEOS)
551 551
552 void AboutHandler::RequestUpdate() { 552 void AboutHandler::RequestUpdate() {
553 version_updater_->CheckForUpdate( 553 version_updater_->CheckForUpdate(
(...skipping 23 matching lines...) Expand all
577 if (!types_msg.empty()) 577 if (!types_msg.empty())
578 event->SetString("connectionTypes", types_msg); 578 event->SetString("connectionTypes", types_msg);
579 else 579 else
580 event->Set("connectionTypes", base::Value::CreateNullValue()); 580 event->Set("connectionTypes", base::Value::CreateNullValue());
581 } else { 581 } else {
582 event->Set("connectionTypes", base::Value::CreateNullValue()); 582 event->Set("connectionTypes", base::Value::CreateNullValue());
583 } 583 }
584 #endif // defined(OS_CHROMEOS) 584 #endif // defined(OS_CHROMEOS)
585 585
586 CallJavascriptFunction("cr.webUIListenerCallback", 586 CallJavascriptFunction("cr.webUIListenerCallback",
587 base::StringValue("update-status-changed"), *event); 587 base::Value("update-status-changed"), *event);
588 } 588 }
589 589
590 #if defined(OS_MACOSX) 590 #if defined(OS_MACOSX)
591 void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) { 591 void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) {
592 // Worth noting: PROMOTE_DISABLED indicates that promotion is possible, 592 // Worth noting: PROMOTE_DISABLED indicates that promotion is possible,
593 // there's just something else going on right now (e.g. checking for update). 593 // there's just something else going on right now (e.g. checking for update).
594 bool hidden = state == VersionUpdater::PROMOTE_HIDDEN; 594 bool hidden = state == VersionUpdater::PROMOTE_HIDDEN;
595 bool disabled = state == VersionUpdater::PROMOTE_HIDDEN || 595 bool disabled = state == VersionUpdater::PROMOTE_HIDDEN ||
596 state == VersionUpdater::PROMOTE_DISABLED || 596 state == VersionUpdater::PROMOTE_DISABLED ||
597 state == VersionUpdater::PROMOTED; 597 state == VersionUpdater::PROMOTED;
598 bool actionable = state == VersionUpdater::PROMOTE_DISABLED || 598 bool actionable = state == VersionUpdater::PROMOTE_DISABLED ||
599 state == VersionUpdater::PROMOTE_ENABLED; 599 state == VersionUpdater::PROMOTE_ENABLED;
600 600
601 base::string16 text = base::string16(); 601 base::string16 text = base::string16();
602 if (actionable) 602 if (actionable)
603 text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL); 603 text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL);
604 else if (state == VersionUpdater::PROMOTED) 604 else if (state == VersionUpdater::PROMOTED)
605 text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL_IS_ON); 605 text = l10n_util::GetStringUTF16(IDS_ABOUT_CHROME_AUTOUPDATE_ALL_IS_ON);
606 606
607 base::DictionaryValue promo_state; 607 base::DictionaryValue promo_state;
608 promo_state.SetBoolean("hidden", hidden); 608 promo_state.SetBoolean("hidden", hidden);
609 promo_state.SetBoolean("disabled", disabled); 609 promo_state.SetBoolean("disabled", disabled);
610 promo_state.SetBoolean("actionable", actionable); 610 promo_state.SetBoolean("actionable", actionable);
611 if (!text.empty()) 611 if (!text.empty())
612 promo_state.SetString("text", text); 612 promo_state.SetString("text", text);
613 613
614 CallJavascriptFunction("cr.webUIListenerCallback", 614 CallJavascriptFunction("cr.webUIListenerCallback",
615 base::StringValue("promotion-state-changed"), 615 base::Value("promotion-state-changed"), promo_state);
616 promo_state);
617 } 616 }
618 #endif // defined(OS_MACOSX) 617 #endif // defined(OS_MACOSX)
619 618
620 #if defined(OS_CHROMEOS) 619 #if defined(OS_CHROMEOS)
621 void AboutHandler::OnRegulatoryLabelDirFound( 620 void AboutHandler::OnRegulatoryLabelDirFound(
622 std::string callback_id, 621 std::string callback_id,
623 const base::FilePath& label_dir_path) { 622 const base::FilePath& label_dir_path) {
624 if (label_dir_path.empty()) { 623 if (label_dir_path.empty()) {
625 ResolveJavascriptCallback(base::StringValue(callback_id), 624 ResolveJavascriptCallback(base::Value(callback_id),
626 *base::Value::CreateNullValue()); 625 *base::Value::CreateNullValue());
627 return; 626 return;
628 } 627 }
629 628
630 base::PostTaskWithTraitsAndReplyWithResult( 629 base::PostTaskWithTraitsAndReplyWithResult(
631 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( 630 FROM_HERE, base::TaskTraits().MayBlock().WithPriority(
632 base::TaskPriority::USER_VISIBLE), 631 base::TaskPriority::USER_VISIBLE),
633 base::Bind(&ReadRegulatoryLabelText, label_dir_path), 632 base::Bind(&ReadRegulatoryLabelText, label_dir_path),
634 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, 633 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead,
635 weak_factory_.GetWeakPtr(), callback_id, label_dir_path)); 634 weak_factory_.GetWeakPtr(), callback_id, label_dir_path));
636 } 635 }
637 636
638 void AboutHandler::OnRegulatoryLabelTextRead( 637 void AboutHandler::OnRegulatoryLabelTextRead(
639 std::string callback_id, 638 std::string callback_id,
640 const base::FilePath& label_dir_path, 639 const base::FilePath& label_dir_path,
641 const std::string& text) { 640 const std::string& text) {
642 std::unique_ptr<base::DictionaryValue> regulatory_info( 641 std::unique_ptr<base::DictionaryValue> regulatory_info(
643 new base::DictionaryValue); 642 new base::DictionaryValue);
644 // Remove unnecessary whitespace. 643 // Remove unnecessary whitespace.
645 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true)); 644 regulatory_info->SetString("text", base::CollapseWhitespaceASCII(text, true));
646 645
647 std::string image_path = 646 std::string image_path =
648 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); 647 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII();
649 std::string url = 648 std::string url =
650 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; 649 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path;
651 regulatory_info->SetString("url", url); 650 regulatory_info->SetString("url", url);
652 651
653 ResolveJavascriptCallback(base::StringValue(callback_id), *regulatory_info); 652 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info);
654 } 653 }
655 #endif // defined(OS_CHROMEOS) 654 #endif // defined(OS_CHROMEOS)
656 655
657 } // namespace settings 656 } // namespace settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698