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

Side by Side Diff: chrome/browser/views/uninstall_view.cc

Issue 174194: Re-apply r23841 "During uninstall if Chrome is set as default" (Closed)
Patch Set: update for combobox model changes Created 11 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
« no previous file with comments | « chrome/browser/views/uninstall_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/views/uninstall_view.h"
6
7 #include "app/l10n_util.h"
8 #include "base/message_loop.h"
9 #include "base/process_util.h"
10 #include "chrome/browser/shell_integration.h"
11 #include "chrome/common/result_codes.h"
12 #include "chrome/installer/util/shell_util.h"
13 #include "views/controls/button/checkbox.h"
14 #include "views/controls/label.h"
15 #include "views/standard_layout.h"
16
17 #include "grit/chromium_strings.h"
18
19 UninstallView::UninstallView(int& user_selection)
20 : confirm_label_(NULL),
21 delete_profile_(NULL),
22 change_default_browser_(NULL),
23 browsers_combo_(NULL),
24 browsers_(NULL),
25 user_selection_(user_selection) {
26 SetupControls();
27 }
28
29 UninstallView::~UninstallView() {
30 // Exit the message loop we were started with so that uninstall can continue.
31 MessageLoop::current()->Quit();
32 }
33
34 void UninstallView::SetupControls() {
35 using views::ColumnSet;
36 using views::GridLayout;
37
38 GridLayout* layout = CreatePanelGridLayout(this);
39 SetLayoutManager(layout);
40
41 // Message to confirm uninstallation.
42 int column_set_id = 0;
43 ColumnSet* column_set = layout->AddColumnSet(column_set_id);
44 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
45 GridLayout::USE_PREF, 0, 0);
46 layout->StartRow(0, column_set_id);
47 confirm_label_ = new views::Label(l10n_util::GetString(IDS_UNINSTALL_VERIFY));
48 confirm_label_->SetHorizontalAlignment(views::Label::ALIGN_LEFT);
49 layout->AddView(confirm_label_);
50
51 layout->AddPaddingRow(0, kUnrelatedControlVerticalSpacing);
52
53 // The "delete profile" check box.
54 ++column_set_id;
55 column_set = layout->AddColumnSet(column_set_id);
56 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
57 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
58 GridLayout::USE_PREF, 0, 0);
59 layout->StartRow(0, column_set_id);
60 delete_profile_ = new views::Checkbox(
61 l10n_util::GetString(IDS_UNINSTALL_DELETE_PROFILE));
62 layout->AddView(delete_profile_);
63
64 // Set default browser combo box
65 if (ShellIntegration::IsDefaultBrowser()) {
66 browsers_.reset(new BrowsersMap());
67 ShellUtil::GetRegisteredBrowsers(browsers_.get());
68 if (!browsers_->empty()) {
69 layout->AddPaddingRow(0, kRelatedControlVerticalSpacing);
70
71 ++column_set_id;
72 column_set = layout->AddColumnSet(column_set_id);
73 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
74 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
75 GridLayout::USE_PREF, 0, 0);
76 column_set->AddPaddingColumn(0, kRelatedControlHorizontalSpacing);
77 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
78 GridLayout::USE_PREF, 0, 0);
79 layout->StartRow(0, column_set_id);
80 change_default_browser_ = new views::Checkbox(
81 l10n_util::GetString(IDS_UNINSTALL_SET_DEFAULT_BROWSER));
82 change_default_browser_->set_listener(this);
83 layout->AddView(change_default_browser_);
84 browsers_combo_ = new views::Combobox(this);
85 layout->AddView(browsers_combo_);
86 browsers_combo_->SetEnabled(false);
87 }
88 }
89
90 layout->AddPaddingRow(0, kRelatedControlSmallVerticalSpacing);
91 }
92
93 bool UninstallView::Accept() {
94 user_selection_ = ResultCodes::NORMAL_EXIT;
95 if (delete_profile_->checked())
96 user_selection_ = ResultCodes::UNINSTALL_DELETE_PROFILE;
97 if (change_default_browser_ && change_default_browser_->checked()) {
98 int index = browsers_combo_->selected_item();
99 BrowsersMap::const_iterator it = browsers_->begin();
100 std::advance(it, index);
101 base::LaunchApp((*it).second, false, true, NULL);
102 }
103 return true;
104 }
105
106 bool UninstallView::Cancel() {
107 user_selection_ = ResultCodes::UNINSTALL_USER_CANCEL;
108 return true;
109 }
110
111 std::wstring UninstallView::GetDialogButtonLabel(
112 MessageBoxFlags::DialogButton button) const {
113 // We only want to give custom name to OK button - 'Uninstall'. Cancel
114 // button remains same.
115 std::wstring label = L"";
116 if (button == MessageBoxFlags::DIALOGBUTTON_OK)
117 label = l10n_util::GetString(IDS_UNINSTALL_BUTTON_TEXT);
118 return label;
119 }
120
121 void UninstallView::ButtonPressed(views::Button* sender) {
122 if (change_default_browser_ == sender) {
123 // Disable the browsers combobox if the user unchecks the checkbox.
124 DCHECK(browsers_combo_);
125 browsers_combo_->SetEnabled(change_default_browser_->checked());
126 }
127 }
128
129 std::wstring UninstallView::GetWindowTitle() const {
130 return l10n_util::GetString(IDS_UNINSTALL_CHROME);
131 }
132
133 views::View* UninstallView::GetContentsView() {
134 return this;
135 }
136
137 int UninstallView::GetItemCount() {
138 DCHECK(!browsers_->empty());
139 return browsers_->size();
140 }
141
142 std::wstring UninstallView::GetItemAt(int index) {
143 DCHECK(index < (int) browsers_->size());
144 BrowsersMap::const_iterator it = browsers_->begin();
145 std::advance(it, index);
146 return (*it).first;
147 }
148
OLDNEW
« no previous file with comments | « chrome/browser/views/uninstall_view.h ('k') | chrome/chrome.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698