summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-04 10:29:47 +0000
committerfinnur@chromium.org <finnur@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-04 10:29:47 +0000
commit8101ef03ff6f84be3dd58dfb47760396553b09ba (patch)
tree2e722e118233bbf59b933eed4a33e9fe30ddecfb /chrome
parent62f6bbd3fa77c1f9a42f8cbb6081ccd111217217 (diff)
downloadchromium_src-8101ef03ff6f84be3dd58dfb47760396553b09ba.zip
chromium_src-8101ef03ff6f84be3dd58dfb47760396553b09ba.tar.gz
chromium_src-8101ef03ff6f84be3dd58dfb47760396553b09ba.tar.bz2
Augment the About box flow to automatically install any new version we find on the server and have inline buttons to suggest restart, which restores your session (as opposed to the modal dialog box suggesting a restart and not restarting/restoring).
BUG=http://crbug.com/43076, http://crbug.com/1821 TEST=Needs manual testing with an active Google Update server. Review URL: http://codereview.chromium.org/3076018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54888 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/browser/views/about_chrome_view.cc68
-rw-r--r--chrome/browser/views/about_chrome_view.h11
3 files changed, 37 insertions, 48 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index b217207..ae64e12 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -4668,6 +4668,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_UPGRADE_SUCCESSFUL_NOVERSION" desc="Status label: Successfully upgraded">
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> has been updated
</message>
+ <message name="IDS_UPGRADE_SUCCESSFUL_RESTART" desc="Status label: Successfully updated">
+ Restart <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to finish updating to <ph name="VERSION">$2<ex>0.1.131</ex></ph>
+ </message>
+ <message name="IDS_UPGRADE_SUCCESSFUL_NOVERSION_RESTART" desc="Status label: Successfully updated">
+ Restart <ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> to finish updating
+ </message>
<if expr="pp_ifdef('chromeos')">
<message name="IDS_UPGRADE_ALREADY_UP_TO_DATE" desc="Status label: Already up to date">
<ph name="PRODUCT_NAME">$1<ex>Google Chrome</ex></ph> is up to date
diff --git a/chrome/browser/views/about_chrome_view.cc b/chrome/browser/views/about_chrome_view.cc
index fae029c..4eba383 100644
--- a/chrome/browser/views/about_chrome_view.cc
+++ b/chrome/browser/views/about_chrome_view.cc
@@ -16,11 +16,14 @@
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/browser_list.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/metrics/user_metrics.h"
#include "chrome/browser/platform_util.h"
+#include "chrome/browser/pref_service.h"
#include "chrome/browser/views/accessible_view_helper.h"
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_version_info.h"
+#include "chrome/common/pref_names.h"
#include "chrome/common/url_constants.h"
#include "gfx/canvas.h"
#include "grit/chromium_strings.h"
@@ -106,7 +109,7 @@ AboutChromeView::AboutChromeView(Profile* profile)
chromium_url_(NULL),
open_source_url_(NULL),
terms_of_service_url_(NULL),
- check_button_status_(CHECKBUTTON_HIDDEN),
+ restart_button_visible_(false),
chromium_url_appears_first_(true),
text_direction_is_rtl_(false) {
DCHECK(profile);
@@ -501,7 +504,7 @@ void AboutChromeView::Paint(gfx::Canvas* canvas) {
void AboutChromeView::ViewHierarchyChanged(bool is_add,
views::View* parent,
views::View* child) {
- // Since we want the some of the controls to show up in the same visual row
+ // Since we want some of the controls to show up in the same visual row
// as the buttons, which are provided by the framework, we must add the
// buttons to the non-client view, which is the parent of this view.
// Similarly, when we're removed from the view hierarchy, we must take care
@@ -555,10 +558,12 @@ void AboutChromeView::ViewHierarchyChanged(bool is_add,
std::wstring AboutChromeView::GetDialogButtonLabel(
MessageBoxFlags::DialogButton button) const {
if (button == MessageBoxFlags::DIALOGBUTTON_OK) {
- return l10n_util::GetString(IDS_ABOUT_CHROME_UPDATE_CHECK);
+ return l10n_util::GetString(IDS_RESTART_AND_UPDATE);
} else if (button == MessageBoxFlags::DIALOGBUTTON_CANCEL) {
+ if (restart_button_visible_)
+ return l10n_util::GetString(IDS_NOT_NOW);
// The OK button (which is the default button) has been re-purposed to be
- // 'Check for Updates' so we want the Cancel button should have the label
+ // 'Restart Now' so we want the Cancel button should have the label
// OK but act like a Cancel button in all other ways.
return l10n_util::GetString(IDS_OK);
}
@@ -573,20 +578,16 @@ std::wstring AboutChromeView::GetWindowTitle() const {
bool AboutChromeView::IsDialogButtonEnabled(
MessageBoxFlags::DialogButton button) const {
- if (button == MessageBoxFlags::DIALOGBUTTON_OK &&
- check_button_status_ != CHECKBUTTON_ENABLED) {
+ if (button == MessageBoxFlags::DIALOGBUTTON_OK && !restart_button_visible_)
return false;
- }
return true;
}
bool AboutChromeView::IsDialogButtonVisible(
MessageBoxFlags::DialogButton button) const {
- if (button == MessageBoxFlags::DIALOGBUTTON_OK &&
- check_button_status_ == CHECKBUTTON_HIDDEN) {
+ if (button == MessageBoxFlags::DIALOGBUTTON_OK && !restart_button_visible_)
return false;
- }
return true;
}
@@ -621,19 +622,13 @@ bool AboutChromeView::IsModal() const {
bool AboutChromeView::Accept() {
#if defined(OS_WIN) || defined(OS_CHROMEOS)
- UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR);
-
- // The Upgrade button isn't available until we have received notification
- // that an update is available, at which point this pointer should have been
- // null-ed out.
- DCHECK(!google_updater_);
- google_updater_ = new GoogleUpdate();
- google_updater_->set_status_listener(this);
- // CheckForUpdate(true,...) means perform the upgrade if new version found.
- google_updater_->CheckForUpdate(true, window());
+ // Set the flag to restore the last session on shutdown.
+ PrefService* pref_service = g_browser_process->local_state();
+ pref_service->SetBoolean(prefs::kRestartLastSessionOnShutdown, true);
+ BrowserList::CloseAllBrowsersAndExit();
#endif
- return false; // We never allow this button to close the window.
+ return true;
}
views::View* AboutChromeView::GetContentsView() {
@@ -714,26 +709,27 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
switch (result) {
case UPGRADE_STARTED:
UserMetrics::RecordAction(UserMetricsAction("Upgrade_Started"), profile_);
- check_button_status_ = CHECKBUTTON_DISABLED;
show_throbber = true;
update_label_.SetText(l10n_util::GetString(IDS_UPGRADE_STARTED));
break;
case UPGRADE_CHECK_STARTED:
UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Started"),
profile_);
- check_button_status_ = CHECKBUTTON_HIDDEN;
show_throbber = true;
update_label_.SetText(l10n_util::GetString(IDS_UPGRADE_CHECK_STARTED));
break;
case UPGRADE_IS_AVAILABLE:
UserMetrics::RecordAction(
UserMetricsAction("UpgradeCheck_UpgradeIsAvailable"), profile_);
- check_button_status_ = CHECKBUTTON_ENABLED;
- update_label_.SetText(
- l10n_util::GetStringF(IDS_UPGRADE_AVAILABLE,
- l10n_util::GetString(IDS_PRODUCT_NAME)));
- show_update_available_indicator = true;
- break;
+ DCHECK(!google_updater_); // Should have been nulled out already.
+ google_updater_ = new GoogleUpdate();
+ google_updater_->set_status_listener(this);
+ UpdateStatus(UPGRADE_STARTED, GOOGLE_UPDATE_NO_ERROR);
+ // CheckForUpdate(true,...) means perform upgrade if new version found.
+ google_updater_->CheckForUpdate(true, window());
+ // TODO(seanparent): Need to see if this code needs to change to
+ // force a machine restart.
+ return;
case UPGRADE_ALREADY_UP_TO_DATE: {
// The extra version check is necessary on Windows because the application
// may be already up to date on disk though the running app is still
@@ -753,7 +749,6 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
#endif
UserMetrics::RecordAction(
UserMetricsAction("UpgradeCheck_AlreadyUpToDate"), profile_);
- check_button_status_ = CHECKBUTTON_HIDDEN;
#if defined(OS_CHROMEOS)
std::wstring update_label_text =
l10n_util::GetStringF(IDS_UPGRADE_ALREADY_UP_TO_DATE,
@@ -783,26 +778,21 @@ void AboutChromeView::UpdateStatus(GoogleUpdateUpgradeResult result,
else
UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Upgraded"),
profile_);
- check_button_status_ = CHECKBUTTON_HIDDEN;
+ restart_button_visible_ = true;
const std::wstring& update_string = new_version_available_.empty()
- ? l10n_util::GetStringF(IDS_UPGRADE_SUCCESSFUL_NOVERSION,
+ ? l10n_util::GetStringF(IDS_UPGRADE_SUCCESSFUL_NOVERSION_RESTART,
l10n_util::GetString(IDS_PRODUCT_NAME))
- : l10n_util::GetStringF(IDS_UPGRADE_SUCCESSFUL,
+ : l10n_util::GetStringF(IDS_UPGRADE_SUCCESSFUL_RESTART,
l10n_util::GetString(IDS_PRODUCT_NAME),
new_version_available_);
update_label_.SetText(update_string);
show_success_indicator = true;
- // TODO(seanparent): Need to see if this code needs to change to
- // force a machine restart.
-#if defined(OS_WIN)
- RestartMessageBox::ShowMessageBox(window()->GetNativeWindow());
-#endif
break;
}
case UPGRADE_ERROR:
UserMetrics::RecordAction(UserMetricsAction("UpgradeCheck_Error"),
profile_);
- check_button_status_ = CHECKBUTTON_HIDDEN;
+ restart_button_visible_ = false;
update_label_.SetText(l10n_util::GetStringF(IDS_UPGRADE_ERROR,
UTF8ToWide(base::IntToString(error_code))));
show_timeout_indicator = true;
diff --git a/chrome/browser/views/about_chrome_view.h b/chrome/browser/views/about_chrome_view.h
index e1386d4..f3b6bee 100644
--- a/chrome/browser/views/about_chrome_view.h
+++ b/chrome/browser/views/about_chrome_view.h
@@ -84,13 +84,6 @@ class AboutChromeView : public views::View,
#endif
private:
- // The visible state of the Check For Updates button.
- enum CheckButtonStatus {
- CHECKBUTTON_HIDDEN = 0,
- CHECKBUTTON_DISABLED,
- CHECKBUTTON_ENABLED,
- };
-
#if defined(OS_WIN) || defined(OS_CHROMEOS)
// Update the UI to show the status of the upgrade.
void UpdateStatus(GoogleUpdateUpgradeResult result,
@@ -132,8 +125,8 @@ class AboutChromeView : public views::View,
// The dialog dimensions.
gfx::Size dialog_dimensions_;
- // Keeps track of the visible state of the Check For Updates button.
- CheckButtonStatus check_button_status_;
+ // Keeps track of the visible state of the Restart Now button.
+ bool restart_button_visible_;
// The text to display as the main label of the About box. We draw this text
// word for word with the help of the WordIterator, and make room for URLs