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

Side by Side Diff: chrome/browser/ui/webui/help/help_handler.cc

Issue 2060623002: Implementation of Device End of Life Notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modify browsertest Created 4 years, 6 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 (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
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
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 base::string16 eol_link = l10n_util::GetStringFUTF16(
213 IDS_EOL_MORE_INFO_LINK, base::ASCIIToUTF16(chrome::kEolNotificationURL),
214 base::ASCIIToUTF16(chrome::kEolNotificationURL));
215 if (status == update_engine::EndOfLifeStatus::kSecurityOnly) {
216 return l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_SECURITY_ONLY) +
217 eol_link;
218 } else {
219 return l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_EOL) + eol_link;
xiyuan 2016/06/16 22:41:28 Cancat strings like this is not i18n friendly beca
xiaoyinh(OOO Sep 11-29) 2016/06/17 04:07:35 Done.
220 }
221 }
222
208 #endif // defined(OS_CHROMEOS) 223 #endif // defined(OS_CHROMEOS)
209 224
210 } // namespace 225 } // namespace
211 226
212 HelpHandler::HelpHandler() 227 HelpHandler::HelpHandler()
213 : policy_registrar_( 228 : policy_registrar_(
214 g_browser_process->policy_service(), 229 g_browser_process->policy_service(),
215 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())), 230 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())),
216 weak_factory_(this) { 231 weak_factory_(this) {
217 } 232 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
509 "help.HelpPage.updateIsEnterpriseManaged", 524 "help.HelpPage.updateIsEnterpriseManaged",
510 base::FundamentalValue(IsEnterpriseManaged())); 525 base::FundamentalValue(IsEnterpriseManaged()));
511 // First argument to GetChannel() is a flag that indicates whether 526 // First argument to GetChannel() is a flag that indicates whether
512 // current channel should be returned (if true) or target channel 527 // current channel should be returned (if true) or target channel
513 // (otherwise). 528 // (otherwise).
514 version_updater_->GetChannel(true, 529 version_updater_->GetChannel(true,
515 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr())); 530 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr()));
516 version_updater_->GetChannel(false, 531 version_updater_->GetChannel(false,
517 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr())); 532 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr()));
518 533
534 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
535 chromeos::switches::kEnableEolNotification)) {
536 version_updater_->GetEolStatus(
537 base::Bind(&HelpHandler::OnEolStatus, weak_factory_.GetWeakPtr()));
538 }
539
519 base::PostTaskAndReplyWithResult( 540 base::PostTaskAndReplyWithResult(
520 content::BrowserThread::GetBlockingPool(), 541 content::BrowserThread::GetBlockingPool(),
521 FROM_HERE, 542 FROM_HERE,
522 base::Bind(&FindRegulatoryLabelDir), 543 base::Bind(&FindRegulatoryLabelDir),
523 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound, 544 base::Bind(&HelpHandler::OnRegulatoryLabelDirFound,
524 weak_factory_.GetWeakPtr())); 545 weak_factory_.GetWeakPtr()));
525 #endif 546 #endif
526 } 547 }
527 548
528 #if defined(OS_MACOSX) 549 #if defined(OS_MACOSX)
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 base::StringValue(url)); 756 base::StringValue(url));
736 } 757 }
737 758
738 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) { 759 void HelpHandler::OnRegulatoryLabelTextRead(const std::string& text) {
739 // Remove unnecessary whitespace. 760 // Remove unnecessary whitespace.
740 web_ui()->CallJavascriptFunctionUnsafe( 761 web_ui()->CallJavascriptFunctionUnsafe(
741 "help.HelpPage.setRegulatoryLabelText", 762 "help.HelpPage.setRegulatoryLabelText",
742 base::StringValue(base::CollapseWhitespaceASCII(text, true))); 763 base::StringValue(base::CollapseWhitespaceASCII(text, true)));
743 } 764 }
744 765
766 void HelpHandler::OnEolStatus(const int status) {
767 if (status == update_engine::EndOfLifeStatus::kSupported ||
768 IsEnterpriseManaged()) {
769 return;
770 }
771
772 if (status == update_engine::EndOfLifeStatus::kSupported) {
773 web_ui()->CallJavascriptFunctionUnsafe(
774 "help.HelpPage.updateEolMessage", base::StringValue("device_supported"),
775 base::StringValue(""));
776 } else {
777 base::string16 message = GetEolMessage(status);
778 web_ui()->CallJavascriptFunctionUnsafe(
779 "help.HelpPage.updateEolMessage", base::StringValue("device_endoflife"),
780 base::StringValue(message));
781 }
782 }
783
745 #endif // defined(OS_CHROMEOS) 784 #endif // defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698