| 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/common/system/chromeos/devicetype_utils.h" | 11 #include "ash/common/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 |
| 217 } else { |
| 218 return l10n_util::GetStringFUTF16( |
| 219 IDS_ABOUT_PAGE_EOL_EOL, |
| 220 base::ASCIIToUTF16(chrome::kEolNotificationURL)); |
| 221 } |
| 222 } |
| 223 |
| 208 #endif // defined(OS_CHROMEOS) | 224 #endif // defined(OS_CHROMEOS) |
| 209 | 225 |
| 210 } // namespace | 226 } // namespace |
| 211 | 227 |
| 212 HelpHandler::HelpHandler() | 228 HelpHandler::HelpHandler() |
| 213 : policy_registrar_( | 229 : policy_registrar_( |
| 214 g_browser_process->policy_service(), | 230 g_browser_process->policy_service(), |
| 215 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())), | 231 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())), |
| 216 weak_factory_(this) { | 232 weak_factory_(this) { |
| 217 } | 233 } |
| (...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 "help.HelpPage.updateIsEnterpriseManaged", | 525 "help.HelpPage.updateIsEnterpriseManaged", |
| 510 base::FundamentalValue(IsEnterpriseManaged())); | 526 base::FundamentalValue(IsEnterpriseManaged())); |
| 511 // First argument to GetChannel() is a flag that indicates whether | 527 // First argument to GetChannel() is a flag that indicates whether |
| 512 // current channel should be returned (if true) or target channel | 528 // current channel should be returned (if true) or target channel |
| 513 // (otherwise). | 529 // (otherwise). |
| 514 version_updater_->GetChannel(true, | 530 version_updater_->GetChannel(true, |
| 515 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); | 531 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); |
| 516 version_updater_->GetChannel(false, | 532 version_updater_->GetChannel(false, |
| 517 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); | 533 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); |
| 518 | 534 |
| 535 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 536 chromeos::switches::kEnableEolNotification)) { |
| 537 version_updater_->GetEolStatus( |
| 538 base::Bind(&HelpHandler::OnEolStatus, weak_factory_.GetWeakPtr())); |
| 539 } |
| 540 |
| 519 base::PostTaskAndReplyWithResult( | 541 base::PostTaskAndReplyWithResult( |
| 520 content::BrowserThread::GetBlockingPool(), | 542 content::BrowserThread::GetBlockingPool(), |
| 521 FROM_HERE, | 543 FROM_HERE, |
| 522 base::Bind(&FindRegulatoryLabelDir), | 544 base::Bind(&FindRegulatoryLabelDir), |
| 523 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound, | 545 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound, |
| 524 weak_factory_.GetWeakPtr())); | 546 weak_factory_.GetWeakPtr())); |
| 525 #endif | 547 #endif |
| 526 } | 548 } |
| 527 | 549 |
| 528 #if defined(OS_MACOSX) | 550 #if defined(OS_MACOSX) |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 base::StringValue(url)); | 757 base::StringValue(url)); |
| 736 } | 758 } |
| 737 | 759 |
| 738 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { | 760 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { |
| 739 // Remove unnecessary whitespace. | 761 // Remove unnecessary whitespace. |
| 740 web_ui()->CallJavascriptFunctionUnsafe( | 762 web_ui()->CallJavascriptFunctionUnsafe( |
| 741 "help.HelpPage.setRegulatoryLabelText", | 763 "help.HelpPage.setRegulatoryLabelText", |
| 742 base::StringValue(base::CollapseWhitespaceASCII(text, true))); | 764 base::StringValue(base::CollapseWhitespaceASCII(text, true))); |
| 743 } | 765 } |
| 744 | 766 |
| 767 void HelpHandler::OnEolStatus(const int status) { |
| 768 if (status == update_engine::EndOfLifeStatus::kSupported || |
| 769 IsEnterpriseManaged()) { |
| 770 return; |
| 771 } |
| 772 |
| 773 if (status == update_engine::EndOfLifeStatus::kSupported) { |
| 774 web_ui()->CallJavascriptFunctionUnsafe( |
| 775 "help.HelpPage.updateEolMessage", base::StringValue("device_supported"), |
| 776 base::StringValue("")); |
| 777 } else { |
| 778 base::string16 message = GetEolMessage(status); |
| 779 web_ui()->CallJavascriptFunctionUnsafe( |
| 780 "help.HelpPage.updateEolMessage", base::StringValue("device_endoflife"), |
| 781 base::StringValue(message)); |
| 782 } |
| 783 } |
| 784 |
| 745 #endif // defined(OS_CHROMEOS) | 785 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |