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

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

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

Powered by Google App Engine
This is Rietveld 408576698