diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:40:51 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-20 18:40:51 +0000 |
commit | 230388a45910240cd770cd5a29a39bad4ca19ce4 (patch) | |
tree | acf911adf01178edd97294e1ad0dfc75adec8018 | |
parent | 11495b1be2bf51b887a9403cb164ff21e0640f1a (diff) | |
download | chromium_src-230388a45910240cd770cd5a29a39bad4ca19ce4.zip chromium_src-230388a45910240cd770cd5a29a39bad4ca19ce4.tar.gz chromium_src-230388a45910240cd770cd5a29a39bad4ca19ce4.tar.bz2 |
Revert "During uninstall if Chrome is set as default,"
allow user to choose another browser as default."
reverting r23841
Review URL: http://codereview.chromium.org/173131
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23845 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/app/chromium_strings.grd | 6 | ||||
-rw-r--r-- | chrome/app/google_chrome_strings.grd | 6 | ||||
-rw-r--r-- | chrome/browser/browser_main_win.cc | 17 | ||||
-rw-r--r-- | chrome/browser/views/uninstall_dialog.cc | 61 | ||||
-rw-r--r-- | chrome/browser/views/uninstall_dialog.h | 39 | ||||
-rw-r--r-- | chrome/browser/views/uninstall_view.cc | 150 | ||||
-rw-r--r-- | chrome/browser/views/uninstall_view.h | 59 | ||||
-rw-r--r-- | chrome/chrome.gyp | 4 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.cc | 26 | ||||
-rw-r--r-- | chrome/installer/util/shell_util.h | 6 |
10 files changed, 106 insertions, 268 deletions
diff --git a/chrome/app/chromium_strings.grd b/chrome/app/chromium_strings.grd index 2127282..08798da 100644 --- a/chrome/app/chromium_strings.grd +++ b/chrome/app/chromium_strings.grd @@ -337,12 +337,6 @@ be available for now. --> <message name="IDS_UNINSTALL_DELETE_PROFILE" desc="Text to show user to ask whether to delete all the profile data also during uninstallation."> Also delete your browsing data? </message> - <message name="IDS_UNINSTALL_SET_DEFAULT_BROWSER" desc="Text to ask whether to set another browser as default when Chromium is uninstalled."> - Change default browser to: - </message> - <message name="IDS_UNINSTALL_BUTTON_TEXT" desc="Label for uninstall button on Uninstall confirmation dialog."> - Uninstall - </message> <message name="IDS_DEFAULT_BROWSER_INFOBAR_TEXT" desc="Text to show in the default browser query infobar."> Hooray, you're back! But Chromium isn't your default browser. </message> diff --git a/chrome/app/google_chrome_strings.grd b/chrome/app/google_chrome_strings.grd index bec59f6..3b2c32f 100644 --- a/chrome/app/google_chrome_strings.grd +++ b/chrome/app/google_chrome_strings.grd @@ -385,12 +385,6 @@ Chrome supports. --> <message name="IDS_UNINSTALL_DELETE_PROFILE" desc="Text to show user to ask whether to delete all the profile data also during uninstallation."> Also delete your browsing data? </message> - <message name="IDS_UNINSTALL_SET_DEFAULT_BROWSER" desc="Text to ask whether to set another browser as default when Chromium is uninstalled."> - Change default browser to: - </message> - <message name="IDS_UNINSTALL_BUTTON_TEXT" desc="Label for uninstall button on Uninstall confirmation dialog."> - Uninstall - </message> <message name="IDS_DEFAULT_BROWSER_INFOBAR_TEXT" desc="Text to show in the default browser query infobar."> Hooray, you're back! But Google Chrome isn't your default browser. </message> diff --git a/chrome/browser/browser_main_win.cc b/chrome/browser/browser_main_win.cc index cb3551a..b4f1052 100644 --- a/chrome/browser/browser_main_win.cc +++ b/chrome/browser/browser_main_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2008 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. @@ -15,7 +15,7 @@ #include "base/win_util.h" #include "chrome/browser/first_run.h" #include "chrome/browser/metrics/metrics_service.h" -#include "chrome/browser/views/uninstall_view.h" +#include "chrome/browser/views/uninstall_dialog.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/env_vars.h" #include "chrome/common/result_codes.h" @@ -24,6 +24,7 @@ #include "chrome/installer/util/shell_util.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" +#include "views/controls/message_box_view.h" #include "views/focus/accelerator_handler.h" #include "views/window/window.h" @@ -42,8 +43,7 @@ bool CheckForWin2000() { int AskForUninstallConfirmation() { int ret = ResultCodes::NORMAL_EXIT; - views::Window::CreateChromeWindow(NULL, gfx::Rect(), - new UninstallView(ret))->Show(); + UninstallDialog::ShowUninstallDialog(ret); views::AcceleratorHandler accelerator_handler; MessageLoopForUI::current()->Run(&accelerator_handler); return ret; @@ -57,20 +57,11 @@ void ShowCloseBrowserFirstMessageBox() { } int DoUninstallTasks(bool chrome_still_running) { - // We want to show a warning to user (and exit) if Chrome is already running - // *before* we show the uninstall confirmation dialog box. But while the - // uninstall confirmation dialog is up, user might start Chrome, so we - // check once again after user acknowledges Uninstall dialog. if (chrome_still_running) { ShowCloseBrowserFirstMessageBox(); return ResultCodes::UNINSTALL_CHROME_ALIVE; } int ret = AskForUninstallConfirmation(); - if (Upgrade::IsBrowserAlreadyRunning()) { - ShowCloseBrowserFirstMessageBox(); - return ResultCodes::UNINSTALL_CHROME_ALIVE; - } - if (ret != ResultCodes::UNINSTALL_USER_CANCEL) { // The following actions are just best effort. LOG(INFO) << "Executing uninstall actions"; diff --git a/chrome/browser/views/uninstall_dialog.cc b/chrome/browser/views/uninstall_dialog.cc new file mode 100644 index 0000000..f54fbc8 --- /dev/null +++ b/chrome/browser/views/uninstall_dialog.cc @@ -0,0 +1,61 @@ +// 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 "app/l10n_util.h" +#include "app/message_box_flags.h" +#include "base/message_loop.h" +#include "chrome/common/result_codes.h" +#include "grit/chromium_strings.h" +#include "views/controls/message_box_view.h" +#include "views/window/window.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; +} + +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( + MessageBoxFlags::kIsConfirmMessageBox | + MessageBoxFlags::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..6987cb2 --- /dev/null +++ b/chrome/browser/views/uninstall_dialog.h @@ -0,0 +1,39 @@ +// 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 "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 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/browser/views/uninstall_view.cc b/chrome/browser/views/uninstall_view.cc deleted file mode 100644 index c0438b1..0000000 --- a/chrome/browser/views/uninstall_view.cc +++ /dev/null @@ -1,150 +0,0 @@ -// 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_view.h" - -#include "app/l10n_util.h" -#include "base/message_loop.h" -#include "base/process_util.h" -#include "chrome/browser/shell_integration.h" -#include "chrome/common/result_codes.h" -#include "chrome/installer/util/shell_util.h" -#include "views/controls/button/checkbox.h" -#include "views/controls/label.h" -#include "views/standard_layout.h" - -#include "grit/chromium_strings.h" - -UninstallView::UninstallView(int& user_selection) - : confirm_label_(NULL), - delete_profile_(NULL), - change_default_browser_(NULL), - browsers_combo_(NULL), - browsers_(NULL), - user_selection_(user_selection) { - SetupControls(); -} - -UninstallView::~UninstallView() { - // Exit the message loop we were started with so that uninstall can continue. - MessageLoop::current()->Quit(); -} - -void UninstallView::SetupControls() { - using views::ColumnSet; - using views::GridLayout; - - GridLayout* layout = CreatePanelGridLayout(this); - SetLayoutManager(layout); - - // Message to confirm uninstallation. - int column_set_id = 0; - ColumnSet* column_set = layout->AddColumnSet(column_set_id); - column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - layout->StartRow(0, column_set_id); - confirm_label_ = new views::Label(l10n_util::GetString(IDS_UNINSTALL_VERIFY)); - confirm_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT); - layout->AddView(confirm_label_); - - layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing); - - // The "delete profile" check box. - ++column_set_id; - column_set = layout->AddColumnSet(column_set_id); - column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - layout->StartRow(0, column_set_id); - delete_profile_ = new views::Checkbox( - l10n_util::GetString(IDS_UNINSTALL_DELETE_PROFILE)); - layout->AddView(delete_profile_); - - // Set default browser combo box - if (ShellIntegration::IsDefaultBrowser()) { - browsers_.reset(new BrowsersMap()); - ShellUtil::GetRegisteredBrowsers(browsers_.get()); - if (!browsers_->empty()) { - layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); - - ++column_set_id; - column_set = layout->AddColumnSet(column_set_id); - column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing); - column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, - GridLayout::USE_PREF, 0, 0); - layout->StartRow(0, column_set_id); - change_default_browser_ = new views::Checkbox( - l10n_util::GetString(IDS_UNINSTALL_SET_DEFAULT_BROWSER)); - change_default_browser_->set_listener(this); - layout->AddView(change_default_browser_); - browsers_combo_ = new views::Combobox(this); - layout->AddView(browsers_combo_); - browsers_combo_->SetEnabled(false); - } - } - - layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing); -} - -bool UninstallView::Accept() { - user_selection_ = ResultCodes::NORMAL_EXIT; - if (delete_profile_->checked()) - user_selection_ = ResultCodes::UNINSTALL_DELETE_PROFILE; - if (change_default_browser_ && change_default_browser_->checked()) { - int index = browsers_combo_->selected_item(); - BrowsersMap::const_iterator it = browsers_->begin(); - std::advance(it, index); - base::LaunchApp((*it).second, false, true, NULL); - } - return true; -} - -bool UninstallView::Cancel() { - user_selection_ = ResultCodes::UNINSTALL_USER_CANCEL; - return true; -} - -std::wstring UninstallView::GetDialogButtonLabel( - MessageBoxFlags::DialogButton button) const { - // We only want to give custom name to OK button - 'Uninstall'. Cancel - // button remains same. - std::wstring label = L""; - if (button == MessageBoxFlags::DIALOGBUTTON_OK) - label = l10n_util::GetString(IDS_UNINSTALL_BUTTON_TEXT); - return label; -} - -void UninstallView::ButtonPressed(views::Button* sender) { - if (change_default_browser_ == sender) { - // Disable the browsers combobox if the user unchecks the checkbox. - DCHECK(browsers_combo_); - browsers_combo_->SetEnabled(change_default_browser_->checked()); - } -} - -std::wstring UninstallView::GetWindowTitle() const { - return l10n_util::GetString(IDS_UNINSTALL_CHROME); -} - -views::View* UninstallView::GetContentsView() { - return this; -} - -int UninstallView::GetItemCount(views::Combobox* source) { - DCHECK(source == browsers_combo_); - DCHECK(!browsers_->empty()); - return browsers_->size(); -} - -std::wstring UninstallView::GetItemAt(views::Combobox* source, int index) { - DCHECK(source == browsers_combo_); - DCHECK(index < (int) browsers_->size()); - BrowsersMap::const_iterator it = browsers_->begin(); - std::advance(it, index); - return (*it).first; -} - diff --git a/chrome/browser/views/uninstall_view.h b/chrome/browser/views/uninstall_view.h deleted file mode 100644 index 6b5933c..0000000 --- a/chrome/browser/views/uninstall_view.h +++ /dev/null @@ -1,59 +0,0 @@ -// 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_VIEW_H_ -#define CHROME_BROWSER_VIEWS_UNINSTALL_VIEW_H_ - -#include "views/controls/combobox/combobox.h" -#include "views/window/dialog_delegate.h" - -namespace views { -class Checkbox; -class Label; -} - -// UninstallView implements the dialog that confirms Chrome uninstallation -// and asks whether to delete Chrome profile. Also if currently Chrome is set -// as default browser, it asks users whether to set another browser as default. -class UninstallView : public views::View, - public views::ButtonListener, - public views::DialogDelegate, - public views::Combobox::Model { - public: - explicit UninstallView(int& user_selection); - virtual ~UninstallView(); - - // Overridden from views::DialogDelegate: - virtual bool Accept(); - virtual bool Cancel(); - virtual std::wstring GetDialogButtonLabel( - MessageBoxFlags::DialogButton button) const; - - // Overridden form views::ButtonListener. - virtual void ButtonPressed(views::Button* sender); - - // Overridden from views::WindowDelegate: - virtual std::wstring GetWindowTitle() const; - virtual views::View* GetContentsView(); - - // Overridden from views::Combobox::Model. - virtual int GetItemCount(views::Combobox* source); - virtual std::wstring GetItemAt(views::Combobox* source, int index); - - private: - // Initializes the controls on the dialog. - void SetupControls(); - - views::Label* confirm_label_; - views::Checkbox* delete_profile_; - views::Checkbox* change_default_browser_; - views::Combobox* browsers_combo_; - typedef std::map<std::wstring, std::wstring> BrowsersMap; - scoped_ptr<BrowsersMap> browsers_; - int& user_selection_; - - DISALLOW_COPY_AND_ASSIGN(UninstallView); -}; - -#endif // CHROME_BROWSER_VIEWS_UNINSTALL_VIEW_H_
\ No newline at end of file diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 9cc69e3..9b7b71e 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -2012,8 +2012,8 @@ 'browser/views/toolbar_star_toggle.h', 'browser/views/toolbar_view.cc', 'browser/views/toolbar_view.h', - 'browser/views/uninstall_view.cc', - 'browser/views/uninstall_view.h', + 'browser/views/uninstall_dialog.cc', + 'browser/views/uninstall_dialog.h', 'browser/views/url_picker.cc', 'browser/views/url_picker.h', 'browser/views/user_data_dir_dialog.cc', diff --git a/chrome/installer/util/shell_util.cc b/chrome/installer/util/shell_util.cc index f21aeab..88674dc 100644 --- a/chrome/installer/util/shell_util.cc +++ b/chrome/installer/util/shell_util.cc @@ -583,32 +583,6 @@ bool ShellUtil::GetQuickLaunchPath(bool system_level, std::wstring* path) { return true; } -void ShellUtil::GetRegisteredBrowsers(std::map<std::wstring, - std::wstring>* browsers) { - std::wstring base_key(ShellUtil::kRegStartMenuInternet); - HKEY root = HKEY_LOCAL_MACHINE; - for (RegistryKeyIterator iter(root, base_key.c_str()); iter.Valid(); ++iter) { - std::wstring key = base_key + L"\\" + iter.Name(); - RegKey capabilities(root, (key + L"\\Capabilities").c_str()); - std::wstring name; - if (!capabilities.Valid() || - !capabilities.ReadValue(L"ApplicationName", &name)) { - RegKey base_key(root, key.c_str()); - if (!base_key.ReadValue(L"", &name)) - continue; - } - RegKey install_info(root, (key + L"\\InstallInfo").c_str()); - std::wstring command; - if (!install_info.Valid() || - !install_info.ReadValue(L"ReinstallCommand", &command)) - continue; - BrowserDistribution* dist = BrowserDistribution::GetDistribution(); - if (!name.empty() && !command.empty() && - name.find(dist->GetApplicationName()) == std::wstring::npos) - (*browsers)[name] = command; - } -} - bool ShellUtil::GetUserSpecificDefaultBrowserSuffix(std::wstring* entry) { wchar_t user_name[256]; DWORD size = _countof(user_name); diff --git a/chrome/installer/util/shell_util.h b/chrome/installer/util/shell_util.h index 99f88b8..ca6eac7 100644 --- a/chrome/installer/util/shell_util.h +++ b/chrome/installer/util/shell_util.h @@ -10,7 +10,6 @@ #define CHROME_INSTALLER_UTIL_SHELL_UTIL_H_ #include <windows.h> -#include <map> #include <string> #include "base/basictypes.h" @@ -140,11 +139,6 @@ class ShellUtil { // User's profile only affects any new user profiles (not existing ones). static bool GetQuickLaunchPath(bool system_level, std::wstring* path); - // Gets a mapping of all registered browser (on local machine) names and - // thier reinstall command (which usually sets browser as default). - static void GetRegisteredBrowsers(std::map<std::wstring, - std::wstring>* browsers); - // This function gets a suffix (user's login name) that can be added // to Chromium default browser entry in the registry to create a unique name // if there are multiple users on the machine, each with their own copy of |