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 |
11 #include "ash/common/system/chromeos/devicetype_utils.h" | 11 #include "ash/common/system/chromeos/devicetype_utils.h" |
12 #include "base/bind.h" | 12 #include "base/bind.h" |
13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 16 #include "base/files/file_util.h" |
17 #include "base/i18n/message_formatter.h" | 17 #include "base/i18n/message_formatter.h" |
18 #include "base/location.h" | 18 #include "base/location.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
| 20 #include "base/memory/ptr_util.h" |
20 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
22 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
23 #include "base/task_scheduler/post_task.h" | 24 #include "base/task_scheduler/post_task.h" |
24 #include "base/time/time.h" | 25 #include "base/time/time.h" |
25 #include "base/values.h" | 26 #include "base/values.h" |
26 #include "build/build_config.h" | 27 #include "build/build_config.h" |
27 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
28 #include "chrome/browser/chrome_notification_types.h" | 29 #include "chrome/browser/chrome_notification_types.h" |
29 #include "chrome/browser/obsolete_system/obsolete_system.h" | 30 #include "chrome/browser/obsolete_system/obsolete_system.h" |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 event->SetString("message", message); | 568 event->SetString("message", message); |
568 event->SetInteger("progress", progress); | 569 event->SetInteger("progress", progress); |
569 | 570 |
570 #if defined(OS_CHROMEOS) | 571 #if defined(OS_CHROMEOS) |
571 if (status == VersionUpdater::FAILED_OFFLINE || | 572 if (status == VersionUpdater::FAILED_OFFLINE || |
572 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { | 573 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) { |
573 base::string16 types_msg = GetAllowedConnectionTypesMessage(); | 574 base::string16 types_msg = GetAllowedConnectionTypesMessage(); |
574 if (!types_msg.empty()) | 575 if (!types_msg.empty()) |
575 event->SetString("connectionTypes", types_msg); | 576 event->SetString("connectionTypes", types_msg); |
576 else | 577 else |
577 event->Set("connectionTypes", base::Value::CreateNullValue()); | 578 event->Set("connectionTypes", base::MakeUnique<base::Value>()); |
578 } else { | 579 } else { |
579 event->Set("connectionTypes", base::Value::CreateNullValue()); | 580 event->Set("connectionTypes", base::MakeUnique<base::Value>()); |
580 } | 581 } |
581 #endif // defined(OS_CHROMEOS) | 582 #endif // defined(OS_CHROMEOS) |
582 | 583 |
583 CallJavascriptFunction("cr.webUIListenerCallback", | 584 CallJavascriptFunction("cr.webUIListenerCallback", |
584 base::Value("update-status-changed"), *event); | 585 base::Value("update-status-changed"), *event); |
585 } | 586 } |
586 | 587 |
587 #if defined(OS_MACOSX) | 588 #if defined(OS_MACOSX) |
588 void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) { | 589 void AboutHandler::SetPromotionState(VersionUpdater::PromotionState state) { |
589 // Worth noting: PROMOTE_DISABLED indicates that promotion is possible, | 590 // Worth noting: PROMOTE_DISABLED indicates that promotion is possible, |
(...skipping 21 matching lines...) Expand all Loading... |
611 CallJavascriptFunction("cr.webUIListenerCallback", | 612 CallJavascriptFunction("cr.webUIListenerCallback", |
612 base::Value("promotion-state-changed"), promo_state); | 613 base::Value("promotion-state-changed"), promo_state); |
613 } | 614 } |
614 #endif // defined(OS_MACOSX) | 615 #endif // defined(OS_MACOSX) |
615 | 616 |
616 #if defined(OS_CHROMEOS) | 617 #if defined(OS_CHROMEOS) |
617 void AboutHandler::OnRegulatoryLabelDirFound( | 618 void AboutHandler::OnRegulatoryLabelDirFound( |
618 std::string callback_id, | 619 std::string callback_id, |
619 const base::FilePath& label_dir_path) { | 620 const base::FilePath& label_dir_path) { |
620 if (label_dir_path.empty()) { | 621 if (label_dir_path.empty()) { |
621 ResolveJavascriptCallback(base::Value(callback_id), | 622 ResolveJavascriptCallback(base::Value(callback_id), base::Value()); |
622 *base::Value::CreateNullValue()); | |
623 return; | 623 return; |
624 } | 624 } |
625 | 625 |
626 base::PostTaskWithTraitsAndReplyWithResult( | 626 base::PostTaskWithTraitsAndReplyWithResult( |
627 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( | 627 FROM_HERE, base::TaskTraits().MayBlock().WithPriority( |
628 base::TaskPriority::USER_VISIBLE), | 628 base::TaskPriority::USER_VISIBLE), |
629 base::Bind(&ReadRegulatoryLabelText, label_dir_path), | 629 base::Bind(&ReadRegulatoryLabelText, label_dir_path), |
630 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, | 630 base::Bind(&AboutHandler::OnRegulatoryLabelTextRead, |
631 weak_factory_.GetWeakPtr(), callback_id, label_dir_path)); | 631 weak_factory_.GetWeakPtr(), callback_id, label_dir_path)); |
632 } | 632 } |
(...skipping 11 matching lines...) Expand all Loading... |
644 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); | 644 label_dir_path.AppendASCII(kRegulatoryLabelImageFilename).MaybeAsASCII(); |
645 std::string url = | 645 std::string url = |
646 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; | 646 std::string("chrome://") + chrome::kChromeOSAssetHost + "/" + image_path; |
647 regulatory_info->SetString("url", url); | 647 regulatory_info->SetString("url", url); |
648 | 648 |
649 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info); | 649 ResolveJavascriptCallback(base::Value(callback_id), *regulatory_info); |
650 } | 650 } |
651 #endif // defined(OS_CHROMEOS) | 651 #endif // defined(OS_CHROMEOS) |
652 | 652 |
653 } // namespace settings | 653 } // namespace settings |
OLD | NEW |