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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/webui/help/help_handler.h"
9 #include "base/basictypes.h"
10 #include "base/bind.h"
11 #include "base/bind_helpers.h"
12 #include "base/command_line.h"
13 #include "base/files/file_util.h"
14 #include "base/location.h"
15 #include "base/strings/string16.h"
16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h"
19 #include "base/task_runner_util.h"
20 #include "base/values.h"
21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/chrome_notification_types.h"
23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_commands.h"
25 #include "chrome/browser/ui/browser_finder.h"
26 #include "chrome/browser/ui/chrome_pages.h"
27 #include "chrome/common/chrome_content_client.h"
28 #include "chrome/common/chrome_version_info.h"
29 #include "chrome/common/pref_names.h"
30 #include "chrome/common/url_constants.h"
31 #include "chrome/grit/chromium_strings.h"
32 #include "chrome/grit/generated_resources.h"
33 #include "components/google/core/browser/google_util.h"
34 #include "content/public/browser/browser_thread.h"
35 #include "content/public/browser/notification_service.h"
36 #include "content/public/browser/web_contents.h"
37 #include "content/public/browser/web_ui.h"
38 #include "content/public/common/user_agent.h"
39 #include "grit/components_strings.h"
40 #include "ui/base/l10n/l10n_util.h"
41 #include "v8/include/v8.h"
43 #if defined(OS_MACOSX)
44 #include "chrome/browser/mac/obsolete_system.h"
47 #if defined(OS_CHROMEOS)
48 #include "base/files/file_util_proxy.h"
49 #include "base/i18n/time_formatting.h"
50 #include "base/prefs/pref_service.h"
51 #include "base/sys_info.h"
52 #include "base/task_runner_util.h"
53 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
54 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
55 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
56 #include "chrome/browser/chromeos/profiles/profile_helper.h"
57 #include "chrome/browser/chromeos/settings/cros_settings.h"
58 #include "chrome/browser/profiles/profile.h"
59 #include "chrome/browser/ui/webui/chromeos/image_source.h"
60 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
61 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
62 #include "chromeos/chromeos_switches.h"
63 #include "chromeos/dbus/dbus_thread_manager.h"
64 #include "chromeos/dbus/power_manager_client.h"
65 #include "components/user_manager/user_manager.h"
68 using base::ListValue
;
69 using content::BrowserThread
;
73 #if defined(OS_CHROMEOS)
75 const char kFCCLabelTextPath
[] = "fcc/label.txt";
77 // Returns message that informs user that for update it's better to
78 // connect to a network of one of the allowed types.
79 base::string16
GetAllowedConnectionTypesMessage() {
80 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) {
81 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED
);
83 return l10n_util::GetStringUTF16(
84 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED
);
88 // Returns true if the device is enterprise managed, false otherwise.
89 bool IsEnterpriseManaged() {
90 policy::BrowserPolicyConnectorChromeOS
* connector
=
91 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
92 return connector
->IsEnterpriseManaged();
95 // Returns true if current user can change channel, false otherwise.
96 bool CanChangeChannel(Profile
* profile
) {
98 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated
,
101 // On a managed machine we delegate this setting to the users of the same
102 // domain only if the policy value is "domain".
103 if (IsEnterpriseManaged()) {
106 // Get the currently logged in user and strip the domain part only.
107 std::string domain
= "";
108 const user_manager::User
* user
=
109 profile
? chromeos::ProfileHelper::Get()->GetUserByProfile(profile
)
111 std::string email
= user
? user
->email() : std::string();
112 size_t at_pos
= email
.find('@');
113 if (at_pos
!= std::string::npos
&& at_pos
+ 1 < email
.length())
114 domain
= email
.substr(email
.find('@') + 1);
115 policy::BrowserPolicyConnectorChromeOS
* connector
=
116 g_browser_process
->platform_part()->browser_policy_connector_chromeos();
117 return domain
== connector
->GetEnterpriseDomain();
119 chromeos::OwnerSettingsServiceChromeOS
* service
=
120 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance()
121 ->GetForBrowserContext(profile
);
122 // On non managed machines we have local owner who is the only one to change
123 // anything. Ensure that ReleaseChannelDelegated is false.
124 if (service
&& service
->IsOwner())
130 // Reads the file containing the FCC label text, if found. Must be called from
131 // the blocking pool.
132 std::string
ReadFCCLabelText() {
133 const base::FilePath
asset_dir(FILE_PATH_LITERAL(chrome::kChromeOSAssetPath
));
134 const base::FilePath label_file_path
=
135 asset_dir
.AppendASCII(kFCCLabelTextPath
);
137 std::string contents
;
138 if (base::ReadFileToString(label_file_path
, &contents
))
140 return std::string();
143 #endif // defined(OS_CHROMEOS)
147 HelpHandler::HelpHandler()
148 : weak_factory_(this) {
151 HelpHandler::~HelpHandler() {
154 void HelpHandler::GetLocalizedValues(base::DictionaryValue
* localized_strings
) {
155 struct L10nResources
{
160 static L10nResources resources
[] = {
161 { "aboutTitle", IDS_ABOUT_TITLE
},
162 #if defined(OS_CHROMEOS)
163 { "aboutProductTitle", IDS_PRODUCT_OS_NAME
},
165 { "aboutProductTitle", IDS_PRODUCT_NAME
},
167 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION
},
168 { "relaunch", IDS_RELAUNCH_BUTTON
},
169 #if defined(OS_CHROMEOS)
170 { "relaunchAndPowerwash", IDS_RELAUNCH_AND_POWERWASH_BUTTON
},
172 { "productName", IDS_PRODUCT_NAME
},
173 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED
},
174 { "upToDate", IDS_UPGRADE_UP_TO_DATE
},
175 { "updating", IDS_UPGRADE_UPDATING
},
176 #if defined(OS_CHROMEOS)
177 { "updateButton", IDS_UPGRADE_BUTTON
},
178 { "updatingChannelSwitch", IDS_UPGRADE_UPDATING_CHANNEL_SWITCH
},
180 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH
},
181 #if defined(OS_CHROMEOS)
182 { "successfulChannelSwitch", IDS_UPGRADE_SUCCESSFUL_CHANNEL_SWITCH
},
184 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME
},
185 { "reportAnIssue", IDS_REPORT_AN_ISSUE
},
186 #if defined(OS_CHROMEOS)
187 { "platform", IDS_PLATFORM_LABEL
},
188 { "firmware", IDS_ABOUT_PAGE_FIRMWARE
},
189 { "showMoreInfo", IDS_SHOW_MORE_INFO
},
190 { "hideMoreInfo", IDS_HIDE_MORE_INFO
},
191 { "channel", IDS_ABOUT_PAGE_CHANNEL
},
192 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE
},
193 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA
},
194 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT
},
195 { "channel-changed", IDS_ABOUT_PAGE_CHANNEL_CHANGED
},
196 { "currentChannelStable", IDS_ABOUT_PAGE_CURRENT_CHANNEL_STABLE
},
197 { "currentChannelBeta", IDS_ABOUT_PAGE_CURRENT_CHANNEL_BETA
},
198 { "currentChannelDev", IDS_ABOUT_PAGE_CURRENT_CHANNEL_DEV
},
199 { "currentChannel", IDS_ABOUT_PAGE_CURRENT_CHANNEL
},
200 { "channelChangeButton", IDS_ABOUT_PAGE_CHANNEL_CHANGE_BUTTON
},
201 { "channelChangeDisallowedMessage",
202 IDS_ABOUT_PAGE_CHANNEL_CHANGE_DISALLOWED_MESSAGE
},
203 { "channelChangePageTitle", IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_TITLE
},
204 { "channelChangePagePowerwashTitle",
205 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_TITLE
},
206 { "channelChangePagePowerwashMessage",
207 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_MESSAGE
},
208 { "channelChangePageDelayedChangeTitle",
209 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_TITLE
},
210 { "channelChangePageUnstableTitle",
211 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_TITLE
},
212 { "channelChangePagePowerwashButton",
213 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_BUTTON
},
214 { "channelChangePageChangeButton",
215 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CHANGE_BUTTON
},
216 { "channelChangePageCancelButton",
217 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CANCEL_BUTTON
},
218 { "webkit", IDS_WEBKIT
},
219 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT
},
220 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE
},
221 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE
},
223 #if defined(OS_MACOSX)
224 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER
},
225 { "learnMore", IDS_LEARN_MORE
},
229 for (size_t i
= 0; i
< arraysize(resources
); ++i
) {
230 localized_strings
->SetString(resources
[i
].name
,
231 l10n_util::GetStringUTF16(resources
[i
].ids
));
234 #if defined(OS_MACOSX)
235 localized_strings
->SetString(
236 "updateObsoleteSystem",
237 ObsoleteSystemMac::LocalizedObsoleteSystemString());
238 localized_strings
->SetString(
239 "updateObsoleteSystemURL",
240 chrome::kMac32BitDeprecationURL
);
243 localized_strings
->SetString(
245 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION
,
246 BuildBrowserVersionString()));
248 base::Time::Exploded exploded_time
;
249 base::Time::Now().LocalExplode(&exploded_time
);
250 localized_strings
->SetString(
252 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT
,
253 base::IntToString16(exploded_time
.year
)));
255 base::string16 license
= l10n_util::GetStringFUTF16(
256 IDS_ABOUT_VERSION_LICENSE
,
257 base::ASCIIToUTF16(chrome::kChromiumProjectURL
),
258 base::ASCIIToUTF16(chrome::kChromeUICreditsURL
));
259 localized_strings
->SetString("productLicense", license
);
261 #if defined(OS_CHROMEOS)
262 base::string16 os_license
= l10n_util::GetStringFUTF16(
263 IDS_ABOUT_CROS_VERSION_LICENSE
,
264 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL
));
265 localized_strings
->SetString("productOsLicense", os_license
);
267 base::string16 product_name
= l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME
);
268 localized_strings
->SetString(
269 "channelChangePageDelayedChangeMessage",
270 l10n_util::GetStringFUTF16(
271 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE
,
273 localized_strings
->SetString(
274 "channelChangePageUnstableMessage",
275 l10n_util::GetStringFUTF16(
276 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE
,
279 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
280 chromeos::switches::kDisableNewChannelSwitcherUI
)) {
281 localized_strings
->SetBoolean("disableNewChannelSwitcherUI", true);
285 base::string16 tos
= l10n_util::GetStringFUTF16(
286 IDS_ABOUT_TERMS_OF_SERVICE
, base::UTF8ToUTF16(chrome::kChromeUITermsURL
));
287 localized_strings
->SetString("productTOS", tos
);
289 localized_strings
->SetString("webkitVersion", content::GetWebKitVersion());
291 localized_strings
->SetString("jsEngine", "V8");
292 localized_strings
->SetString("jsEngineVersion", v8::V8::GetVersion());
294 localized_strings
->SetString("userAgentInfo", GetUserAgent());
296 base::CommandLine::StringType command_line
=
297 base::CommandLine::ForCurrentProcess()->GetCommandLineString();
298 localized_strings
->SetString("commandLineInfo", command_line
);
301 void HelpHandler::RegisterMessages() {
302 version_updater_
.reset(VersionUpdater::Create(web_ui()->GetWebContents()));
303 registrar_
.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED
,
304 content::NotificationService::AllSources());
306 web_ui()->RegisterMessageCallback("onPageLoaded",
307 base::Bind(&HelpHandler::OnPageLoaded
, base::Unretained(this)));
308 web_ui()->RegisterMessageCallback("relaunchNow",
309 base::Bind(&HelpHandler::RelaunchNow
, base::Unretained(this)));
310 web_ui()->RegisterMessageCallback("openFeedbackDialog",
311 base::Bind(&HelpHandler::OpenFeedbackDialog
, base::Unretained(this)));
312 web_ui()->RegisterMessageCallback("openHelpPage",
313 base::Bind(&HelpHandler::OpenHelpPage
, base::Unretained(this)));
314 #if defined(OS_CHROMEOS)
315 web_ui()->RegisterMessageCallback("setChannel",
316 base::Bind(&HelpHandler::SetChannel
, base::Unretained(this)));
317 web_ui()->RegisterMessageCallback("relaunchAndPowerwash",
318 base::Bind(&HelpHandler::RelaunchAndPowerwash
, base::Unretained(this)));
319 web_ui()->RegisterMessageCallback("requestUpdate",
320 base::Bind(&HelpHandler::RequestUpdate
, base::Unretained(this)));
322 #if defined(OS_MACOSX)
323 web_ui()->RegisterMessageCallback("promoteUpdater",
324 base::Bind(&HelpHandler::PromoteUpdater
, base::Unretained(this)));
327 #if defined(OS_CHROMEOS)
328 // Handler for the product label image, which will be shown if available.
329 content::URLDataSource::Add(Profile::FromWebUI(web_ui()),
330 new chromeos::ImageSource());
334 void HelpHandler::Observe(int type
, const content::NotificationSource
& source
,
335 const content::NotificationDetails
& details
) {
337 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED
: {
338 // A version update is installed and ready to go. Refresh the UI so the
339 // correct state will be shown.
349 base::string16
HelpHandler::BuildBrowserVersionString() {
350 chrome::VersionInfo version_info
;
352 std::string version
= version_info
.Version();
354 std::string modifier
= chrome::VersionInfo::GetVersionStringModifier();
355 if (!modifier
.empty())
356 version
+= " " + modifier
;
358 #if defined(ARCH_CPU_64_BITS)
359 version
+= " (64-bit)";
362 return base::UTF8ToUTF16(version
);
365 void HelpHandler::OnPageLoaded(const base::ListValue
* args
) {
366 #if defined(OS_CHROMEOS)
367 base::PostTaskAndReplyWithResult(
368 content::BrowserThread::GetBlockingPool(),
370 base::Bind(&chromeos::version_loader::GetVersion
,
371 chromeos::version_loader::VERSION_FULL
),
372 base::Bind(&HelpHandler::OnOSVersion
,
373 weak_factory_
.GetWeakPtr()));
374 base::PostTaskAndReplyWithResult(
375 content::BrowserThread::GetBlockingPool(),
377 base::Bind(&chromeos::version_loader::GetFirmware
),
378 base::Bind(&HelpHandler::OnOSFirmware
,
379 weak_factory_
.GetWeakPtr()));
381 web_ui()->CallJavascriptFunction(
382 "help.HelpPage.updateEnableReleaseChannel",
383 base::FundamentalValue(CanChangeChannel(Profile::FromWebUI(web_ui()))));
385 base::Time build_time
= base::SysInfo::GetLsbReleaseTime();
386 base::string16 build_date
= base::TimeFormatFriendlyDate(build_time
);
387 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate",
388 base::StringValue(build_date
));
389 #endif // defined(OS_CHROMEOS)
391 // On Chrome OS, do not check for an update automatically.
392 #if defined(OS_CHROMEOS)
393 static_cast<VersionUpdaterCros
*>(version_updater_
.get())->GetUpdateStatus(
394 base::Bind(&HelpHandler::SetUpdateStatus
, base::Unretained(this)));
399 #if defined(OS_MACOSX)
400 web_ui()->CallJavascriptFunction(
401 "help.HelpPage.setObsoleteSystem",
402 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() &&
403 ObsoleteSystemMac::Has32BitOnlyCPU()));
404 web_ui()->CallJavascriptFunction(
405 "help.HelpPage.setObsoleteSystemEndOfTheLine",
406 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() &&
407 ObsoleteSystemMac::Is32BitEndOfTheLine()));
410 #if defined(OS_CHROMEOS)
411 web_ui()->CallJavascriptFunction(
412 "help.HelpPage.updateIsEnterpriseManaged",
413 base::FundamentalValue(IsEnterpriseManaged()));
414 // First argument to GetChannel() is a flag that indicates whether
415 // current channel should be returned (if true) or target channel
417 version_updater_
->GetChannel(true,
418 base::Bind(&HelpHandler::OnCurrentChannel
, weak_factory_
.GetWeakPtr()));
419 version_updater_
->GetChannel(false,
420 base::Bind(&HelpHandler::OnTargetChannel
, weak_factory_
.GetWeakPtr()));
422 base::PostTaskAndReplyWithResult(
423 content::BrowserThread::GetBlockingPool(),
425 base::Bind(&ReadFCCLabelText
),
426 base::Bind(&HelpHandler::OnFCCLabelTextRead
,
427 weak_factory_
.GetWeakPtr()));
431 #if defined(OS_MACOSX)
432 void HelpHandler::PromoteUpdater(const base::ListValue
* args
) {
433 version_updater_
->PromoteUpdater();
437 void HelpHandler::RelaunchNow(const base::ListValue
* args
) {
438 DCHECK(args
->empty());
439 version_updater_
->RelaunchBrowser();
442 void HelpHandler::OpenFeedbackDialog(const base::ListValue
* args
) {
443 DCHECK(args
->empty());
444 Browser
* browser
= chrome::FindBrowserWithWebContents(
445 web_ui()->GetWebContents());
446 chrome::OpenFeedbackDialog(browser
);
449 void HelpHandler::OpenHelpPage(const base::ListValue
* args
) {
450 DCHECK(args
->empty());
451 Browser
* browser
= chrome::FindBrowserWithWebContents(
452 web_ui()->GetWebContents());
453 chrome::ShowHelp(browser
, chrome::HELP_SOURCE_WEBUI
);
456 #if defined(OS_CHROMEOS)
458 void HelpHandler::SetChannel(const base::ListValue
* args
) {
459 DCHECK(args
->GetSize() == 2);
461 if (!CanChangeChannel(Profile::FromWebUI(web_ui()))) {
462 LOG(WARNING
) << "Non-owner tried to change release track.";
466 base::string16 channel
;
467 bool is_powerwash_allowed
;
468 if (!args
->GetString(0, &channel
) ||
469 !args
->GetBoolean(1, &is_powerwash_allowed
)) {
470 LOG(ERROR
) << "Can't parse SetChannel() args";
474 version_updater_
->SetChannel(base::UTF16ToUTF8(channel
),
475 is_powerwash_allowed
);
476 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
477 // Check for update after switching release channel.
478 version_updater_
->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus
,
479 base::Unretained(this)));
483 void HelpHandler::RelaunchAndPowerwash(const base::ListValue
* args
) {
484 DCHECK(args
->empty());
486 if (IsEnterpriseManaged())
489 PrefService
* prefs
= g_browser_process
->local_state();
490 prefs
->SetBoolean(prefs::kFactoryResetRequested
, true);
491 prefs
->CommitPendingWrite();
493 // Perform sign out. Current chrome process will then terminate, new one will
494 // be launched (as if it was a restart).
495 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
498 #endif // defined(OS_CHROMEOS)
500 void HelpHandler::RequestUpdate(const base::ListValue
* args
) {
501 version_updater_
->CheckForUpdate(
502 base::Bind(&HelpHandler::SetUpdateStatus
, base::Unretained(this))
503 #if defined(OS_MACOSX)
504 , base::Bind(&HelpHandler::SetPromotionState
, base::Unretained(this))
509 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status
,
510 int progress
, const base::string16
& message
) {
511 // Only UPDATING state should have progress set.
512 DCHECK(status
== VersionUpdater::UPDATING
|| progress
== 0);
514 std::string status_str
;
516 case VersionUpdater::CHECKING
:
517 status_str
= "checking";
519 case VersionUpdater::UPDATING
:
520 status_str
= "updating";
522 case VersionUpdater::NEARLY_UPDATED
:
523 status_str
= "nearly_updated";
525 case VersionUpdater::UPDATED
:
526 status_str
= "updated";
528 case VersionUpdater::FAILED
:
529 case VersionUpdater::FAILED_OFFLINE
:
530 case VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED
:
531 status_str
= "failed";
533 case VersionUpdater::DISABLED
:
534 status_str
= "disabled";
538 web_ui()->CallJavascriptFunction("help.HelpPage.setUpdateStatus",
539 base::StringValue(status_str
),
540 base::StringValue(message
));
542 if (status
== VersionUpdater::UPDATING
) {
543 web_ui()->CallJavascriptFunction("help.HelpPage.setProgress",
544 base::FundamentalValue(progress
));
547 #if defined(OS_CHROMEOS)
548 if (status
== VersionUpdater::FAILED_OFFLINE
||
549 status
== VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED
) {
550 base::string16 types_msg
= GetAllowedConnectionTypesMessage();
551 if (!types_msg
.empty()) {
552 web_ui()->CallJavascriptFunction(
553 "help.HelpPage.setAndShowAllowedConnectionTypesMsg",
554 base::StringValue(types_msg
));
556 web_ui()->CallJavascriptFunction(
557 "help.HelpPage.showAllowedConnectionTypesMsg",
558 base::FundamentalValue(false));
561 web_ui()->CallJavascriptFunction(
562 "help.HelpPage.showAllowedConnectionTypesMsg",
563 base::FundamentalValue(false));
565 #endif // defined(OS_CHROMEOS)
568 #if defined(OS_MACOSX)
569 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state
) {
570 std::string state_str
;
572 case VersionUpdater::PROMOTE_HIDDEN
:
573 state_str
= "hidden";
575 case VersionUpdater::PROMOTE_ENABLED
:
576 state_str
= "enabled";
578 case VersionUpdater::PROMOTE_DISABLED
:
579 state_str
= "disabled";
583 web_ui()->CallJavascriptFunction("help.HelpPage.setPromotionState",
584 base::StringValue(state_str
));
586 #endif // defined(OS_MACOSX)
588 #if defined(OS_CHROMEOS)
589 void HelpHandler::OnOSVersion(const std::string
& version
) {
590 web_ui()->CallJavascriptFunction("help.HelpPage.setOSVersion",
591 base::StringValue(version
));
594 void HelpHandler::OnOSFirmware(const std::string
& firmware
) {
595 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware",
596 base::StringValue(firmware
));
599 void HelpHandler::OnCurrentChannel(const std::string
& channel
) {
600 web_ui()->CallJavascriptFunction(
601 "help.HelpPage.updateCurrentChannel", base::StringValue(channel
));
604 void HelpHandler::OnTargetChannel(const std::string
& channel
) {
605 web_ui()->CallJavascriptFunction(
606 "help.HelpPage.updateTargetChannel", base::StringValue(channel
));
609 void HelpHandler::OnFCCLabelTextRead(const std::string
& text
) {
610 // Remove unnecessary whitespace.
611 web_ui()->CallJavascriptFunction(
612 "help.HelpPage.setProductLabelText",
613 base::StringValue(base::CollapseWhitespaceASCII(text
, true)));
616 #endif // defined(OS_CHROMEOS)