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

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

Issue 449623003: Integrate About page into Settings for Chrome OS settings in a window. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/webui/help/help_handler.h ('k') | chrome/browser/ui/webui/help/help_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
(...skipping 10 matching lines...) Expand all
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/common/chrome_content_client.h" 23 #include "chrome/common/chrome_content_client.h"
24 #include "chrome/common/chrome_version_info.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
(...skipping 11 matching lines...) Expand all
53 #include "chromeos/chromeos_switches.h" 52 #include "chromeos/chromeos_switches.h"
54 #include "chromeos/dbus/dbus_thread_manager.h" 53 #include "chromeos/dbus/dbus_thread_manager.h"
55 #include "chromeos/dbus/power_manager_client.h" 54 #include "chromeos/dbus/power_manager_client.h"
56 #endif 55 #endif
57 56
58 using base::ListValue; 57 using base::ListValue;
59 using content::BrowserThread; 58 using content::BrowserThread;
60 59
61 namespace { 60 namespace {
62 61
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) 62 #if defined(OS_CHROMEOS)
88 63
89 // Returns message that informs user that for update it's better to 64 // Returns message that informs user that for update it's better to
90 // connect to a network of one of the allowed types. 65 // connect to a network of one of the allowed types.
91 base::string16 GetAllowedConnectionTypesMessage() { 66 base::string16 GetAllowedConnectionTypesMessage() {
92 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) { 67 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) {
93 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED); 68 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED);
94 } else { 69 } else {
95 return l10n_util::GetStringUTF16( 70 return l10n_util::GetStringUTF16(
96 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED); 71 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 } // namespace 112 } // namespace
138 113
139 HelpHandler::HelpHandler() 114 HelpHandler::HelpHandler()
140 : version_updater_(VersionUpdater::Create()), 115 : version_updater_(VersionUpdater::Create()),
141 weak_factory_(this) { 116 weak_factory_(this) {
142 } 117 }
143 118
144 HelpHandler::~HelpHandler() { 119 HelpHandler::~HelpHandler() {
145 } 120 }
146 121
147 void HelpHandler::GetLocalizedValues(content::WebUIDataSource* source) { 122 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) {
148 struct L10nResources { 123 struct L10nResources {
149 const char* name; 124 const char* name;
150 int ids; 125 int ids;
151 }; 126 };
152 127
153 static L10nResources resources[] = { 128 static L10nResources resources[] = {
154 { "aboutTitle", IDS_ABOUT_TITLE }, 129 { "aboutTitle", IDS_ABOUT_TITLE },
155 #if defined(OS_CHROMEOS) 130 #if defined(OS_CHROMEOS)
156 { "aboutProductTitle", IDS_PRODUCT_OS_NAME }, 131 { "aboutProductTitle", IDS_PRODUCT_OS_NAME },
157 #else 132 #else
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE }, 187 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE },
213 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE }, 188 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE },
214 #endif 189 #endif
215 #if defined(OS_MACOSX) 190 #if defined(OS_MACOSX)
216 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER }, 191 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER },
217 { "learnMore", IDS_LEARN_MORE }, 192 { "learnMore", IDS_LEARN_MORE },
218 #endif 193 #endif
219 }; 194 };
220 195
221 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) { 196 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(resources); ++i) {
222 source->AddString(resources[i].name, 197 localized_strings->SetString(resources[i].name,
223 l10n_util::GetStringUTF16(resources[i].ids)); 198 l10n_util::GetStringUTF16(resources[i].ids));
224 } 199 }
225 200
226 #if defined(OS_MACOSX) 201 #if defined(OS_MACOSX)
227 source->AddString("updateObsoleteSystem", 202 localized_strings->SetString(
228 ObsoleteSystemMac::LocalizedObsoleteSystemString()); 203 "updateObsoleteSystem",
229 source->AddString("updateObsoleteSystemURL", 204 ObsoleteSystemMac::LocalizedObsoleteSystemString());
230 chrome::kMac32BitDeprecationURL); 205 localized_strings->SetString(
206 "updateObsoleteSystemURL",
207 chrome::kMac32BitDeprecationURL);
231 #endif 208 #endif
232 209
233 source->AddString( 210 localized_strings->SetString(
234 "browserVersion", 211 "browserVersion",
235 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION, 212 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION,
236 BuildBrowserVersionString())); 213 BuildBrowserVersionString()));
237 214
238 base::Time::Exploded exploded_time; 215 base::Time::Exploded exploded_time;
239 base::Time::Now().LocalExplode(&exploded_time); 216 base::Time::Now().LocalExplode(&exploded_time);
240 source->AddString( 217 localized_strings->SetString(
241 "productCopyright", 218 "productCopyright",
242 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT, 219 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT,
243 base::IntToString16(exploded_time.year))); 220 base::IntToString16(exploded_time.year)));
244 221
245 base::string16 license = l10n_util::GetStringFUTF16( 222 base::string16 license = l10n_util::GetStringFUTF16(
246 IDS_ABOUT_VERSION_LICENSE, 223 IDS_ABOUT_VERSION_LICENSE,
247 base::ASCIIToUTF16(chrome::kChromiumProjectURL), 224 base::ASCIIToUTF16(chrome::kChromiumProjectURL),
248 base::ASCIIToUTF16(chrome::kChromeUICreditsURL)); 225 base::ASCIIToUTF16(chrome::kChromeUICreditsURL));
249 source->AddString("productLicense", license); 226 localized_strings->SetString("productLicense", license);
250 227
251 #if defined(OS_CHROMEOS) 228 #if defined(OS_CHROMEOS)
252 base::string16 os_license = l10n_util::GetStringFUTF16( 229 base::string16 os_license = l10n_util::GetStringFUTF16(
253 IDS_ABOUT_CROS_VERSION_LICENSE, 230 IDS_ABOUT_CROS_VERSION_LICENSE,
254 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL)); 231 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL));
255 source->AddString("productOsLicense", os_license); 232 localized_strings->SetString("productOsLicense", os_license);
256 233
257 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME); 234 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME);
258 source->AddString( 235 localized_strings->SetString(
259 "channelChangePageDelayedChangeMessage", 236 "channelChangePageDelayedChangeMessage",
260 l10n_util::GetStringFUTF16( 237 l10n_util::GetStringFUTF16(
261 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE, 238 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE,
262 product_name)); 239 product_name));
263 source->AddString( 240 localized_strings->SetString(
264 "channelChangePageUnstableMessage", 241 "channelChangePageUnstableMessage",
265 l10n_util::GetStringFUTF16( 242 l10n_util::GetStringFUTF16(
266 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE, 243 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE,
267 product_name)); 244 product_name));
268 245
269 if (CommandLine::ForCurrentProcess()-> 246 if (CommandLine::ForCurrentProcess()->
270 HasSwitch(chromeos::switches::kDisableNewChannelSwitcherUI)) { 247 HasSwitch(chromeos::switches::kDisableNewChannelSwitcherUI)) {
271 source->AddBoolean("disableNewChannelSwitcherUI", true); 248 localized_strings->SetBoolean("disableNewChannelSwitcherUI", true);
272 } 249 }
273 #endif 250 #endif
274 251
275 base::string16 tos = l10n_util::GetStringFUTF16( 252 base::string16 tos = l10n_util::GetStringFUTF16(
276 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL)); 253 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL));
277 source->AddString("productTOS", tos); 254 localized_strings->SetString("productTOS", tos);
278 255
279 source->AddString("webkitVersion", content::GetWebKitVersion()); 256 localized_strings->SetString("webkitVersion", content::GetWebKitVersion());
280 257
281 source->AddString("jsEngine", "V8"); 258 localized_strings->SetString("jsEngine", "V8");
282 source->AddString("jsEngineVersion", v8::V8::GetVersion()); 259 localized_strings->SetString("jsEngineVersion", v8::V8::GetVersion());
283 260
284 source->AddString("userAgentInfo", GetUserAgent()); 261 localized_strings->SetString("userAgentInfo", GetUserAgent());
285 262
286 CommandLine::StringType command_line = 263 CommandLine::StringType command_line =
287 CommandLine::ForCurrentProcess()->GetCommandLineString(); 264 CommandLine::ForCurrentProcess()->GetCommandLineString();
288 source->AddString("commandLineInfo", command_line); 265 localized_strings->SetString("commandLineInfo", command_line);
289 } 266 }
290 267
291 void HelpHandler::RegisterMessages() { 268 void HelpHandler::RegisterMessages() {
292 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED, 269 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
293 content::NotificationService::AllSources()); 270 content::NotificationService::AllSources());
294 271
295 web_ui()->RegisterMessageCallback("onPageLoaded", 272 web_ui()->RegisterMessageCallback("onPageLoaded",
296 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this))); 273 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this)));
297 web_ui()->RegisterMessageCallback("relaunchNow", 274 web_ui()->RegisterMessageCallback("relaunchNow",
298 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); 275 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this)));
(...skipping 25 matching lines...) Expand all
324 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) 301 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this))
325 #endif 302 #endif
326 ); 303 );
327 break; 304 break;
328 } 305 }
329 default: 306 default:
330 NOTREACHED(); 307 NOTREACHED();
331 } 308 }
332 } 309 }
333 310
311 // static
312 base::string16 HelpHandler::BuildBrowserVersionString() {
313 chrome::VersionInfo version_info;
314 DCHECK(version_info.is_valid());
315
316 std::string browser_version = version_info.Version();
317 std::string version_modifier =
318 chrome::VersionInfo::GetVersionStringModifier();
319 if (!version_modifier.empty())
320 browser_version += " " + version_modifier;
321
322 #if !defined(GOOGLE_CHROME_BUILD)
323 browser_version += " (";
324 browser_version += version_info.LastChange();
325 browser_version += ")";
326 #endif
327
328 #if defined(ARCH_CPU_64_BITS)
329 browser_version += " (64-bit)";
330 #endif
331
332 return base::UTF8ToUTF16(browser_version);
333 }
334
334 void HelpHandler::OnPageLoaded(const base::ListValue* args) { 335 void HelpHandler::OnPageLoaded(const base::ListValue* args) {
335 #if defined(OS_CHROMEOS) 336 #if defined(OS_CHROMEOS)
336 // Version information is loaded from a callback 337 // Version information is loaded from a callback
337 loader_.GetVersion( 338 loader_.GetVersion(
338 chromeos::VersionLoader::VERSION_FULL, 339 chromeos::VersionLoader::VERSION_FULL,
339 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)), 340 base::Bind(&HelpHandler::OnOSVersion, base::Unretained(this)),
340 &tracker_); 341 &tracker_);
341 loader_.GetFirmware( 342 loader_.GetFirmware(
342 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)), 343 base::Bind(&HelpHandler::OnOSFirmware, base::Unretained(this)),
343 &tracker_); 344 &tracker_);
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 web_ui()->CallJavascriptFunction( 548 web_ui()->CallJavascriptFunction(
548 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); 549 "help.HelpPage.updateCurrentChannel", base::StringValue(channel));
549 } 550 }
550 551
551 void HelpHandler::OnTargetChannel(const std::string& channel) { 552 void HelpHandler::OnTargetChannel(const std::string& channel) {
552 web_ui()->CallJavascriptFunction( 553 web_ui()->CallJavascriptFunction(
553 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); 554 "help.HelpPage.updateTargetChannel", base::StringValue(channel));
554 } 555 }
555 556
556 #endif // defined(OS_CHROMEOS) 557 #endif // defined(OS_CHROMEOS)
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/help/help_handler.h ('k') | chrome/browser/ui/webui/help/help_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698