| OLD | NEW |
| 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/run_loop.h" |
| 10 #include "base/string16.h" | |
| 11 #include "base/utf_string_conversions.h" | |
| 12 #include "chrome/browser/shell_integration.h" | 10 #include "chrome/browser/shell_integration.h" |
| 13 #include "chrome/browser/ui/uninstall_browser_prompt.h" | 11 #include "chrome/browser/ui/uninstall_browser_prompt.h" |
| 14 #include "chrome/common/chrome_result_codes.h" | 12 #include "chrome/common/chrome_result_codes.h" |
| 15 #include "chrome/installer/util/browser_distribution.h" | 13 #include "chrome/installer/util/browser_distribution.h" |
| 16 #include "chrome/installer/util/shell_util.h" | 14 #include "chrome/installer/util/shell_util.h" |
| 17 #include "grit/chromium_strings.h" | 15 #include "grit/chromium_strings.h" |
| 18 #include "ui/base/l10n/l10n_util.h" | 16 #include "ui/base/l10n/l10n_util.h" |
| 19 #include "ui/views/controls/button/checkbox.h" | 17 #include "ui/views/controls/button/checkbox.h" |
| 20 #include "ui/views/controls/combobox/combobox.h" | 18 #include "ui/views/controls/combobox/combobox.h" |
| 21 #include "ui/views/controls/label.h" | 19 #include "ui/views/controls/label.h" |
| 22 #include "ui/views/focus/accelerator_handler.h" | 20 #include "ui/views/focus/accelerator_handler.h" |
| 23 #include "ui/views/layout/grid_layout.h" | 21 #include "ui/views/layout/grid_layout.h" |
| 24 #include "ui/views/layout/layout_constants.h" | 22 #include "ui/views/layout/layout_constants.h" |
| 25 #include "ui/views/widget/widget.h" | 23 #include "ui/views/widget/widget.h" |
| 26 | 24 |
| 27 UninstallView::UninstallView(int* user_selection, | 25 UninstallView::UninstallView(int* user_selection, |
| 28 const base::Closure& quit_closure) | 26 const base::Closure& quit_closure) |
| 29 : confirm_label_(NULL), | 27 : confirm_label_(NULL), |
| 30 delete_profile_(NULL), | 28 delete_profile_(NULL), |
| 31 change_default_browser_(NULL), | 29 change_default_browser_(NULL), |
| 32 browsers_combo_(NULL), | 30 browsers_combo_(NULL), |
| 33 browsers_(NULL), | |
| 34 user_selection_(*user_selection), | 31 user_selection_(*user_selection), |
| 35 quit_closure_(quit_closure) { | 32 quit_closure_(quit_closure) { |
| 36 SetupControls(); | 33 SetupControls(); |
| 37 } | 34 } |
| 38 | 35 |
| 39 UninstallView::~UninstallView() { | 36 UninstallView::~UninstallView() { |
| 40 // Exit the message loop we were started with so that uninstall can continue. | 37 // Exit the message loop we were started with so that uninstall can continue. |
| 41 quit_closure_.Run(); | 38 quit_closure_.Run(); |
| 42 } | 39 } |
| 43 | 40 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 151 |
| 155 int UninstallView::GetItemCount() const { | 152 int UninstallView::GetItemCount() const { |
| 156 DCHECK(!browsers_->empty()); | 153 DCHECK(!browsers_->empty()); |
| 157 return browsers_->size(); | 154 return browsers_->size(); |
| 158 } | 155 } |
| 159 | 156 |
| 160 string16 UninstallView::GetItemAt(int index) { | 157 string16 UninstallView::GetItemAt(int index) { |
| 161 DCHECK_LT(index, static_cast<int>(browsers_->size())); | 158 DCHECK_LT(index, static_cast<int>(browsers_->size())); |
| 162 BrowsersMap::const_iterator i = browsers_->begin(); | 159 BrowsersMap::const_iterator i = browsers_->begin(); |
| 163 std::advance(i, index); | 160 std::advance(i, index); |
| 164 return WideToUTF16Hack(i->first); | 161 return i->first; |
| 165 } | 162 } |
| 166 | 163 |
| 167 namespace chrome { | 164 namespace chrome { |
| 168 | 165 |
| 169 int ShowUninstallBrowserPrompt() { | 166 int ShowUninstallBrowserPrompt() { |
| 170 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); | 167 DCHECK_EQ(MessageLoop::TYPE_UI, MessageLoop::current()->type()); |
| 171 int result = content::RESULT_CODE_NORMAL_EXIT; | 168 int result = content::RESULT_CODE_NORMAL_EXIT; |
| 172 views::AcceleratorHandler accelerator_handler; | 169 views::AcceleratorHandler accelerator_handler; |
| 173 base::RunLoop run_loop(&accelerator_handler); | 170 base::RunLoop run_loop(&accelerator_handler); |
| 174 UninstallView* view = new UninstallView(&result, run_loop.QuitClosure()); | 171 UninstallView* view = new UninstallView(&result, run_loop.QuitClosure()); |
| 175 views::Widget::CreateWindow(view)->Show(); | 172 views::Widget::CreateWindow(view)->Show(); |
| 176 run_loop.Run(); | 173 run_loop.Run(); |
| 177 return result; | 174 return result; |
| 178 } | 175 } |
| 179 | 176 |
| 180 } // namespace chrome | 177 } // namespace chrome |
| OLD | NEW |