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

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

Issue 10479018: Add base::RunLoop and update ui_test_utils to use it to reduce flakiness (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: phajdan feedback Created 8 years, 5 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.h" 7 #include "base/message_loop.h"
8 #include "base/process_util.h" 8 #include "base/process_util.h"
9 #include "base/run_loop.h"
9 #include "base/string16.h" 10 #include "base/string16.h"
10 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/shell_integration.h" 12 #include "chrome/browser/shell_integration.h"
12 #include "chrome/browser/ui/uninstall_browser_prompt.h" 13 #include "chrome/browser/ui/uninstall_browser_prompt.h"
13 #include "chrome/common/chrome_result_codes.h" 14 #include "chrome/common/chrome_result_codes.h"
14 #include "chrome/installer/util/browser_distribution.h" 15 #include "chrome/installer/util/browser_distribution.h"
15 #include "chrome/installer/util/shell_util.h" 16 #include "chrome/installer/util/shell_util.h"
16 #include "grit/chromium_strings.h" 17 #include "grit/chromium_strings.h"
17 #include "ui/base/l10n/l10n_util.h" 18 #include "ui/base/l10n/l10n_util.h"
18 #include "ui/views/controls/button/checkbox.h" 19 #include "ui/views/controls/button/checkbox.h"
19 #include "ui/views/controls/combobox/combobox.h" 20 #include "ui/views/controls/combobox/combobox.h"
20 #include "ui/views/controls/label.h" 21 #include "ui/views/controls/label.h"
21 #include "ui/views/focus/accelerator_handler.h" 22 #include "ui/views/focus/accelerator_handler.h"
22 #include "ui/views/layout/grid_layout.h" 23 #include "ui/views/layout/grid_layout.h"
23 #include "ui/views/layout/layout_constants.h" 24 #include "ui/views/layout/layout_constants.h"
24 #include "ui/views/widget/widget.h" 25 #include "ui/views/widget/widget.h"
25 26
26 UninstallView::UninstallView(int* user_selection) 27 UninstallView::UninstallView(int* user_selection,
28 const base::Closure& quit_closure)
27 : confirm_label_(NULL), 29 : confirm_label_(NULL),
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 browsers_(NULL), 33 browsers_(NULL),
32 user_selection_(*user_selection) { 34 user_selection_(*user_selection),
35 quit_closure_(quit_closure) {
33 SetupControls(); 36 SetupControls();
34 } 37 }
35 38
36 UninstallView::~UninstallView() { 39 UninstallView::~UninstallView() {
37 // Exit the message loop we were started with so that uninstall can continue. 40 // Exit the message loop we were started with so that uninstall can continue.
38 MessageLoop::current()->Quit(); 41 quit_closure_.Run();
39 } 42 }
40 43
41 void UninstallView::SetupControls() { 44 void UninstallView::SetupControls() {
42 using views::ColumnSet; 45 using views::ColumnSet;
43 using views::GridLayout; 46 using views::GridLayout;
44 47
45 GridLayout* layout = GridLayout::CreatePanel(this); 48 GridLayout* layout = GridLayout::CreatePanel(this);
46 SetLayoutManager(layout); 49 SetLayoutManager(layout);
47 50
48 // Message to confirm uninstallation. 51 // Message to confirm uninstallation.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 string16 UninstallView::GetItemAt(int index) { 160 string16 UninstallView::GetItemAt(int index) {
158 DCHECK_LT(index, static_cast<int>(browsers_->size())); 161 DCHECK_LT(index, static_cast<int>(browsers_->size()));
159 BrowsersMap::const_iterator i = browsers_->begin(); 162 BrowsersMap::const_iterator i = browsers_->begin();
160 std::advance(i, index); 163 std::advance(i, index);
161 return WideToUTF16Hack(i->first); 164 return WideToUTF16Hack(i->first);
162 } 165 }
163 166
164 namespace browser { 167 namespace browser {
165 168
166 int ShowUninstallBrowserPrompt() { 169 int ShowUninstallBrowserPrompt() {
170 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type());
167 int result = content::RESULT_CODE_NORMAL_EXIT; 171 int result = content::RESULT_CODE_NORMAL_EXIT;
168 views::Widget::CreateWindow(new UninstallView(&result))->Show();
169 views::AcceleratorHandler accelerator_handler; 172 views::AcceleratorHandler accelerator_handler;
170 MessageLoopForUI::current()->RunWithDispatcher(&accelerator_handler); 173 base::RunLoop run_loop(&accelerator_handler);
174 UninstallView* view = new UninstallView(&result, run_loop.QuitClosure());
175 views::Widget::CreateWindow(view)->Show();
176 run_loop.Run();
171 return result; 177 return result;
172 } 178 }
173 179
174 } // namespace browser 180 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/uninstall_view.h ('k') | chrome/browser/ui/views/user_data_dir_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698