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

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

Powered by Google App Engine
This is Rietveld 408576698