Chromium Code Reviews| 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 |
| 11 #include "ash/system/chromeos/devicetype_utils.h" | 11 #include "ash/system/chromeos/devicetype_utils.h" |
| 12 #include "base/base_switches.h" | |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 15 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 16 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 17 #include "base/i18n/message_formatter.h" | 18 #include "base/i18n/message_formatter.h" |
| 18 #include "base/location.h" | 19 #include "base/location.h" |
| 19 #include "base/macros.h" | 20 #include "base/macros.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" |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 #include "chrome/browser/profiles/profile.h" | 67 #include "chrome/browser/profiles/profile.h" |
| 67 #include "chrome/browser/ui/webui/chromeos/image_source.h" | 68 #include "chrome/browser/ui/webui/chromeos/image_source.h" |
| 68 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 69 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
| 69 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" | 70 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| 70 #include "chromeos/chromeos_switches.h" | 71 #include "chromeos/chromeos_switches.h" |
| 71 #include "chromeos/dbus/dbus_thread_manager.h" | 72 #include "chromeos/dbus/dbus_thread_manager.h" |
| 72 #include "chromeos/dbus/power_manager_client.h" | 73 #include "chromeos/dbus/power_manager_client.h" |
| 73 #include "chromeos/system/statistics_provider.h" | 74 #include "chromeos/system/statistics_provider.h" |
| 74 #include "components/prefs/pref_service.h" | 75 #include "components/prefs/pref_service.h" |
| 75 #include "components/user_manager/user_manager.h" | 76 #include "components/user_manager/user_manager.h" |
| 77 #include "third_party/cros_system_api/dbus/update_engine/dbus-constants.h" | |
| 76 #endif | 78 #endif |
| 77 | 79 |
| 78 using base::ListValue; | 80 using base::ListValue; |
| 79 using content::BrowserThread; | 81 using content::BrowserThread; |
| 80 | 82 |
| 81 namespace { | 83 namespace { |
| 82 | 84 |
| 83 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
| 84 | 86 |
| 85 // Directory containing the regulatory labels for supported regions. | 87 // Directory containing the regulatory labels for supported regions. |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 base::FilePath text_path(chrome::kChromeOSAssetPath); | 200 base::FilePath text_path(chrome::kChromeOSAssetPath); |
| 199 text_path = text_path.Append(path); | 201 text_path = text_path.Append(path); |
| 200 text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename); | 202 text_path = text_path.AppendASCII(kRegulatoryLabelTextFilename); |
| 201 | 203 |
| 202 std::string contents; | 204 std::string contents; |
| 203 if (base::ReadFileToString(text_path, &contents)) | 205 if (base::ReadFileToString(text_path, &contents)) |
| 204 return contents; | 206 return contents; |
| 205 return std::string(); | 207 return std::string(); |
| 206 } | 208 } |
| 207 | 209 |
| 210 // Returns messages that applys to this eol status | |
| 211 base::string16 GetEolMessage(int status) { | |
| 212 if (status == update_engine::EndOfLifeStatus::kSecurityOnly) { | |
| 213 return l10n_util::GetStringFUTF16( | |
| 214 IDS_ABOUT_PAGE_EOL_SECURITY_ONLY, | |
| 215 base::ASCIIToUTF16(chrome::kEolNotificationURL), | |
| 216 base::ASCIIToUTF16(chrome::kEolNotificationURL)); | |
|
xiyuan
2016/06/17 20:02:10
Think we only need one chrome::kEolNotificationURL
xiaoyinh(OOO Sep 11-29)
2016/06/17 22:36:53
Done.
| |
| 217 | |
| 218 } else { | |
| 219 return l10n_util::GetStringFUTF16( | |
| 220 IDS_ABOUT_PAGE_EOL_EOL, base::ASCIIToUTF16(chrome::kEolNotificationURL), | |
| 221 base::ASCIIToUTF16(chrome::kEolNotificationURL)); | |
|
xiyuan
2016/06/17 20:02:10
same here.
xiaoyinh(OOO Sep 11-29)
2016/06/17 22:36:53
Done.
| |
| 222 } | |
| 223 } | |
| 224 | |
| 208 #endif // defined(OS_CHROMEOS) | 225 #endif // defined(OS_CHROMEOS) |
| 209 | 226 |
| 210 } // namespace | 227 } // namespace |
| 211 | 228 |
| 212 HelpHandler::HelpHandler() | 229 HelpHandler::HelpHandler() |
| 213 : policy_registrar_( | 230 : policy_registrar_( |
| 214 g_browser_process->policy_service(), | 231 g_browser_process->policy_service(), |
| 215 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())), | 232 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())), |
| 216 weak_factory_(this) { | 233 weak_factory_(this) { |
| 217 } | 234 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 509 "help.HelpPage.updateIsEnterpriseManaged", | 526 "help.HelpPage.updateIsEnterpriseManaged", |
| 510 base::FundamentalValue(IsEnterpriseManaged())); | 527 base::FundamentalValue(IsEnterpriseManaged())); |
| 511 // First argument to GetChannel() is a flag that indicates whether | 528 // First argument to GetChannel() is a flag that indicates whether |
| 512 // current channel should be returned (if true) or target channel | 529 // current channel should be returned (if true) or target channel |
| 513 // (otherwise). | 530 // (otherwise). |
| 514 version_updater_->GetChannel(true, | 531 version_updater_->GetChannel(true, |
| 515 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | 532 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); |
| 516 version_updater_->GetChannel(false, | 533 version_updater_->GetChannel(false, |
| 517 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | 534 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); |
| 518 | 535 |
| 536 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | |
| 537 chromeos::switches::kEnableEolNotification)) { | |
| 538 version_updater_->GetEolStatus( | |
| 539 base::Bind(&HelpHandler::OnEolStatus, weak_factory_.GetWeakPtr())); | |
| 540 } | |
| 541 | |
| 519 base::PostTaskAndReplyWithResult( | 542 base::PostTaskAndReplyWithResult( |
| 520 content::BrowserThread::GetBlockingPool(), | 543 content::BrowserThread::GetBlockingPool(), |
| 521 FROM_HERE, | 544 FROM_HERE, |
| 522 base::Bind(&FindRegulatoryLabelDir), | 545 base::Bind(&FindRegulatoryLabelDir), |
| 523 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound, | 546 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound, |
| 524 weak_factory_.GetWeakPtr())); | 547 weak_factory_.GetWeakPtr())); |
| 525 #endif | 548 #endif |
| 526 } | 549 } |
| 527 | 550 |
| 528 #if defined(OS_MACOSX) | 551 #if defined(OS_MACOSX) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 base::StringValue(url)); | 758 base::StringValue(url)); |
| 736 } | 759 } |
| 737 | 760 |
| 738 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { | 761 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { |
| 739 // Remove unnecessary whitespace. | 762 // Remove unnecessary whitespace. |
| 740 web_ui()->CallJavascriptFunctionUnsafe( | 763 web_ui()->CallJavascriptFunctionUnsafe( |
| 741 "help.HelpPage.setRegulatoryLabelText", | 764 "help.HelpPage.setRegulatoryLabelText", |
| 742 base::StringValue(base::CollapseWhitespaceASCII(text, true))); | 765 base::StringValue(base::CollapseWhitespaceASCII(text, true))); |
| 743 } | 766 } |
| 744 | 767 |
| 768 void HelpHandler::OnEolStatus(const int status) { | |
| 769 if (status == update_engine::EndOfLifeStatus::kSupported || | |
| 770 IsEnterpriseManaged()) { | |
| 771 return; | |
| 772 } | |
| 773 | |
| 774 if (status == update_engine::EndOfLifeStatus::kSupported) { | |
| 775 web_ui()->CallJavascriptFunctionUnsafe( | |
| 776 "help.HelpPage.updateEolMessage", base::StringValue("device_supported"), | |
| 777 base::StringValue("")); | |
| 778 } else { | |
| 779 base::string16 message = GetEolMessage(status); | |
| 780 web_ui()->CallJavascriptFunctionUnsafe( | |
| 781 "help.HelpPage.updateEolMessage", base::StringValue("device_endoflife"), | |
| 782 base::StringValue(message)); | |
| 783 } | |
| 784 } | |
| 785 | |
| 745 #endif // defined(OS_CHROMEOS) | 786 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |