| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| 11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chrome_notification_types.h" | 18 #include "chrome/browser/chrome_notification_types.h" |
| 19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
| 20 #include "chrome/browser/ui/browser_commands.h" | 20 #include "chrome/browser/ui/browser_commands.h" |
| 21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
| 22 #include "chrome/browser/ui/chrome_pages.h" | 22 #include "chrome/browser/ui/chrome_pages.h" |
| 23 #include "chrome/browser/ui/webui/help/help_utils.h" |
| 23 #include "chrome/common/chrome_content_client.h" | 24 #include "chrome/common/chrome_content_client.h" |
| 24 #include "chrome/common/chrome_version_info.h" | |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "components/google/core/browser/google_util.h" | 27 #include "components/google/core/browser/google_util.h" |
| 28 #include "content/public/browser/browser_thread.h" | 28 #include "content/public/browser/browser_thread.h" |
| 29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/web_ui.h" | 30 #include "content/public/browser/web_ui.h" |
| 31 #include "content/public/browser/web_ui_data_source.h" | |
| 32 #include "content/public/common/user_agent.h" | 31 #include "content/public/common/user_agent.h" |
| 33 #include "grit/chromium_strings.h" | 32 #include "grit/chromium_strings.h" |
| 34 #include "grit/generated_resources.h" | 33 #include "grit/generated_resources.h" |
| 35 #include "grit/google_chrome_strings.h" | 34 #include "grit/google_chrome_strings.h" |
| 36 #include "ui/base/l10n/l10n_util.h" | 35 #include "ui/base/l10n/l10n_util.h" |
| 37 #include "v8/include/v8.h" | 36 #include "v8/include/v8.h" |
| 38 | 37 |
| 39 #if defined(OS_MACOSX) | 38 #if defined(OS_MACOSX) |
| 40 #include "chrome/browser/mac/obsolete_system.h" | 39 #include "chrome/browser/mac/obsolete_system.h" |
| 41 #endif | 40 #endif |
| 42 | 41 |
| 43 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 44 #include "base/files/file_util_proxy.h" | 43 #include "base/files/file_util_proxy.h" |
| 45 #include "base/i18n/time_formatting.h" | 44 #include "base/i18n/time_formatting.h" |
| 46 #include "base/prefs/pref_service.h" | 45 #include "base/prefs/pref_service.h" |
| 47 #include "base/sys_info.h" | 46 #include "base/sys_info.h" |
| 48 #include "chrome/browser/chromeos/login/users/user_manager.h" | 47 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 49 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 48 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 50 #include "chrome/browser/chromeos/settings/cros_settings.h" | 49 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 51 #include "chrome/browser/profiles/profile.h" | 50 #include "chrome/browser/profiles/profile.h" |
| 52 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | |
| 53 #include "chromeos/chromeos_switches.h" | 51 #include "chromeos/chromeos_switches.h" |
| 54 #include "chromeos/dbus/dbus_thread_manager.h" | 52 #include "chromeos/dbus/dbus_thread_manager.h" |
| 55 #include "chromeos/dbus/power_manager_client.h" | 53 #include "chromeos/dbus/power_manager_client.h" |
| 56 #endif | 54 #endif |
| 57 | 55 |
| 58 using base::ListValue; | 56 using base::ListValue; |
| 59 using content::BrowserThread; | 57 using content::BrowserThread; |
| 60 | 58 |
| 61 namespace { | 59 namespace { |
| 62 | 60 |
| 63 // Returns the browser version as a string. | |
| 64 base::string16 BuildBrowserVersionString() { | |
| 65 chrome::VersionInfo version_info; | |
| 66 DCHECK(version_info.is_valid()); | |
| 67 | |
| 68 std::string browser_version = version_info.Version(); | |
| 69 std::string version_modifier = | |
| 70 chrome::VersionInfo::GetVersionStringModifier(); | |
| 71 if (!version_modifier.empty()) | |
| 72 browser_version += " " + version_modifier; | |
| 73 | |
| 74 #if !defined(GOOGLE_CHROME_BUILD) | |
| 75 browser_version += " ("; | |
| 76 browser_version += version_info.LastChange(); | |
| 77 browser_version += ")"; | |
| 78 #endif | |
| 79 | |
| 80 #if defined(ARCH_CPU_64_BITS) | |
| 81 browser_version += " (64-bit)"; | |
| 82 #endif | |
| 83 | |
| 84 return base::UTF8ToUTF16(browser_version); | |
| 85 } | |
| 86 | |
| 87 #if defined(OS_CHROMEOS) | 61 #if defined(OS_CHROMEOS) |
| 88 | 62 |
| 89 // Returns message that informs user that for update it's better to | 63 // Returns message that informs user that for update it's better to |
| 90 // connect to a network of one of the allowed types. | 64 // connect to a network of one of the allowed types. |
| 91 base::string16 GetAllowedConnectionTypesMessage() { | 65 base::string16 GetAllowedConnectionTypesMessage() { |
| 92 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { | 66 if (help_utils::IsUpdateOverCellularAllowed()) { |
| 93 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); | 67 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); |
| 94 } else { | 68 } else { |
| 95 return l10n_util::GetStringUTF16( | 69 return l10n_util::GetStringUTF16( |
| 96 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); | 70 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); |
| 97 } | 71 } |
| 98 } | 72 } |
| 99 | 73 |
| 100 // Returns true if the device is enterprise managed, false otherwise. | 74 // Returns true if the device is enterprise managed, false otherwise. |
| 101 bool IsEnterpriseManaged() { | 75 bool IsEnterpriseManaged() { |
| 102 policy::BrowserPolicyConnectorChromeOS* connector = | 76 policy::BrowserPolicyConnectorChromeOS* connector = |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 } // namespace | 111 } // namespace |
| 138 | 112 |
| 139 HelpHandler::HelpHandler() | 113 HelpHandler::HelpHandler() |
| 140 : version_updater_(VersionUpdater::Create()), | 114 : version_updater_(VersionUpdater::Create()), |
| 141 weak_factory_(this) { | 115 weak_factory_(this) { |
| 142 } | 116 } |
| 143 | 117 |
| 144 HelpHandler::~HelpHandler() { | 118 HelpHandler::~HelpHandler() { |
| 145 } | 119 } |
| 146 | 120 |
| 147 void HelpHandler::GetLocalizedValues(content::WebUIDataSource* source) { | 121 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) { |
| 148 struct L10nResources { | 122 struct L10nResources { |
| 149 const char* name; | 123 const char* name; |
| 150 int ids; | 124 int ids; |
| 151 }; | 125 }; |
| 152 | 126 |
| 153 static L10nResources resources[] = { | 127 static L10nResources resources[] = { |
| 154 { "aboutTitle", IDS_ABOUT_TITLE }, | 128 { "aboutTitle", IDS_ABOUT_TITLE }, |
| 155 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 156 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, | 130 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, |
| 157 #else | 131 #else |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, | 186 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, |
| 213 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, | 187 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, |
| 214 #endif | 188 #endif |
| 215 #if defined(OS_MACOSX) | 189 #if defined(OS_MACOSX) |
| 216 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, | 190 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, |
| 217 { "learnMore", IDS_LEARN_MORE }, | 191 { "learnMore", IDS_LEARN_MORE }, |
| 218 #endif | 192 #endif |
| 219 }; | 193 }; |
| 220 | 194 |
| 221 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { | 195 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { |
| 222 source->AddString(resources[i].name, | 196 localized_strings->SetString(resources[i].name, |
| 223 l10n_util::GetStringUTF16(resources[i].ids)); | 197 l10n_util::GetStringUTF16(resources[i].ids)); |
| 224 } | 198 } |
| 225 | 199 |
| 226 #if defined(OS_MACOSX) | 200 #if defined(OS_MACOSX) |
| 227 source->AddString("updateObsoleteSystem", | 201 localized_strings->SetString( |
| 228 ObsoleteSystemMac::LocalizedObsoleteSystemString()); | 202 "updateObsoleteSystem", |
| 229 source->AddString("updateObsoleteSystemURL", | 203 ObsoleteSystemMac::LocalizedObsoleteSystemString()); |
| 230 chrome::kMac32BitDeprecationURL); | 204 localized_strings->SetString( |
| 205 "updateObsoleteSystemURL", |
| 206 chrome::kMac32BitDeprecationURL); |
| 231 #endif | 207 #endif |
| 232 | 208 |
| 233 source->AddString( | 209 localized_strings->SetString( |
| 234 "browserVersion", | 210 "browserVersion", |
| 235 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, | 211 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, |
| 236 BuildBrowserVersionString())); | 212 help_utils::BuildBrowserVersionString())); |
| 237 | 213 |
| 238 base::Time::Exploded exploded_time; | 214 base::Time::Exploded exploded_time; |
| 239 base::Time::Now().LocalExplode(&exploded_time); | 215 base::Time::Now().LocalExplode(&exploded_time); |
| 240 source->AddString( | 216 localized_strings->SetString( |
| 241 "productCopyright", | 217 "productCopyright", |
| 242 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT, | 218 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT, |
| 243 base::IntToString16(exploded_time.year))); | 219 base::IntToString16(exploded_time.year))); |
| 244 | 220 |
| 245 base::string16 license = l10n_util::GetStringFUTF16( | 221 base::string16 license = l10n_util::GetStringFUTF16( |
| 246 IDS_ABOUT_VERSION_LICENSE, | 222 IDS_ABOUT_VERSION_LICENSE, |
| 247 base::ASCIIToUTF16(chrome::kChromiumProjectURL), | 223 base::ASCIIToUTF16(chrome::kChromiumProjectURL), |
| 248 base::ASCIIToUTF16(chrome::kChromeUICreditsURL)); | 224 base::ASCIIToUTF16(chrome::kChromeUICreditsURL)); |
| 249 source->AddString("productLicense", license); | 225 localized_strings->SetString("productLicense", license); |
| 250 | 226 |
| 251 #if defined(OS_CHROMEOS) | 227 #if defined(OS_CHROMEOS) |
| 252 base::string16 os_license = l10n_util::GetStringFUTF16( | 228 base::string16 os_license = l10n_util::GetStringFUTF16( |
| 253 IDS_ABOUT_CROS_VERSION_LICENSE, | 229 IDS_ABOUT_CROS_VERSION_LICENSE, |
| 254 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); | 230 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); |
| 255 source->AddString("productOsLicense", os_license); | 231 localized_strings->SetString("productOsLicense", os_license); |
| 256 | 232 |
| 257 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); | 233 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); |
| 258 source->AddString( | 234 localized_strings->SetString( |
| 259 "channelChangePageDelayedChangeMessage", | 235 "channelChangePageDelayedChangeMessage", |
| 260 l10n_util::GetStringFUTF16( | 236 l10n_util::GetStringFUTF16( |
| 261 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE, | 237 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE, |
| 262 product_name)); | 238 product_name)); |
| 263 source->AddString( | 239 localized_strings->SetString( |
| 264 "channelChangePageUnstableMessage", | 240 "channelChangePageUnstableMessage", |
| 265 l10n_util::GetStringFUTF16( | 241 l10n_util::GetStringFUTF16( |
| 266 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE, | 242 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE, |
| 267 product_name)); | 243 product_name)); |
| 268 | 244 |
| 269 if (CommandLine::ForCurrentProcess()-> | 245 if (CommandLine::ForCurrentProcess()-> |
| 270 HasSwitch(chromeos::switches::kDisableNewChannelSwitcherUI)) { | 246 HasSwitch(chromeos::switches::kDisableNewChannelSwitcherUI)) { |
| 271 source->AddBoolean("disableNewChannelSwitcherUI", true); | 247 localized_strings->SetBoolean("disableNewChannelSwitcherUI", true); |
| 272 } | 248 } |
| 273 #endif | 249 #endif |
| 274 | 250 |
| 275 base::string16 tos = l10n_util::GetStringFUTF16( | 251 base::string16 tos = l10n_util::GetStringFUTF16( |
| 276 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL)); | 252 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL)); |
| 277 source->AddString("productTOS", tos); | 253 localized_strings->SetString("productTOS", tos); |
| 278 | 254 |
| 279 source->AddString("webkitVersion", content::GetWebKitVersion()); | 255 localized_strings->SetString("webkitVersion", content::GetWebKitVersion()); |
| 280 | 256 |
| 281 source->AddString("jsEngine", "V8"); | 257 localized_strings->SetString("jsEngine", "V8"); |
| 282 source->AddString("jsEngineVersion", v8::V8::GetVersion()); | 258 localized_strings->SetString("jsEngineVersion", v8::V8::GetVersion()); |
| 283 | 259 |
| 284 source->AddString("userAgentInfo", GetUserAgent()); | 260 localized_strings->SetString("userAgentInfo", GetUserAgent()); |
| 285 | 261 |
| 286 CommandLine::StringType command_line = | 262 CommandLine::StringType command_line = |
| 287 CommandLine::ForCurrentProcess()->GetCommandLineString(); | 263 CommandLine::ForCurrentProcess()->GetCommandLineString(); |
| 288 source->AddString("commandLineInfo", command_line); | 264 localized_strings->SetString("commandLineInfo", command_line); |
| 289 } | 265 } |
| 290 | 266 |
| 291 void HelpHandler::RegisterMessages() { | 267 void HelpHandler::RegisterMessages() { |
| 292 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, | 268 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, |
| 293 content::NotificationService::AllSources()); | 269 content::NotificationService::AllSources()); |
| 294 | 270 |
| 295 web_ui()->RegisterMessageCallback("onPageLoaded", | 271 web_ui()->RegisterMessageCallback("onPageLoaded", |
| 296 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); | 272 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); |
| 297 web_ui()->RegisterMessageCallback("relaunchNow", | 273 web_ui()->RegisterMessageCallback("relaunchNow", |
| 298 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); | 274 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 web_ui()->CallJavascriptFunction( | 523 web_ui()->CallJavascriptFunction( |
| 548 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 524 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
| 549 } | 525 } |
| 550 | 526 |
| 551 void HelpHandler::OnTargetChannel(const std::string& channel) { | 527 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 552 web_ui()->CallJavascriptFunction( | 528 web_ui()->CallJavascriptFunction( |
| 553 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 529 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
| 554 } | 530 } |
| 555 | 531 |
| 556 #endif // defined(OS_CHROMEOS) | 532 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |