| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "base/files/file_util_proxy.h" | 43 #include "base/files/file_util_proxy.h" |
| 44 #include "base/i18n/time_formatting.h" | 44 #include "base/i18n/time_formatting.h" |
| 45 #include "base/prefs/pref_service.h" | 45 #include "base/prefs/pref_service.h" |
| 46 #include "base/sys_info.h" | 46 #include "base/sys_info.h" |
| 47 #include "chrome/browser/chromeos/login/users/user_manager.h" | 47 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 48 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 48 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 49 #include "chrome/browser/chromeos/settings/cros_settings.h" | 49 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 50 #include "chrome/browser/profiles/profile.h" | 50 #include "chrome/browser/profiles/profile.h" |
| 51 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" | 51 #include "chrome/browser/ui/webui/help/help_utils_chromeos.h" |
| 52 #include "chrome/browser/ui/webui/help/version_updater_chromeos.h" |
| 52 #include "chromeos/chromeos_switches.h" | 53 #include "chromeos/chromeos_switches.h" |
| 53 #include "chromeos/dbus/dbus_thread_manager.h" | 54 #include "chromeos/dbus/dbus_thread_manager.h" |
| 54 #include "chromeos/dbus/power_manager_client.h" | 55 #include "chromeos/dbus/power_manager_client.h" |
| 55 #endif | 56 #endif |
| 56 | 57 |
| 57 using base::ListValue; | 58 using base::ListValue; |
| 58 using content::BrowserThread; | 59 using content::BrowserThread; |
| 59 | 60 |
| 60 namespace { | 61 namespace { |
| 61 | 62 |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION }, | 136 { "aboutProductDescription", IDS_ABOUT_PRODUCT_DESCRIPTION }, |
| 136 { "relaunch", IDS_RELAUNCH_BUTTON }, | 137 { "relaunch", IDS_RELAUNCH_BUTTON }, |
| 137 #if defined(OS_CHROMEOS) | 138 #if defined(OS_CHROMEOS) |
| 138 { "relaunchAndPowerwash", IDS_RELAUNCH_AND_POWERWASH_BUTTON }, | 139 { "relaunchAndPowerwash", IDS_RELAUNCH_AND_POWERWASH_BUTTON }, |
| 139 #endif | 140 #endif |
| 140 { "productName", IDS_PRODUCT_NAME }, | 141 { "productName", IDS_PRODUCT_NAME }, |
| 141 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED }, | 142 { "updateCheckStarted", IDS_UPGRADE_CHECK_STARTED }, |
| 142 { "upToDate", IDS_UPGRADE_UP_TO_DATE }, | 143 { "upToDate", IDS_UPGRADE_UP_TO_DATE }, |
| 143 { "updating", IDS_UPGRADE_UPDATING }, | 144 { "updating", IDS_UPGRADE_UPDATING }, |
| 144 #if defined(OS_CHROMEOS) | 145 #if defined(OS_CHROMEOS) |
| 146 { "updateButton", IDS_UPGRADE_BUTTON }, |
| 145 { "updatingChannelSwitch", IDS_UPGRADE_UPDATING_CHANNEL_SWITCH }, | 147 { "updatingChannelSwitch", IDS_UPGRADE_UPDATING_CHANNEL_SWITCH }, |
| 146 #endif | 148 #endif |
| 147 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, | 149 { "updateAlmostDone", IDS_UPGRADE_SUCCESSFUL_RELAUNCH }, |
| 148 #if defined(OS_CHROMEOS) | 150 #if defined(OS_CHROMEOS) |
| 149 { "successfulChannelSwitch", IDS_UPGRADE_SUCCESSFUL_CHANNEL_SWITCH }, | 151 { "successfulChannelSwitch", IDS_UPGRADE_SUCCESSFUL_CHANNEL_SWITCH }, |
| 150 #endif | 152 #endif |
| 151 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, | 153 { "getHelpWithChrome", IDS_GET_HELP_USING_CHROME }, |
| 152 { "reportAnIssue", IDS_REPORT_AN_ISSUE }, | 154 { "reportAnIssue", IDS_REPORT_AN_ISSUE }, |
| 153 #if defined(OS_CHROMEOS) | 155 #if defined(OS_CHROMEOS) |
| 154 { "platform", IDS_PLATFORM_LABEL }, | 156 { "platform", IDS_PLATFORM_LABEL }, |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); | 277 base::Bind(&HelpHandler::RelaunchNow, base::Unretained(this))); |
| 276 web_ui()->RegisterMessageCallback("openFeedbackDialog", | 278 web_ui()->RegisterMessageCallback("openFeedbackDialog", |
| 277 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); | 279 base::Bind(&HelpHandler::OpenFeedbackDialog, base::Unretained(this))); |
| 278 web_ui()->RegisterMessageCallback("openHelpPage", | 280 web_ui()->RegisterMessageCallback("openHelpPage", |
| 279 base::Bind(&HelpHandler::OpenHelpPage, base::Unretained(this))); | 281 base::Bind(&HelpHandler::OpenHelpPage, base::Unretained(this))); |
| 280 #if defined(OS_CHROMEOS) | 282 #if defined(OS_CHROMEOS) |
| 281 web_ui()->RegisterMessageCallback("setChannel", | 283 web_ui()->RegisterMessageCallback("setChannel", |
| 282 base::Bind(&HelpHandler::SetChannel, base::Unretained(this))); | 284 base::Bind(&HelpHandler::SetChannel, base::Unretained(this))); |
| 283 web_ui()->RegisterMessageCallback("relaunchAndPowerwash", | 285 web_ui()->RegisterMessageCallback("relaunchAndPowerwash", |
| 284 base::Bind(&HelpHandler::RelaunchAndPowerwash, base::Unretained(this))); | 286 base::Bind(&HelpHandler::RelaunchAndPowerwash, base::Unretained(this))); |
| 287 web_ui()->RegisterMessageCallback("requestUpdate", |
| 288 base::Bind(&HelpHandler::RequestUpdate, base::Unretained(this))); |
| 285 #endif | 289 #endif |
| 286 #if defined(OS_MACOSX) | 290 #if defined(OS_MACOSX) |
| 287 web_ui()->RegisterMessageCallback("promoteUpdater", | 291 web_ui()->RegisterMessageCallback("promoteUpdater", |
| 288 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); | 292 base::Bind(&HelpHandler::PromoteUpdater, base::Unretained(this))); |
| 289 #endif | 293 #endif |
| 290 } | 294 } |
| 291 | 295 |
| 292 void HelpHandler::Observe(int type, const content::NotificationSource& source, | 296 void HelpHandler::Observe(int type, const content::NotificationSource& source, |
| 293 const content::NotificationDetails& details) { | 297 const content::NotificationDetails& details) { |
| 294 switch (type) { | 298 switch (type) { |
| 295 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { | 299 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { |
| 296 // A version update is installed and ready to go. Refresh the UI so the | 300 // A version update is installed and ready to go. Refresh the UI so the |
| 297 // correct state will be shown. | 301 // correct state will be shown. |
| 298 version_updater_->CheckForUpdate( | 302 RequestUpdate(NULL); |
| 299 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) | |
| 300 #if defined(OS_MACOSX) | |
| 301 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) | |
| 302 #endif | |
| 303 ); | |
| 304 break; | 303 break; |
| 305 } | 304 } |
| 306 default: | 305 default: |
| 307 NOTREACHED(); | 306 NOTREACHED(); |
| 308 } | 307 } |
| 309 } | 308 } |
| 310 | 309 |
| 311 // static | 310 // static |
| 312 base::string16 HelpHandler::BuildBrowserVersionString() { | 311 base::string16 HelpHandler::BuildBrowserVersionString() { |
| 313 chrome::VersionInfo version_info; | 312 chrome::VersionInfo version_info; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 web_ui()->CallJavascriptFunction( | 345 web_ui()->CallJavascriptFunction( |
| 347 "help.HelpPage.updateEnableReleaseChannel", | 346 "help.HelpPage.updateEnableReleaseChannel", |
| 348 base::FundamentalValue(CanChangeChannel())); | 347 base::FundamentalValue(CanChangeChannel())); |
| 349 | 348 |
| 350 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); | 349 base::Time build_time = base::SysInfo::GetLsbReleaseTime(); |
| 351 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); | 350 base::string16 build_date = base::TimeFormatFriendlyDate(build_time); |
| 352 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", | 351 web_ui()->CallJavascriptFunction("help.HelpPage.setBuildDate", |
| 353 base::StringValue(build_date)); | 352 base::StringValue(build_date)); |
| 354 #endif // defined(OS_CHROMEOS) | 353 #endif // defined(OS_CHROMEOS) |
| 355 | 354 |
| 356 version_updater_->CheckForUpdate( | 355 // On Chrome OS, do not check for an update automatically. |
| 357 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) | 356 #if defined(OS_CHROMEOS) |
| 358 #if defined(OS_MACOSX) | 357 static_cast<VersionUpdaterCros*>(version_updater_.get())->GetUpdateStatus( |
| 359 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) | 358 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this))); |
| 359 #else |
| 360 RequestUpdate(NULL); |
| 360 #endif | 361 #endif |
| 361 ); | |
| 362 | 362 |
| 363 #if defined(OS_MACOSX) | 363 #if defined(OS_MACOSX) |
| 364 web_ui()->CallJavascriptFunction( | 364 web_ui()->CallJavascriptFunction( |
| 365 "help.HelpPage.setObsoleteSystem", | 365 "help.HelpPage.setObsoleteSystem", |
| 366 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() && | 366 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() && |
| 367 ObsoleteSystemMac::Has32BitOnlyCPU())); | 367 ObsoleteSystemMac::Has32BitOnlyCPU())); |
| 368 web_ui()->CallJavascriptFunction( | 368 web_ui()->CallJavascriptFunction( |
| 369 "help.HelpPage.setObsoleteSystemEndOfTheLine", | 369 "help.HelpPage.setObsoleteSystemEndOfTheLine", |
| 370 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() && | 370 base::FundamentalValue(ObsoleteSystemMac::Is32BitObsoleteNowOrSoon() && |
| 371 ObsoleteSystemMac::Is32BitEndOfTheLine())); | 371 ObsoleteSystemMac::Is32BitEndOfTheLine())); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 prefs->SetBoolean(prefs::kFactoryResetRequested, true); | 447 prefs->SetBoolean(prefs::kFactoryResetRequested, true); |
| 448 prefs->CommitPendingWrite(); | 448 prefs->CommitPendingWrite(); |
| 449 | 449 |
| 450 // Perform sign out. Current chrome process will then terminate, new one will | 450 // Perform sign out. Current chrome process will then terminate, new one will |
| 451 // be launched (as if it was a restart). | 451 // be launched (as if it was a restart). |
| 452 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); | 452 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 453 } | 453 } |
| 454 | 454 |
| 455 #endif // defined(OS_CHROMEOS) | 455 #endif // defined(OS_CHROMEOS) |
| 456 | 456 |
| 457 void HelpHandler::RequestUpdate(const base::ListValue* args) { |
| 458 version_updater_->CheckForUpdate( |
| 459 base::Bind(&HelpHandler::SetUpdateStatus, base::Unretained(this)) |
| 460 #if defined(OS_MACOSX) |
| 461 , base::Bind(&HelpHandler::SetPromotionState, base::Unretained(this)) |
| 462 #endif |
| 463 ); |
| 464 } |
| 465 |
| 457 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, | 466 void HelpHandler::SetUpdateStatus(VersionUpdater::Status status, |
| 458 int progress, const base::string16& message) { | 467 int progress, const base::string16& message) { |
| 459 // Only UPDATING state should have progress set. | 468 // Only UPDATING state should have progress set. |
| 460 DCHECK(status == VersionUpdater::UPDATING || progress == 0); | 469 DCHECK(status == VersionUpdater::UPDATING || progress == 0); |
| 461 | 470 |
| 462 std::string status_str; | 471 std::string status_str; |
| 463 switch (status) { | 472 switch (status) { |
| 464 case VersionUpdater::CHECKING: | 473 case VersionUpdater::CHECKING: |
| 465 status_str = "checking"; | 474 status_str = "checking"; |
| 466 break; | 475 break; |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 web_ui()->CallJavascriptFunction( | 557 web_ui()->CallJavascriptFunction( |
| 549 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); | 558 "help.HelpPage.updateCurrentChannel", base::StringValue(channel)); |
| 550 } | 559 } |
| 551 | 560 |
| 552 void HelpHandler::OnTargetChannel(const std::string& channel) { | 561 void HelpHandler::OnTargetChannel(const std::string& channel) { |
| 553 web_ui()->CallJavascriptFunction( | 562 web_ui()->CallJavascriptFunction( |
| 554 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); | 563 "help.HelpPage.updateTargetChannel", base::StringValue(channel)); |
| 555 } | 564 } |
| 556 | 565 |
| 557 #endif // defined(OS_CHROMEOS) | 566 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |