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" | |
14 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
15 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
16 #include "base/values.h" | 15 #include "base/values.h" |
17 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
19 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_commands.h" | 19 #include "chrome/browser/ui/browser_commands.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/chrome_pages.h" | 21 #include "chrome/browser/ui/chrome_pages.h" |
23 #include "chrome/common/chrome_content_client.h" | 22 #include "chrome/common/chrome_content_client.h" |
24 #include "chrome/common/chrome_version_info.h" | |
25 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
26 #include "chrome/common/url_constants.h" | 24 #include "chrome/common/url_constants.h" |
27 #include "components/google/core/browser/google_util.h" | 25 #include "components/google/core/browser/google_util.h" |
28 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
29 #include "content/public/browser/notification_service.h" | 27 #include "content/public/browser/notification_service.h" |
30 #include "content/public/browser/web_ui.h" | 28 #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" | 29 #include "content/public/common/user_agent.h" |
33 #include "grit/chromium_strings.h" | 30 #include "grit/chromium_strings.h" |
34 #include "grit/generated_resources.h" | 31 #include "grit/generated_resources.h" |
35 #include "grit/google_chrome_strings.h" | 32 #include "grit/google_chrome_strings.h" |
36 #include "ui/base/l10n/l10n_util.h" | 33 #include "ui/base/l10n/l10n_util.h" |
37 #include "v8/include/v8.h" | 34 #include "v8/include/v8.h" |
38 | 35 |
39 #if defined(OS_MACOSX) | 36 #if defined(OS_MACOSX) |
40 #include "chrome/browser/mac/obsolete_system.h" | 37 #include "chrome/browser/mac/obsolete_system.h" |
41 #endif | 38 #endif |
(...skipping 11 matching lines...) Expand all Loading... |
53 #include "chromeos/chromeos_switches.h" | 50 #include "chromeos/chromeos_switches.h" |
54 #include "chromeos/dbus/dbus_thread_manager.h" | 51 #include "chromeos/dbus/dbus_thread_manager.h" |
55 #include "chromeos/dbus/power_manager_client.h" | 52 #include "chromeos/dbus/power_manager_client.h" |
56 #endif | 53 #endif |
57 | 54 |
58 using base::ListValue; | 55 using base::ListValue; |
59 using content::BrowserThread; | 56 using content::BrowserThread; |
60 | 57 |
61 namespace { | 58 namespace { |
62 | 59 |
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) | 60 #if defined(OS_CHROMEOS) |
88 | 61 |
89 // Returns message that informs user that for update it's better to | 62 // Returns message that informs user that for update it's better to |
90 // connect to a network of one of the allowed types. | 63 // connect to a network of one of the allowed types. |
91 base::string16 GetAllowedConnectionTypesMessage() { | 64 base::string16 GetAllowedConnectionTypesMessage() { |
92 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { | 65 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { |
93 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); | 66 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); |
94 } else { | 67 } else { |
95 return l10n_util::GetStringUTF16( | 68 return l10n_util::GetStringUTF16( |
96 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); | 69 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } // namespace | 110 } // namespace |
138 | 111 |
139 HelpHandler::HelpHandler() | 112 HelpHandler::HelpHandler() |
140 : version_updater_(VersionUpdater::Create()), | 113 : version_updater_(VersionUpdater::Create()), |
141 weak_factory_(this) { | 114 weak_factory_(this) { |
142 } | 115 } |
143 | 116 |
144 HelpHandler::~HelpHandler() { | 117 HelpHandler::~HelpHandler() { |
145 } | 118 } |
146 | 119 |
147 void HelpHandler::GetLocalizedValues(content::WebUIDataSource* source) { | 120 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) { |
148 struct L10nResources { | 121 struct L10nResources { |
149 const char* name; | 122 const char* name; |
150 int ids; | 123 int ids; |
151 }; | 124 }; |
152 | 125 |
153 static L10nResources resources[] = { | 126 static L10nResources resources[] = { |
154 { "aboutTitle", IDS_ABOUT_TITLE }, | 127 { "aboutTitle", IDS_ABOUT_TITLE }, |
155 #if defined(OS_CHROMEOS) | 128 #if defined(OS_CHROMEOS) |
156 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, | 129 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, |
157 #else | 130 #else |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, | 185 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, |
213 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, | 186 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, |
214 #endif | 187 #endif |
215 #if defined(OS_MACOSX) | 188 #if defined(OS_MACOSX) |
216 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, | 189 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, |
217 { "learnMore", IDS_LEARN_MORE }, | 190 { "learnMore", IDS_LEARN_MORE }, |
218 #endif | 191 #endif |
219 }; | 192 }; |
220 | 193 |
221 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { | 194 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { |
222 source->AddString(resources[i].name, | 195 localized_strings->SetString(resources[i].name, |
223 l10n_util::GetStringUTF16(resources[i].ids)); | 196 l10n_util::GetStringUTF16(resources[i].ids)); |
224 } | 197 } |
225 | 198 |
226 #if defined(OS_MACOSX) | 199 #if defined(OS_MACOSX) |
227 source->AddString("updateObsoleteSystem", | 200 localized_strings->SetString( |
228 ObsoleteSystemMac::LocalizedObsoleteSystemString()); | 201 "updateObsoleteSystem", |
229 source->AddString("updateObsoleteSystemURL", | 202 ObsoleteSystemMac::LocalizedObsoleteSystemString()); |
230 chrome::kMac32BitDeprecationURL); | 203 localized_strings->SetString( |
| 204 "updateObsoleteSystemURL", |
| 205 chrome::kMac32BitDeprecationURL); |
231 #endif | 206 #endif |
232 | 207 |
233 source->AddString( | 208 localized_strings->SetString( |
234 "browserVersion", | 209 "browserVersion", |
235 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, | 210 l10n_util::GetStringFUTF16( |
236 BuildBrowserVersionString())); | 211 IDS_ABOUT_PRODUCT_VERSION, |
| 212 help_utils_chromeos::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 |