summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 13:24:57 +0000
committerkuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-17 13:24:57 +0000
commit4df8786fcd6334d4f5f92350a8297135149aabae (patch)
treec373e3afb8ec9104547ee873019ce0be920b14a5 /chrome
parent7d280cb1adf9c8e66ef8f9c97e8b633b0eac37e0 (diff)
downloadchromium_src-4df8786fcd6334d4f5f92350a8297135149aabae.zip
chromium_src-4df8786fcd6334d4f5f92350a8297135149aabae.tar.gz
chromium_src-4df8786fcd6334d4f5f92350a8297135149aabae.tar.bz2
On uninstall ask whether to delete profile.
BUG=8431 Review URL: http://codereview.chromium.org/62097 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13926 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/app/chromium_strings.grd5
-rw-r--r--chrome/app/google_chrome_strings.grd5
-rw-r--r--chrome/browser/browser_main_win.cc41
-rw-r--r--chrome/browser/views/browser_views.vcproj8
-rw-r--r--chrome/browser/views/uninstall_dialog.cc66
-rw-r--r--chrome/browser/views/uninstall_dialog.h40
-rw-r--r--chrome/common/result_codes.h1
-rw-r--r--chrome/installer/setup/uninstall.cc29
-rw-r--r--chrome/installer/util/util_constants.h1
9 files changed, 168 insertions, 28 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd
index bb3b4ce..d5c6ca1 100644
--- a/chrome/app/chromium_strings.grd
+++ b/chrome/app/chromium_strings.grd
@@ -193,7 +193,7 @@ be available for now. -->
Please close all Chromium windows and try again.
</message>
<message name="IDS_UNINSTALL_VERIFY" desc="Message to confirm user wants to uninstall">
- Are you sure you want to uninstall Chromium? (Was it something we said?)
+ Are you sure you want to uninstall Chromium?
</message>
<message name="IDS_UNINSTALL_CHROME" desc="The text of the shortcut in the Start Menu for uninstalling chrome.">
Uninstall Chromium
@@ -331,6 +331,9 @@ be available for now. -->
<message name="IDS_SHORTCUT_TOOLTIP" desc="Text for the hover-on tooltip for the Chromium shortcuts.">
Access the Internet
</message>
+ <message name="IDS_UNINSTALL_DELETE_PROFILE" desc="Text to show user to ask whether to delete all the profile data also during uninstallation.">
+ Delete all profile data
+ </message>
</messages>
</release>
</grit>
diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd
index 6b49c85..5dac76d 100644
--- a/chrome/app/google_chrome_strings.grd
+++ b/chrome/app/google_chrome_strings.grd
@@ -241,7 +241,7 @@ Chrome supports. -->
Please close all Chrome windows and try again.
</message>
<message name="IDS_UNINSTALL_VERIFY" desc="Message to confirm user wants to uninstall">
- Are you sure you want to uninstall Google Chrome? (Was it something we said?)
+ Are you sure you want to uninstall Google Chrome?
</message>
<message name="IDS_UNINSTALL_CHROME" desc="The text of the shortcut in the Start Menu for uninstalling chrome.">
Uninstall Google Chrome
@@ -379,6 +379,9 @@ Chrome supports. -->
<message name="IDS_SHORTCUT_TOOLTIP" desc="Text for the hover-on tooltip for the Google Chrome shortcuts.">
Access the Internet
</message>
+ <message name="IDS_UNINSTALL_DELETE_PROFILE" desc="Text to show user to ask whether to delete all the profile data also during uninstallation.">
+ Delete all profile data
+ </message>
</messages>
</release>
</grit>
diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc
index e5b0dd4..4d1ea58 100644
--- a/chrome/browser/browser_main_win.cc
+++ b/chrome/browser/browser_main_win.cc
@@ -14,13 +14,18 @@
#include "base/win_util.h"
#include "chrome/browser/first_run.h"
#include "chrome/browser/metrics/metrics_service.h"
+#include "chrome/browser/views/uninstall_dialog.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/env_vars.h"
#include "chrome/common/l10n_util.h"
+#include "chrome/common/message_box_flags.h"
#include "chrome/common/result_codes.h"
#include "chrome/installer/util/helper.h"
#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/shell_util.h"
+#include "chrome/views/controls/message_box_view.h"
+#include "chrome/views/widget/accelerator_handler.h"
+#include "chrome/views/window/window.h"
#include "grit/chromium_strings.h"
#include "grit/generated_resources.h"
@@ -37,11 +42,11 @@ bool CheckForWin2000() {
return false;
}
-bool AskForUninstallConfirmation() {
- const std::wstring text = l10n_util::GetString(IDS_UNINSTALL_VERIFY);
- const std::wstring caption = l10n_util::GetString(IDS_PRODUCT_NAME);
- const UINT flags = MB_OKCANCEL | MB_ICONWARNING | MB_TOPMOST;
- return (IDOK == win_util::MessageBox(NULL, text, caption, flags));
+int AskForUninstallConfirmation() {
+ int ret = ResultCodes::NORMAL_EXIT;
+ UninstallDialog::ShowUninstallDialog(ret);
+ MessageLoop::current()->Run();
+ return ret;
}
void ShowCloseBrowserFirstMessageBox() {
@@ -56,19 +61,19 @@ int DoUninstallTasks(bool chrome_still_running) {
ShowCloseBrowserFirstMessageBox();
return ResultCodes::UNINSTALL_CHROME_ALIVE;
}
- if (!AskForUninstallConfirmation())
- return ResultCodes::UNINSTALL_USER_CANCEL;
- // The following actions are just best effort.
- LOG(INFO) << "Executing uninstall actions";
- ResultCodes::ExitCode ret = ResultCodes::NORMAL_EXIT;
- if (!FirstRun::RemoveSentinel())
- ret = ResultCodes::UNINSTALL_DELETE_FILE_ERROR;
- // We want to remove user level shortcuts and we only care about the ones
- // created by us and not by the installer so |alternate| is false.
- if (!ShellUtil::RemoveChromeDesktopShortcut(ShellUtil::CURRENT_USER, false))
- ret = ResultCodes::UNINSTALL_DELETE_FILE_ERROR;
- if (!ShellUtil::RemoveChromeQuickLaunchShortcut(ShellUtil::CURRENT_USER))
- ret = ResultCodes::UNINSTALL_DELETE_FILE_ERROR;
+ int ret = AskForUninstallConfirmation();
+ if (ret != ResultCodes::UNINSTALL_USER_CANCEL) {
+ // The following actions are just best effort.
+ LOG(INFO) << "Executing uninstall actions";
+ if (!FirstRun::RemoveSentinel())
+ LOG(INFO) << "Failed to delete sentinel file.";
+ // We want to remove user level shortcuts and we only care about the ones
+ // created by us and not by the installer so |alternate| is false.
+ if (!ShellUtil::RemoveChromeDesktopShortcut(ShellUtil::CURRENT_USER, false))
+ LOG(INFO) << "Failed to delete desktop shortcut.";
+ if (!ShellUtil::RemoveChromeQuickLaunchShortcut(ShellUtil::CURRENT_USER))
+ LOG(INFO) << "Failed to delete quick launch shortcut.";
+ }
return ret;
}
diff --git a/chrome/browser/views/browser_views.vcproj b/chrome/browser/views/browser_views.vcproj
index 6905db1..a923afa 100644
--- a/chrome/browser/views/browser_views.vcproj
+++ b/chrome/browser/views/browser_views.vcproj
@@ -858,6 +858,14 @@
>
</File>
<File
+ RelativePath=".\uninstall_dialog.cc"
+ >
+ </File>
+ <File
+ RelativePath=".\uninstall_dialog.h"
+ >
+ </File>
+ <File
RelativePath=".\user_data_dir_dialog.cc"
>
</File>
diff --git a/chrome/browser/views/uninstall_dialog.cc b/chrome/browser/views/uninstall_dialog.cc
new file mode 100644
index 0000000..da54ca8
--- /dev/null
+++ b/chrome/browser/views/uninstall_dialog.cc
@@ -0,0 +1,66 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/views/uninstall_dialog.h"
+
+#include "base/message_loop.h"
+#include "chrome/common/l10n_util.h"
+#include "chrome/common/result_codes.h"
+#include "chrome/common/message_box_flags.h"
+#include "chrome/views/controls/message_box_view.h"
+#include "chrome/views/window/window.h"
+#include "grit/chromium_strings.h"
+
+// static
+void UninstallDialog::ShowUninstallDialog(int& user_selection) {
+ // When the window closes, it will delete itself.
+ new UninstallDialog(user_selection);
+}
+
+bool UninstallDialog::Accept() {
+ user_selection_ = ResultCodes::NORMAL_EXIT;
+ if (message_box_view_->IsCheckBoxSelected())
+ user_selection_ = ResultCodes::UNINSTALL_DELETE_PROFILE;
+ return true;
+}
+
+bool UninstallDialog::Cancel() {
+ user_selection_ = ResultCodes::UNINSTALL_USER_CANCEL;
+ return true;
+}
+
+int UninstallDialog::GetDialogButtons() const {
+ return DIALOGBUTTON_OK | DIALOGBUTTON_CANCEL;
+}
+
+std::wstring UninstallDialog::GetWindowTitle() const {
+ return l10n_util::GetString(IDS_UNINSTALL_CHROME);
+}
+
+void UninstallDialog::DeleteDelegate() {
+ delete this;
+}
+
+views::View* UninstallDialog::GetContentsView() {
+ return message_box_view_;
+}
+
+UninstallDialog::UninstallDialog(int& user_selection)
+ : user_selection_(user_selection) {
+ // Also deleted when the window closes.
+ message_box_view_ = new MessageBoxView(
+ MessageBox::kIsConfirmMessageBox | MessageBox::kAutoDetectAlignment,
+ l10n_util::GetString(IDS_UNINSTALL_VERIFY).c_str(),
+ std::wstring());
+ message_box_view_->SetCheckBoxLabel(
+ l10n_util::GetString(IDS_UNINSTALL_DELETE_PROFILE));
+ message_box_view_->SetCheckBoxSelected(false);
+ views::Window::CreateChromeWindow(NULL, gfx::Rect(), this)->Show();
+}
+
+UninstallDialog::~UninstallDialog() {
+ MessageLoop::current()->Quit();
+}
+
+
diff --git a/chrome/browser/views/uninstall_dialog.h b/chrome/browser/views/uninstall_dialog.h
new file mode 100644
index 0000000..0874db6
--- /dev/null
+++ b/chrome/browser/views/uninstall_dialog.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_VIEWS_UNINSTALL_DIALOG_H_
+#define CHROME_BROWSER_VIEWS_UNINSTALL_DIALOG_H_
+
+#include "base/basictypes.h"
+#include "chrome/views/window/dialog_delegate.h"
+
+class MessageBoxView;
+
+// UninstallDialog implements the dialog that confirms Chrome uninstallation
+// and asks whether to delete Chrome profile.
+class UninstallDialog : public views::DialogDelegate {
+ public:
+ static void ShowUninstallDialog(int& user_selection);
+
+ protected:
+ // Overridden from views::DialogDelegate:
+ virtual bool Accept();
+ virtual bool Cancel();
+ virtual int GetDialogButtons() const;
+ virtual std::wstring GetWindowTitle() const;
+
+ // Overridden from views::WindowDelegate:
+ virtual void DeleteDelegate();
+ virtual views::View* GetContentsView();
+
+ private:
+ explicit UninstallDialog(int& user_selection);
+ virtual ~UninstallDialog();
+
+ MessageBoxView* message_box_view_;
+ int& user_selection_;
+
+ DISALLOW_COPY_AND_ASSIGN(UninstallDialog);
+};
+
+#endif // CHROME_BROWSER_VIEWS_UNINSTALL_DIALOG_H_
diff --git a/chrome/common/result_codes.h b/chrome/common/result_codes.h
index f97e918..4c0de9d 100644
--- a/chrome/common/result_codes.h
+++ b/chrome/common/result_codes.h
@@ -36,6 +36,7 @@ class ResultCodes {
UNINSTALL_CHROME_ALIVE, // Uninstall detected another chrome instance.
UNINSTALL_NO_SURVEY, // Do not launch survey after uninstall.
UNINSTALL_USER_CANCEL, // The user changed her mind.
+ UNINSTALL_DELETE_PROFILE, // Delete profile as well during uninstall.
UNSUPPORTED_PARAM, // Command line parameter is not supported.
KILLED_BAD_MESSAGE, // A bad message caused the process termination.
IMPORTER_CANCEL, // The user canceled the browser import.
diff --git a/chrome/installer/setup/uninstall.cc b/chrome/installer/setup/uninstall.cc
index 04907e5..b1414aa 100644
--- a/chrome/installer/setup/uninstall.cc
+++ b/chrome/installer/setup/uninstall.cc
@@ -99,7 +99,7 @@ void DeleteChromeShortcut(bool system_uninstall) {
// of error (only logs the error).
bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
const installer::Version& installed_version,
- std::wstring* local_state_path) {
+ std::wstring* local_state_path, bool delete_profile) {
std::wstring install_path(installer::GetChromeInstallPath(system_uninstall));
if (install_path.empty()) {
LOG(ERROR) << "Could not get installation destination path.";
@@ -136,6 +136,13 @@ bool DeleteFilesAndFolders(const std::wstring& exe_path, bool system_uninstall,
LOG(ERROR) << "Failed to delete folder (2nd try): " << install_path;
}
+ if (delete_profile) {
+ LOG(INFO) << "Deleting user profile" << user_local_state.value();
+ if (!file_util::Delete(user_local_state, true))
+ LOG(ERROR) << "Failed to delete user profle dir: "
+ << user_local_state.value();
+ }
+
// Now check and delete if the parent directories are empty
// For example Google\Chrome or Chromium
std::wstring parent_dir = file_util::GetDirectoryFromPath(install_path);
@@ -202,8 +209,11 @@ installer_util::InstallStatus IsChromeActiveOrUserCancelled(
<< exit_code;
if ((exit_code == ResultCodes::UNINSTALL_CHROME_ALIVE) ||
(exit_code == ResultCodes::UNINSTALL_USER_CANCEL) ||
- (exit_code == ResultCodes::HUNG))
+ (exit_code == ResultCodes::HUNG)) {
return installer_util::UNINSTALL_CANCELLED;
+ } else if (exit_code == ResultCodes::UNINSTALL_DELETE_PROFILE) {
+ return installer_util::UNINSTALL_DELETE_PROFILE;
+ }
} else {
LOG(ERROR) << "Failed to launch chrome.exe for uninstall confirmation.";
}
@@ -217,10 +227,11 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
const std::wstring& exe_path, bool system_uninstall,
const installer::Version& installed_version,
bool remove_all, bool force_uninstall) {
+ installer_util::InstallStatus status = installer_util::UNINSTALL_CONFIRMED;
if (!force_uninstall) {
- installer_util::InstallStatus status =
- IsChromeActiveOrUserCancelled(system_uninstall);
- if (status != installer_util::UNINSTALL_CONFIRMED)
+ status = IsChromeActiveOrUserCancelled(system_uninstall);
+ if (status != installer_util::UNINSTALL_CONFIRMED &&
+ status != installer_util::UNINSTALL_DELETE_PROFILE)
return status;
} else {
// Since --force-uninstall command line option is used, we are going to
@@ -325,10 +336,12 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
// Finally delete all the files from Chrome folder after moving setup.exe
// and the user's Local State to a temp location.
+ bool delete_profile = (status == installer_util::UNINSTALL_DELETE_PROFILE);
std::wstring local_state_path;
+ installer_util::InstallStatus ret = installer_util::UNINSTALL_SUCCESSFUL;
if (!DeleteFilesAndFolders(exe_path, system_uninstall, installed_version,
- &local_state_path))
- return installer_util::UNINSTALL_FAILED;
+ &local_state_path, delete_profile))
+ ret = installer_util::UNINSTALL_FAILED;
if (!force_uninstall) {
LOG(INFO) << "Uninstallation complete. Launching Uninstall survey.";
@@ -340,5 +353,5 @@ installer_util::InstallStatus installer_setup::UninstallChrome(
if (!local_state_path.empty())
file_util::Delete(local_state_path, false);
- return installer_util::UNINSTALL_SUCCESSFUL;
+ return ret;
}
diff --git a/chrome/installer/util/util_constants.h b/chrome/installer/util/util_constants.h
index 3cc3fb6..f2ca6dc 100644
--- a/chrome/installer/util/util_constants.h
+++ b/chrome/installer/util/util_constants.h
@@ -28,6 +28,7 @@ enum InstallStatus {
CHROME_NOT_INSTALLED, // Chrome not installed (returned in case of uninstall)
CHROME_RUNNING, // Chrome currently running (when trying to uninstall)
UNINSTALL_CONFIRMED, // User has confirmed Chrome uninstall
+ UNINSTALL_DELETE_PROFILE, // User confirmed uninstall and profile deletion
UNINSTALL_SUCCESSFUL, // Chrome successfully uninstalled
UNINSTALL_FAILED, // Chrome uninstallation failed
UNINSTALL_CANCELLED, // User cancelled Chrome uninstallation