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/devicetype_utils.h" | 11 #include "ash/system/devicetype_utils.h" |
| 12 #include "base/base_switches.h" | 12 #include "base/base_switches.h" |
| 13 #include "base/bind.h" | 13 #include "base/bind.h" |
| 14 #include "base/bind_helpers.h" | 14 #include "base/bind_helpers.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
| 17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
| 18 #include "base/i18n/message_formatter.h" | 18 #include "base/i18n/message_formatter.h" |
| 19 #include "base/location.h" | 19 #include "base/location.h" |
| 20 #include "base/macros.h" | 20 #include "base/macros.h" |
| 21 #include "base/strings/string16.h" | 21 #include "base/strings/string16.h" |
| 22 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
| 23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
| 24 #include "base/task_scheduler/post_task.h" | 24 #include "base/task_scheduler/post_task.h" |
| 25 #include "base/time/time.h" | 25 #include "base/time/time.h" |
| 26 #include "base/values.h" | 26 #include "base/values.h" |
| 27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
| 28 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 29 #include "chrome/browser/chrome_notification_types.h" | |
| 30 #include "chrome/browser/lifetime/application_lifetime.h" | 29 #include "chrome/browser/lifetime/application_lifetime.h" |
| 31 #include "chrome/browser/obsolete_system/obsolete_system.h" | 30 #include "chrome/browser/obsolete_system/obsolete_system.h" |
| 32 #include "chrome/browser/ui/browser.h" | 31 #include "chrome/browser/ui/browser.h" |
| 33 #include "chrome/browser/ui/browser_commands.h" | 32 #include "chrome/browser/ui/browser_commands.h" |
| 34 #include "chrome/browser/ui/browser_finder.h" | 33 #include "chrome/browser/ui/browser_finder.h" |
| 35 #include "chrome/browser/ui/chrome_pages.h" | 34 #include "chrome/browser/ui/chrome_pages.h" |
| 35 #include "chrome/browser/upgrade_detector.h" | |
| 36 #include "chrome/common/channel_info.h" | 36 #include "chrome/common/channel_info.h" |
| 37 #include "chrome/common/chrome_content_client.h" | 37 #include "chrome/common/chrome_content_client.h" |
| 38 #include "chrome/common/pref_names.h" | 38 #include "chrome/common/pref_names.h" |
| 39 #include "chrome/common/url_constants.h" | 39 #include "chrome/common/url_constants.h" |
| 40 #include "chrome/grit/chromium_strings.h" | 40 #include "chrome/grit/chromium_strings.h" |
| 41 #include "chrome/grit/generated_resources.h" | 41 #include "chrome/grit/generated_resources.h" |
| 42 #include "components/google/core/browser/google_util.h" | 42 #include "components/google/core/browser/google_util.h" |
| 43 #include "components/policy/core/common/policy_namespace.h" | 43 #include "components/policy/core/common/policy_namespace.h" |
| 44 #include "components/policy/policy_constants.h" | 44 #include "components/policy/policy_constants.h" |
| 45 #include "components/strings/grit/components_chromium_strings.h" | 45 #include "components/strings/grit/components_chromium_strings.h" |
| 46 #include "components/strings/grit/components_strings.h" | 46 #include "components/strings/grit/components_strings.h" |
| 47 #include "components/version_info/version_info.h" | 47 #include "components/version_info/version_info.h" |
| 48 #include "content/public/browser/browser_thread.h" | 48 #include "content/public/browser/browser_thread.h" |
| 49 #include "content/public/browser/notification_service.h" | |
| 50 #include "content/public/browser/web_contents.h" | 49 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/browser/web_ui.h" | 50 #include "content/public/browser/web_ui.h" |
| 52 #include "ui/base/l10n/l10n_util.h" | 51 #include "ui/base/l10n/l10n_util.h" |
| 53 #include "v8/include/v8-version-string.h" | 52 #include "v8/include/v8-version-string.h" |
| 54 | 53 |
| 55 #if defined(OS_CHROMEOS) | 54 #if defined(OS_CHROMEOS) |
| 56 #include "base/files/file_util_proxy.h" | 55 #include "base/files/file_util_proxy.h" |
| 57 #include "base/i18n/time_formatting.h" | 56 #include "base/i18n/time_formatting.h" |
| 58 #include "base/sys_info.h" | 57 #include "base/sys_info.h" |
| 59 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" | 58 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h" |
| (...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 367 | 366 |
| 368 localized_strings->SetString("userAgentInfo", GetUserAgent()); | 367 localized_strings->SetString("userAgentInfo", GetUserAgent()); |
| 369 | 368 |
| 370 base::CommandLine::StringType command_line = | 369 base::CommandLine::StringType command_line = |
| 371 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); | 370 base::CommandLine::ForCurrentProcess()->GetCommandLineString(); |
| 372 localized_strings->SetString("commandLineInfo", command_line); | 371 localized_strings->SetString("commandLineInfo", command_line); |
| 373 } | 372 } |
| 374 | 373 |
| 375 void HelpHandler::RegisterMessages() { | 374 void HelpHandler::RegisterMessages() { |
| 376 version_updater_.reset(VersionUpdater::Create(web_ui()->GetWebContents())); | 375 version_updater_.reset(VersionUpdater::Create(web_ui()->GetWebContents())); |
| 377 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 376 UpgradeDetector::GetInstance()->AddObserver(this); |
|
sky
2017/06/07 23:01:41
I don't see a corresponding remove?
weidongg
2017/06/08 02:28:42
Added AddObserver and RemoveObserver in constructo
| |
| 378 content::NotificationService::AllSources()); | |
| 379 policy_registrar_.Observe( | 377 policy_registrar_.Observe( |
| 380 policy::key::kDeviceAutoUpdateDisabled, | 378 policy::key::kDeviceAutoUpdateDisabled, |
| 381 base::Bind(&HelpHandler::OnDeviceAutoUpdatePolicyChanged, | 379 base::Bind(&HelpHandler::OnDeviceAutoUpdatePolicyChanged, |
| 382 base::Unretained(this))); | 380 base::Unretained(this))); |
| 383 | 381 |
| 384 web_ui()->RegisterMessageCallback("onPageLoaded", | 382 web_ui()->RegisterMessageCallback("onPageLoaded", |
| 385 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); | 383 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); |
| 386 web_ui()->RegisterMessageCallback("relaunchNow", | 384 web_ui()->RegisterMessageCallback("relaunchNow", |
| 387 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); | 385 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); |
| 388 web_ui()->RegisterMessageCallback("openFeedbackDialog", | 386 web_ui()->RegisterMessageCallback("openFeedbackDialog", |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 402 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); | 400 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); |
| 403 #endif | 401 #endif |
| 404 | 402 |
| 405 #if defined(OS_CHROMEOS) | 403 #if defined(OS_CHROMEOS) |
| 406 // Handler for the product label image, which will be shown if available. | 404 // Handler for the product label image, which will be shown if available. |
| 407 content::URLDataSource::Add(Profile::FromWebUI(web_ui()), | 405 content::URLDataSource::Add(Profile::FromWebUI(web_ui()), |
| 408 new chromeos::ImageSource()); | 406 new chromeos::ImageSource()); |
| 409 #endif | 407 #endif |
| 410 } | 408 } |
| 411 | 409 |
| 412 void HelpHandler::Observe(int type, const content::NotificationSource& source, | 410 void HelpHandler::OnUpgradeRecommended() { |
| 413 const content::NotificationDetails& details) { | |
| 414 DCHECK_EQ(chrome::NOTIFICATION_UPGRADE_RECOMMENDED, type); | |
| 415 | |
| 416 // A version update is installed and ready to go. Refresh the UI so the | 411 // A version update is installed and ready to go. Refresh the UI so the |
| 417 // correct state will be shown. | 412 // correct state will be shown. |
| 418 RequestUpdate(nullptr); | 413 RequestUpdate(nullptr); |
| 419 } | 414 } |
| 420 | 415 |
| 421 // static | 416 // static |
| 422 base::string16 HelpHandler::BuildBrowserVersionString() { | 417 base::string16 HelpHandler::BuildBrowserVersionString() { |
| 423 std::string version = version_info::GetVersionNumber(); | 418 std::string version = version_info::GetVersionNumber(); |
| 424 | 419 |
| 425 std::string modifier = chrome::GetChannelString(); | 420 std::string modifier = chrome::GetChannelString(); |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 757 base::Value("device_supported"), | 752 base::Value("device_supported"), |
| 758 base::Value("")); | 753 base::Value("")); |
| 759 } else { | 754 } else { |
| 760 web_ui()->CallJavascriptFunctionUnsafe( | 755 web_ui()->CallJavascriptFunctionUnsafe( |
| 761 "help.HelpPage.updateEolMessage", base::Value("device_endoflife"), | 756 "help.HelpPage.updateEolMessage", base::Value("device_endoflife"), |
| 762 base::Value(l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_EOL))); | 757 base::Value(l10n_util::GetStringUTF16(IDS_ABOUT_PAGE_EOL_EOL))); |
| 763 } | 758 } |
| 764 } | 759 } |
| 765 | 760 |
| 766 #endif // defined(OS_CHROMEOS) | 761 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |