Revert of Add button to add new FSP services to Files app. (patchset #8 id:140001...
[chromium-blink-merge.git] / chrome / browser / ui / webui / help / help_handler.cc
blob2e44951c045e0de95520872004fccd319a0a0efd
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"
7 #include <string>
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 "chrome/grit/google_chrome_strings.h"
34 #include "components/google/core/browser/google_util.h"
35 #include "content/public/browser/browser_thread.h"
36 #include "content/public/browser/notification_service.h"
37 #include "content/public/browser/web_contents.h"
38 #include "content/public/browser/web_ui.h"
39 #include "content/public/common/user_agent.h"
40 #include "grit/components_strings.h"
41 #include "ui/base/l10n/l10n_util.h"
42 #include "v8/include/v8.h"
44 #if defined(OS_MACOSX)
45 #include "chrome/browser/mac/obsolete_system.h"
46 #endif
48 #if defined(OS_CHROMEOS)
49 #include "base/files/file_util_proxy.h"
50 #include "base/i18n/time_formatting.h"
51 #include "base/prefs/pref_service.h"
52 #include "base/sys_info.h"
53 #include "base/task_runner_util.h"
54 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos.h"
55 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_factory.h"
56 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
57 #include "chrome/browser/chromeos/profiles/profile_helper.h"
58 #include "chrome/browser/chromeos/settings/cros_settings.h"
59 #include "chrome/browser/profiles/profile.h"
60 #include "chrome/browser/ui/webui/chromeos/image_source.h"
61 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h"
62 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h"
63 #include "chromeos/chromeos_switches.h"
64 #include "chromeos/dbus/dbus_thread_manager.h"
65 #include "chromeos/dbus/power_manager_client.h"
66 #include "components/user_manager/user_manager.h"
67 #endif
69 using base::ListValue;
70 using content::BrowserThread;
72 namespace {
74 #if defined(OS_CHROMEOS)
76 const char kFCCLabelTextPath[] = "fcc/label.txt";
78 // Returns message that informs user that for update it's better to
79 // connect to a network of one of the allowed types.
80 base::string16 GetAllowedConnectionTypesMessage() {
81 if (help_utils_chromeos::IsUpdateOverCellularAllowed()) {
82 return l10n_util::GetStringUTF16(IDS_UPGRADE_NETWORK_LIST_CELLULAR_ALLOWED);
83 } else {
84 return l10n_util::GetStringUTF16(
85 IDS_UPGRADE_NETWORK_LIST_CELLULAR_DISALLOWED);
89 // Returns true if the device is enterprise managed, false otherwise.
90 bool IsEnterpriseManaged() {
91 policy::BrowserPolicyConnectorChromeOS* connector =
92 g_browser_process->platform_part()->browser_policy_connector_chromeos();
93 return connector->IsEnterpriseManaged();
96 // Returns true if current user can change channel, false otherwise.
97 bool CanChangeChannel(Profile* profile) {
98 bool value = false;
99 chromeos::CrosSettings::Get()->GetBoolean(chromeos::kReleaseChannelDelegated,
100 &value);
102 // On a managed machine we delegate this setting to the users of the same
103 // domain only if the policy value is "domain".
104 if (IsEnterpriseManaged()) {
105 if (!value)
106 return false;
107 // Get the currently logged in user and strip the domain part only.
108 std::string domain = "";
109 const user_manager::User* user =
110 profile ? chromeos::ProfileHelper::Get()->GetUserByProfile(profile)
111 : nullptr;
112 std::string email = user ? user->email() : std::string();
113 size_t at_pos = email.find('@');
114 if (at_pos != std::string::npos && at_pos + 1 < email.length())
115 domain = email.substr(email.find('@') + 1);
116 policy::BrowserPolicyConnectorChromeOS* connector =
117 g_browser_process->platform_part()->browser_policy_connector_chromeos();
118 return domain == connector->GetEnterpriseDomain();
119 } else {
120 chromeos::OwnerSettingsServiceChromeOS* service =
121 chromeos::OwnerSettingsServiceChromeOSFactory::GetInstance()
122 ->GetForBrowserContext(profile);
123 // On non managed machines we have local owner who is the only one to change
124 // anything. Ensure that ReleaseChannelDelegated is false.
125 if (service && service->IsOwner())
126 return !value;
128 return false;
131 // Reads the file containing the FCC label text, if found. Must be called from
132 // the blocking pool.
133 std::string ReadFCCLabelText() {
134 const base::FilePath asset_dir(FILE_PATH_LITERAL(chrome::kChromeOSAssetPath));
135 const base::FilePath label_file_path =
136 asset_dir.AppendASCII(kFCCLabelTextPath);
138 std::string contents;
139 if (base::ReadFileToString(label_file_path, &contents))
140 return contents;
141 return std::string();
144 #endif // defined(OS_CHROMEOS)
146 } // namespace
148 HelpHandler::HelpHandler()
149 : version_updater_(VersionUpdater::Create(nullptr)),
150 weak_factory_(this) {
153 HelpHandler::~HelpHandler() {
156 void HelpHandler::GetLocalizedValues(base::DictionaryValue* localized_strings) {
157 struct L10nResources {
158 const char* name;
159 int ids;
162 static L10nResources resources[] = {
163 { "aboutTitle", IDS_ABOUT_TITLE },
164 #if defined(OS_CHROMEOS)
165 { "aboutProductTitle", IDS_PRODUCT_OS_NAME },
166 #else
167 { "aboutProductTitle", IDS_PRODUCT_NAME },
168 #endif
169 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION },
170 { "relaunch", IDS_RELAUNCH_BUTTON },
171 #if defined(OS_CHROMEOS)
172 { "relaunchAndPowerwash", IDS_RELAUNCH_AND_POWERWASH_BUTTON },
173 #endif
174 { "productName", IDS_PRODUCT_NAME },
175 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED },
176 { "upToDate", IDS_UPGRADE_UP_TO_DATE },
177 { "updating", IDS_UPGRADE_UPDATING },
178 #if defined(OS_CHROMEOS)
179 { "updateButton", IDS_UPGRADE_BUTTON },
180 { "updatingChannelSwitch", IDS_UPGRADE_UPDATING_CHANNEL_SWITCH },
181 #endif
182 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH },
183 #if defined(OS_CHROMEOS)
184 { "successfulChannelSwitch", IDS_UPGRADE_SUCCESSFUL_CHANNEL_SWITCH },
185 #endif
186 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME },
187 { "reportAnIssue", IDS_REPORT_AN_ISSUE },
188 #if defined(OS_CHROMEOS)
189 { "platform", IDS_PLATFORM_LABEL },
190 { "firmware", IDS_ABOUT_PAGE_FIRMWARE },
191 { "showMoreInfo", IDS_SHOW_MORE_INFO },
192 { "hideMoreInfo", IDS_HIDE_MORE_INFO },
193 { "channel", IDS_ABOUT_PAGE_CHANNEL },
194 { "stable", IDS_ABOUT_PAGE_CHANNEL_STABLE },
195 { "beta", IDS_ABOUT_PAGE_CHANNEL_BETA },
196 { "dev", IDS_ABOUT_PAGE_CHANNEL_DEVELOPMENT },
197 { "channel-changed", IDS_ABOUT_PAGE_CHANNEL_CHANGED },
198 { "currentChannelStable", IDS_ABOUT_PAGE_CURRENT_CHANNEL_STABLE },
199 { "currentChannelBeta", IDS_ABOUT_PAGE_CURRENT_CHANNEL_BETA },
200 { "currentChannelDev", IDS_ABOUT_PAGE_CURRENT_CHANNEL_DEV },
201 { "currentChannel", IDS_ABOUT_PAGE_CURRENT_CHANNEL },
202 { "channelChangeButton", IDS_ABOUT_PAGE_CHANNEL_CHANGE_BUTTON },
203 { "channelChangeDisallowedMessage",
204 IDS_ABOUT_PAGE_CHANNEL_CHANGE_DISALLOWED_MESSAGE },
205 { "channelChangePageTitle", IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_TITLE },
206 { "channelChangePagePowerwashTitle",
207 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_TITLE },
208 { "channelChangePagePowerwashMessage",
209 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_MESSAGE },
210 { "channelChangePageDelayedChangeTitle",
211 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_TITLE },
212 { "channelChangePageUnstableTitle",
213 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_TITLE },
214 { "channelChangePagePowerwashButton",
215 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_POWERWASH_BUTTON },
216 { "channelChangePageChangeButton",
217 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CHANGE_BUTTON },
218 { "channelChangePageCancelButton",
219 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_CANCEL_BUTTON },
220 { "webkit", IDS_WEBKIT },
221 { "userAgent", IDS_ABOUT_VERSION_USER_AGENT },
222 { "commandLine", IDS_ABOUT_VERSION_COMMAND_LINE },
223 { "buildDate", IDS_ABOUT_VERSION_BUILD_DATE },
224 #endif
225 #if defined(OS_MACOSX)
226 { "promote", IDS_ABOUT_CHROME_PROMOTE_UPDATER },
227 { "learnMore", IDS_LEARN_MORE },
228 #endif
231 for (size_t i = 0; i < arraysize(resources); ++i) {
232 localized_strings->SetString(resources[i].name,
233 l10n_util::GetStringUTF16(resources[i].ids));
236 #if defined(OS_MACOSX)
237 localized_strings->SetString(
238 "updateObsoleteSystem",
239 ObsoleteSystemMac::LocalizedObsoleteSystemString());
240 localized_strings->SetString(
241 "updateObsoleteSystemURL",
242 chrome::kMac32BitDeprecationURL);
243 #endif
245 localized_strings->SetString(
246 "browserVersion",
247 l10n_util::GetStringFUTF16(IDS_ABOUT_PRODUCT_VERSION,
248 BuildBrowserVersionString()));
250 base::Time::Exploded exploded_time;
251 base::Time::Now().LocalExplode(&exploded_time);
252 localized_strings->SetString(
253 "productCopyright",
254 l10n_util::GetStringFUTF16(IDS_ABOUT_VERSION_COPYRIGHT,
255 base::IntToString16(exploded_time.year)));
257 base::string16 license = l10n_util::GetStringFUTF16(
258 IDS_ABOUT_VERSION_LICENSE,
259 base::ASCIIToUTF16(chrome::kChromiumProjectURL),
260 base::ASCIIToUTF16(chrome::kChromeUICreditsURL));
261 localized_strings->SetString("productLicense", license);
263 #if defined(OS_CHROMEOS)
264 base::string16 os_license = l10n_util::GetStringFUTF16(
265 IDS_ABOUT_CROS_VERSION_LICENSE,
266 base::ASCIIToUTF16(chrome::kChromeUIOSCreditsURL));
267 localized_strings->SetString("productOsLicense", os_license);
269 base::string16 product_name = l10n_util::GetStringUTF16(IDS_PRODUCT_OS_NAME);
270 localized_strings->SetString(
271 "channelChangePageDelayedChangeMessage",
272 l10n_util::GetStringFUTF16(
273 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_DELAYED_CHANGE_MESSAGE,
274 product_name));
275 localized_strings->SetString(
276 "channelChangePageUnstableMessage",
277 l10n_util::GetStringFUTF16(
278 IDS_ABOUT_PAGE_CHANNEL_CHANGE_PAGE_UNSTABLE_MESSAGE,
279 product_name));
281 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
282 chromeos::switches::kDisableNewChannelSwitcherUI)) {
283 localized_strings->SetBoolean("disableNewChannelSwitcherUI", true);
285 #endif
287 base::string16 tos = l10n_util::GetStringFUTF16(
288 IDS_ABOUT_TERMS_OF_SERVICE, base::UTF8ToUTF16(chrome::kChromeUITermsURL));
289 localized_strings->SetString("productTOS", tos);
291 localized_strings->SetString("webkitVersion", content::GetWebKitVersion());
293 localized_strings->SetString("jsEngine", "V8");
294 localized_strings->SetString("jsEngineVersion", v8::V8::GetVersion());
296 localized_strings->SetString("userAgentInfo", GetUserAgent());
298 base::CommandLine::StringType command_line =
299 base::CommandLine::ForCurrentProcess()->GetCommandLineString();
300 localized_strings->SetString("commandLineInfo", command_line);
303 void HelpHandler::RegisterMessages() {
304 #if defined(OS_CHROMEOS)
305 version_updater_.reset(
306 VersionUpdater::Create(web_ui()->GetWebContents()->GetBrowserContext()));
307 #endif
308 registrar_.Add(this, chrome::NOTIFICATION_UPGRADE_RECOMMENDED,
309 content::NotificationService::AllSources());
311 web_ui()->RegisterMessageCallback("onPageLoaded",
312 base::Bind(&HelpHandler::OnPageLoaded, base::Unretained(this)));
313 web_ui()->RegisterMessageCallback("relaunchNow",
314 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this)));
315 web_ui()->RegisterMessageCallback("openFeedbackDialog",
316 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this)));
317 web_ui()->RegisterMessageCallback("openHelpPage",
318 base::Bind(&HelpHandler::OpenHelpPage, base::Unretained(this)));
319 #if defined(OS_CHROMEOS)
320 web_ui()->RegisterMessageCallback("setChannel",
321 base::Bind(&HelpHandler::SetChannel, base::Unretained(this)));
322 web_ui()->RegisterMessageCallback("relaunchAndPowerwash",
323 base::Bind(&HelpHandler::RelaunchAndPowerwash, base::Unretained(this)));
324 web_ui()->RegisterMessageCallback("requestUpdate",
325 base::Bind(&HelpHandler::RequestUpdate, base::Unretained(this)));
326 #endif
327 #if defined(OS_MACOSX)
328 web_ui()->RegisterMessageCallback("promoteUpdater",
329 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this)));
330 #endif
332 #if defined(OS_CHROMEOS)
333 // Handler for the product label image, which will be shown if available.
334 content::URLDataSource::Add(Profile::FromWebUI(web_ui()),
335 new chromeos::ImageSource());
336 #endif
339 void HelpHandler::Observe(int type, const content::NotificationSource& source,
340 const content::NotificationDetails& details) {
341 switch (type) {
342 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
343 // A version update is installed and ready to go. Refresh the UI so the
344 // correct state will be shown.
345 RequestUpdate(NULL);
346 break;
348 default:
349 NOTREACHED();
353 // static
354 base::string16 HelpHandler::BuildBrowserVersionString() {
355 chrome::VersionInfo version_info;
357 std::string version = version_info.Version();
359 std::string modifier = chrome::VersionInfo::GetVersionStringModifier();
360 if (!modifier.empty())
361 version += " " + modifier;
363 #if defined(ARCH_CPU_64_BITS)
364 version += " (64-bit)";
365 #endif
367 return base::UTF8ToUTF16(version);
370 void HelpHandler::OnPageLoaded(const base::ListValue* args) {
371 #if defined(OS_CHROMEOS)
372 base::PostTaskAndReplyWithResult(
373 content::BrowserThread::GetBlockingPool(),
374 FROM_HERE,
375 base::Bind(&chromeos::version_loader::GetVersion,
376 chromeos::version_loader::VERSION_FULL),
377 base::Bind(&HelpHandler::OnOSVersion,
378 weak_factory_.GetWeakPtr()));
379 base::PostTaskAndReplyWithResult(
380 content::BrowserThread::GetBlockingPool(),
381 FROM_HERE,
382 base::Bind(&chromeos::version_loader::GetFirmware),
383 base::Bind(&HelpHandler::OnOSFirmware,
384 weak_factory_.GetWeakPtr()));
386 web_ui()->CallJavascriptFunction(
387 "help.HelpPage.updateEnableReleaseChannel",
388 base::FundamentalValue(CanChangeChannel(Profile::FromWebUI(web_ui()))));
390 base::Time build_time = base::SysInfo::GetLsbReleaseTime();
391 base::string16 build_date = base::TimeFormatFriendlyDate(build_time);
392 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate",
393 base::StringValue(build_date));
394 #endif // defined(OS_CHROMEOS)
396 // On Chrome OS, do not check for an update automatically.
397 #if defined(OS_CHROMEOS)
398 static_cast<VersionUpdaterCros*>(version_updater_.get())->GetUpdateStatus(
399 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)));
400 #else
401 RequestUpdate(NULL);
402 #endif
404 #if defined(OS_MACOSX)
405 web_ui()->CallJavascriptFunction(
406 "help.HelpPage.setObsoleteSystem",
407 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() &&
408 ObsoleteSystemMac::Has32BitOnlyCPU()));
409 web_ui()->CallJavascriptFunction(
410 "help.HelpPage.setObsoleteSystemEndOfTheLine",
411 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() &&
412 ObsoleteSystemMac::Is32BitEndOfTheLine()));
413 #endif
415 #if defined(OS_CHROMEOS)
416 web_ui()->CallJavascriptFunction(
417 "help.HelpPage.updateIsEnterpriseManaged",
418 base::FundamentalValue(IsEnterpriseManaged()));
419 // First argument to GetChannel() is a flag that indicates whether
420 // current channel should be returned (if true) or target channel
421 // (otherwise).
422 version_updater_->GetChannel(true,
423 base::Bind(&HelpHandler::OnCurrentChannel, weak_factory_.GetWeakPtr()));
424 version_updater_->GetChannel(false,
425 base::Bind(&HelpHandler::OnTargetChannel, weak_factory_.GetWeakPtr()));
427 base::PostTaskAndReplyWithResult(
428 content::BrowserThread::GetBlockingPool(),
429 FROM_HERE,
430 base::Bind(&ReadFCCLabelText),
431 base::Bind(&HelpHandler::OnFCCLabelTextRead,
432 weak_factory_.GetWeakPtr()));
433 #endif
436 #if defined(OS_MACOSX)
437 void HelpHandler::PromoteUpdater(const base::ListValue* args) {
438 version_updater_->PromoteUpdater();
440 #endif
442 void HelpHandler::RelaunchNow(const base::ListValue* args) {
443 DCHECK(args->empty());
444 version_updater_->RelaunchBrowser();
447 void HelpHandler::OpenFeedbackDialog(const base::ListValue* args) {
448 DCHECK(args->empty());
449 Browser* browser = chrome::FindBrowserWithWebContents(
450 web_ui()->GetWebContents());
451 chrome::OpenFeedbackDialog(browser);
454 void HelpHandler::OpenHelpPage(const base::ListValue* args) {
455 DCHECK(args->empty());
456 Browser* browser = chrome::FindBrowserWithWebContents(
457 web_ui()->GetWebContents());
458 chrome::ShowHelp(browser, chrome::HELP_SOURCE_WEBUI);
461 #if defined(OS_CHROMEOS)
463 void HelpHandler::SetChannel(const base::ListValue* args) {
464 DCHECK(args->GetSize() == 2);
466 if (!CanChangeChannel(Profile::FromWebUI(web_ui()))) {
467 LOG(WARNING) << "Non-owner tried to change release track.";
468 return;
471 base::string16 channel;
472 bool is_powerwash_allowed;
473 if (!args->GetString(0, &channel) ||
474 !args->GetBoolean(1, &is_powerwash_allowed)) {
475 LOG(ERROR) << "Can't parse SetChannel() args";
476 return;
479 version_updater_->SetChannel(base::UTF16ToUTF8(channel),
480 is_powerwash_allowed);
481 if (user_manager::UserManager::Get()->IsCurrentUserOwner()) {
482 // Check for update after switching release channel.
483 version_updater_->CheckForUpdate(base::Bind(&HelpHandler::SetUpdateStatus,
484 base::Unretained(this)));
488 void HelpHandler::RelaunchAndPowerwash(const base::ListValue* args) {
489 DCHECK(args->empty());
491 if (IsEnterpriseManaged())
492 return;
494 PrefService* prefs = g_browser_process->local_state();
495 prefs->SetBoolean(prefs::kFactoryResetRequested, true);
496 prefs->CommitPendingWrite();
498 // Perform sign out. Current chrome process will then terminate, new one will
499 // be launched (as if it was a restart).
500 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart();
503 #endif // defined(OS_CHROMEOS)
505 void HelpHandler::RequestUpdate(const base::ListValue* args) {
506 version_updater_->CheckForUpdate(
507 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this))
508 #if defined(OS_MACOSX)
509 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this))
510 #endif
514 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status,
515 int progress, const base::string16& message) {
516 // Only UPDATING state should have progress set.
517 DCHECK(status == VersionUpdater::UPDATING || progress == 0);
519 std::string status_str;
520 switch (status) {
521 case VersionUpdater::CHECKING:
522 status_str = "checking";
523 break;
524 case VersionUpdater::UPDATING:
525 status_str = "updating";
526 break;
527 case VersionUpdater::NEARLY_UPDATED:
528 status_str = "nearly_updated";
529 break;
530 case VersionUpdater::UPDATED:
531 status_str = "updated";
532 break;
533 case VersionUpdater::FAILED:
534 case VersionUpdater::FAILED_OFFLINE:
535 case VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED:
536 status_str = "failed";
537 break;
538 case VersionUpdater::DISABLED:
539 status_str = "disabled";
540 break;
543 web_ui()->CallJavascriptFunction("help.HelpPage.setUpdateStatus",
544 base::StringValue(status_str),
545 base::StringValue(message));
547 if (status == VersionUpdater::UPDATING) {
548 web_ui()->CallJavascriptFunction("help.HelpPage.setProgress",
549 base::FundamentalValue(progress));
552 #if defined(OS_CHROMEOS)
553 if (status == VersionUpdater::FAILED_OFFLINE ||
554 status == VersionUpdater::FAILED_CONNECTION_TYPE_DISALLOWED) {
555 base::string16 types_msg = GetAllowedConnectionTypesMessage();
556 if (!types_msg.empty()) {
557 web_ui()->CallJavascriptFunction(
558 "help.HelpPage.setAndShowAllowedConnectionTypesMsg",
559 base::StringValue(types_msg));
560 } else {
561 web_ui()->CallJavascriptFunction(
562 "help.HelpPage.showAllowedConnectionTypesMsg",
563 base::FundamentalValue(false));
565 } else {
566 web_ui()->CallJavascriptFunction(
567 "help.HelpPage.showAllowedConnectionTypesMsg",
568 base::FundamentalValue(false));
570 #endif // defined(OS_CHROMEOS)
573 #if defined(OS_MACOSX)
574 void HelpHandler::SetPromotionState(VersionUpdater::PromotionState state) {
575 std::string state_str;
576 switch (state) {
577 case VersionUpdater::PROMOTE_HIDDEN:
578 state_str = "hidden";
579 break;
580 case VersionUpdater::PROMOTE_ENABLED:
581 state_str = "enabled";
582 break;
583 case VersionUpdater::PROMOTE_DISABLED:
584 state_str = "disabled";
585 break;
588 web_ui()->CallJavascriptFunction("help.HelpPage.setPromotionState",
589 base::StringValue(state_str));
591 #endif // defined(OS_MACOSX)
593 #if defined(OS_CHROMEOS)
594 void HelpHandler::OnOSVersion(const std::string& version) {
595 web_ui()->CallJavascriptFunction("help.HelpPage.setOSVersion",
596 base::StringValue(version));
599 void HelpHandler::OnOSFirmware(const std::string& firmware) {
600 web_ui()->CallJavascriptFunction("help.HelpPage.setOSFirmware",
601 base::StringValue(firmware));
604 void HelpHandler::OnCurrentChannel(const std::string& channel) {
605 web_ui()->CallJavascriptFunction(
606 "help.HelpPage.updateCurrentChannel", base::StringValue(channel));
609 void HelpHandler::OnTargetChannel(const std::string& channel) {
610 web_ui()->CallJavascriptFunction(
611 "help.HelpPage.updateTargetChannel", base::StringValue(channel));
614 void HelpHandler::OnFCCLabelTextRead(const std::string& text) {
615 // Remove unnecessary whitespace.
616 web_ui()->CallJavascriptFunction(
617 "help.HelpPage.setProductLabelText",
618 base::StringValue(base::CollapseWhitespaceASCII(text, true)));
621 #endif // defined(OS_CHROMEOS)