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

Side by Side Diff: trunk/src/chrome/browser/ui/views/uninstall_view.cc

Issue 422593002: Revert 285661 "Remove some dead app host code." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: 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/views/uninstall_view.h" 5 #include "chrome/browser/ui/views/uninstall_view.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/process/launch.h" 8 #include "base/process/launch.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/shell_integration.h" 11 #include "chrome/browser/shell_integration.h"
12 #include "chrome/browser/ui/uninstall_browser_prompt.h" 12 #include "chrome/browser/ui/uninstall_browser_prompt.h"
13 #include "chrome/common/chrome_result_codes.h" 13 #include "chrome/common/chrome_result_codes.h"
14 #include "chrome/installer/util/browser_distribution.h" 14 #include "chrome/installer/util/browser_distribution.h"
15 #include "chrome/installer/util/shell_util.h" 15 #include "chrome/installer/util/shell_util.h"
16 #include "grit/chromium_strings.h" 16 #include "grit/chromium_strings.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/views/controls/button/checkbox.h" 18 #include "ui/views/controls/button/checkbox.h"
19 #include "ui/views/controls/combobox/combobox.h" 19 #include "ui/views/controls/combobox/combobox.h"
20 #include "ui/views/controls/label.h" 20 #include "ui/views/controls/label.h"
21 #include "ui/views/layout/grid_layout.h" 21 #include "ui/views/layout/grid_layout.h"
22 #include "ui/views/layout/layout_constants.h" 22 #include "ui/views/layout/layout_constants.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 24
25 UninstallView::UninstallView(int* user_selection, 25 UninstallView::UninstallView(int* user_selection,
26 const base::Closure& quit_closure) 26 const base::Closure& quit_closure,
27 bool show_delete_profile)
27 : confirm_label_(NULL), 28 : confirm_label_(NULL),
29 show_delete_profile_(show_delete_profile),
28 delete_profile_(NULL), 30 delete_profile_(NULL),
29 change_default_browser_(NULL), 31 change_default_browser_(NULL),
30 browsers_combo_(NULL), 32 browsers_combo_(NULL),
31 user_selection_(*user_selection), 33 user_selection_(*user_selection),
32 quit_closure_(quit_closure) { 34 quit_closure_(quit_closure) {
33 SetupControls(); 35 SetupControls();
34 } 36 }
35 37
36 UninstallView::~UninstallView() { 38 UninstallView::~UninstallView() {
37 // Exit the message loop we were started with so that uninstall can continue. 39 // Exit the message loop we were started with so that uninstall can continue.
(...skipping 17 matching lines...) Expand all
55 GridLayout::USE_PREF, 0, 0); 57 GridLayout::USE_PREF, 0, 0);
56 layout->StartRow(0, column_set_id); 58 layout->StartRow(0, column_set_id);
57 confirm_label_ = new views::Label( 59 confirm_label_ = new views::Label(
58 l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY)); 60 l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY));
59 confirm_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 61 confirm_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
60 layout->AddView(confirm_label_); 62 layout->AddView(confirm_label_);
61 63
62 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 64 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
63 65
64 // The "delete profile" check box. 66 // The "delete profile" check box.
65 ++column_set_id; 67 if (show_delete_profile_) {
66 column_set = layout->AddColumnSet(column_set_id); 68 ++column_set_id;
67 column_set->AddPaddingColumn(0, views::kPanelHorizIndentation); 69 column_set = layout->AddColumnSet(column_set_id);
68 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 70 column_set->AddPaddingColumn(0, views::kPanelHorizIndentation);
69 GridLayout::USE_PREF, 0, 0); 71 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
70 layout->StartRow(0, column_set_id); 72 GridLayout::USE_PREF, 0, 0);
71 delete_profile_ = new views::Checkbox( 73 layout->StartRow(0, column_set_id);
72 l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE)); 74 delete_profile_ = new views::Checkbox(
73 layout->AddView(delete_profile_); 75 l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE));
76 layout->AddView(delete_profile_);
77 }
74 78
75 // Set default browser combo box. If the default should not or cannot be 79 // Set default browser combo box. If the default should not or cannot be
76 // changed, widgets are not shown. We assume here that if Chrome cannot 80 // changed, widgets are not shown. We assume here that if Chrome cannot
77 // be set programatically as default, neither can any other browser (for 81 // be set programatically as default, neither can any other browser (for
78 // instance because the OS doesn't permit that). 82 // instance because the OS doesn't permit that).
79 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 83 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
80 if (dist->GetDefaultBrowserControlPolicy() != 84 if (dist->GetDefaultBrowserControlPolicy() !=
81 BrowserDistribution::DEFAULT_BROWSER_UNSUPPORTED && 85 BrowserDistribution::DEFAULT_BROWSER_UNSUPPORTED &&
82 ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT && 86 ShellIntegration::GetDefaultBrowser() == ShellIntegration::IS_DEFAULT &&
83 (ShellIntegration::CanSetAsDefaultBrowser() != 87 (ShellIntegration::CanSetAsDefaultBrowser() !=
(...skipping 20 matching lines...) Expand all
104 layout->AddView(browsers_combo_); 108 layout->AddView(browsers_combo_);
105 browsers_combo_->SetEnabled(false); 109 browsers_combo_->SetEnabled(false);
106 } 110 }
107 } 111 }
108 112
109 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); 113 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing);
110 } 114 }
111 115
112 bool UninstallView::Accept() { 116 bool UninstallView::Accept() {
113 user_selection_ = content::RESULT_CODE_NORMAL_EXIT; 117 user_selection_ = content::RESULT_CODE_NORMAL_EXIT;
114 if (delete_profile_->checked()) 118 if (show_delete_profile_ && delete_profile_->checked())
115 user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE; 119 user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE;
116 if (change_default_browser_ && change_default_browser_->checked()) { 120 if (change_default_browser_ && change_default_browser_->checked()) {
117 BrowsersMap::const_iterator i = browsers_->begin(); 121 BrowsersMap::const_iterator i = browsers_->begin();
118 std::advance(i, browsers_combo_->selected_index()); 122 std::advance(i, browsers_combo_->selected_index());
119 base::LaunchOptions options; 123 base::LaunchOptions options;
120 options.start_hidden = true; 124 options.start_hidden = true;
121 base::LaunchProcess(i->second, options, NULL); 125 base::LaunchProcess(i->second, options, NULL);
122 } 126 }
123 return true; 127 return true;
124 } 128 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 160
157 base::string16 UninstallView::GetItemAt(int index) { 161 base::string16 UninstallView::GetItemAt(int index) {
158 DCHECK_LT(index, static_cast<int>(browsers_->size())); 162 DCHECK_LT(index, static_cast<int>(browsers_->size()));
159 BrowsersMap::const_iterator i = browsers_->begin(); 163 BrowsersMap::const_iterator i = browsers_->begin();
160 std::advance(i, index); 164 std::advance(i, index);
161 return i->first; 165 return i->first;
162 } 166 }
163 167
164 namespace chrome { 168 namespace chrome {
165 169
166 int ShowUninstallBrowserPrompt() { 170 int ShowUninstallBrowserPrompt(bool show_delete_profile) {
167 DCHECK(base::MessageLoopForUI::IsCurrent()); 171 DCHECK(base::MessageLoopForUI::IsCurrent());
168 int result = content::RESULT_CODE_NORMAL_EXIT; 172 int result = content::RESULT_CODE_NORMAL_EXIT;
169 173
170 // Take a reference on g_browser_process while showing the dialog. This is 174 // Take a reference on g_browser_process while showing the dialog. This is
171 // done because the dialog uses the views framework which may increment 175 // done because the dialog uses the views framework which may increment
172 // and decrement the module ref count during the course of displaying UI and 176 // and decrement the module ref count during the course of displaying UI and
173 // this code can be called while the module refcount is still at 0. 177 // this code can be called while the module refcount is still at 0.
174 // Note that this reference is never released, as this code is shown on a path 178 // Note that this reference is never released, as this code is shown on a path
175 // that immediately exits Chrome anyway. 179 // that immediately exits Chrome anyway.
176 // See http://crbug.com/241366 for details. 180 // See http://crbug.com/241366 for details.
177 g_browser_process->AddRefModule(); 181 g_browser_process->AddRefModule();
178 182
179 base::RunLoop run_loop; 183 base::RunLoop run_loop;
180 UninstallView* view = new UninstallView(&result, 184 UninstallView* view = new UninstallView(&result,
181 run_loop.QuitClosure()); 185 run_loop.QuitClosure(),
186 show_delete_profile);
182 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show(); 187 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show();
183 run_loop.Run(); 188 run_loop.Run();
184 return result; 189 return result;
185 } 190 }
186 191
187 } // namespace chrome 192 } // namespace chrome
OLDNEW
« no previous file with comments | « trunk/src/chrome/browser/ui/views/uninstall_view.h ('k') | trunk/src/chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698