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

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

Issue 2867253003: Description: Views/Harmony Remove references to ui/views/layout/layout_constants.h (Closed)
Patch Set: Address comments Created 3 years, 7 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/ui/views/conflicting_module_view_win.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/lifetime/keep_alive_types.h" 10 #include "chrome/browser/lifetime/keep_alive_types.h"
11 #include "chrome/browser/lifetime/scoped_keep_alive.h" 11 #include "chrome/browser/lifetime/scoped_keep_alive.h"
12 #include "chrome/browser/shell_integration.h" 12 #include "chrome/browser/shell_integration.h"
13 #include "chrome/browser/ui/uninstall_browser_prompt.h" 13 #include "chrome/browser/ui/uninstall_browser_prompt.h"
14 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h"
14 #include "chrome/common/chrome_result_codes.h" 15 #include "chrome/common/chrome_result_codes.h"
15 #include "chrome/grit/chromium_strings.h" 16 #include "chrome/grit/chromium_strings.h"
16 #include "chrome/installer/util/shell_util.h" 17 #include "chrome/installer/util/shell_util.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/layout/grid_layout.h" 22 #include "ui/views/layout/grid_layout.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 : confirm_label_(NULL), 27 : confirm_label_(NULL),
28 delete_profile_(NULL), 28 delete_profile_(NULL),
29 change_default_browser_(NULL), 29 change_default_browser_(NULL),
30 browsers_combo_(NULL), 30 browsers_combo_(NULL),
31 user_selection_(*user_selection), 31 user_selection_(*user_selection),
32 quit_closure_(quit_closure) { 32 quit_closure_(quit_closure) {
(...skipping 18 matching lines...) Expand all
51 int column_set_id = 0; 51 int column_set_id = 0;
52 ColumnSet* column_set = layout->AddColumnSet(column_set_id); 52 ColumnSet* column_set = layout->AddColumnSet(column_set_id);
53 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 53 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
54 GridLayout::USE_PREF, 0, 0); 54 GridLayout::USE_PREF, 0, 0);
55 layout->StartRow(0, column_set_id); 55 layout->StartRow(0, column_set_id);
56 confirm_label_ = new views::Label( 56 confirm_label_ = new views::Label(
57 l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY)); 57 l10n_util::GetStringUTF16(IDS_UNINSTALL_VERIFY));
58 confirm_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT); 58 confirm_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
59 layout->AddView(confirm_label_); 59 layout->AddView(confirm_label_);
60 60
61 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 61 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get();
62
63 const int checkbox_indent = provider->GetDistanceMetric(
64 DISTANCE_SUBSECTION_HORIZONTAL_INDENT);
65 const int unrelated_vertical_spacing = provider->GetDistanceMetric(
66 DISTANCE_UNRELATED_CONTROL_VERTICAL);
67 const int related_vertical_spacing = provider->GetDistanceMetric(
68 views::DISTANCE_RELATED_CONTROL_VERTICAL);
69 const int related_horizontal_spacing = provider->GetDistanceMetric(
70 views::DISTANCE_RELATED_CONTROL_HORIZONTAL);
71 const int related_vertical_small = provider->GetDistanceMetric(
72 DISTANCE_RELATED_CONTROL_VERTICAL_SMALL);
73
74 layout->AddPaddingRow(0, unrelated_vertical_spacing);
62 75
63 // The "delete profile" check box. 76 // The "delete profile" check box.
64 ++column_set_id; 77 ++column_set_id;
65 column_set = layout->AddColumnSet(column_set_id); 78 column_set = layout->AddColumnSet(column_set_id);
66 column_set->AddPaddingColumn(0, views::kCheckboxIndent); 79 column_set->AddPaddingColumn(0, checkbox_indent);
67 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 80 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
68 GridLayout::USE_PREF, 0, 0); 81 GridLayout::USE_PREF, 0, 0);
69 layout->StartRow(0, column_set_id); 82 layout->StartRow(0, column_set_id);
70 delete_profile_ = new views::Checkbox( 83 delete_profile_ = new views::Checkbox(
71 l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE)); 84 l10n_util::GetStringUTF16(IDS_UNINSTALL_DELETE_PROFILE));
72 layout->AddView(delete_profile_); 85 layout->AddView(delete_profile_);
73 86
74 // Set default browser combo box. If the default should not or cannot be 87 // Set default browser combo box. If the default should not or cannot be
75 // changed, widgets are not shown. We assume here that if Chrome cannot 88 // changed, widgets are not shown. We assume here that if Chrome cannot
76 // be set programatically as default, neither can any other browser (for 89 // be set programatically as default, neither can any other browser (for
77 // instance because the OS doesn't permit that). 90 // instance because the OS doesn't permit that).
78 if (ShellUtil::CanMakeChromeDefaultUnattended() && 91 if (ShellUtil::CanMakeChromeDefaultUnattended() &&
79 shell_integration::GetDefaultBrowser() == shell_integration::IS_DEFAULT) { 92 shell_integration::GetDefaultBrowser() == shell_integration::IS_DEFAULT) {
80 browsers_.reset(new BrowsersMap()); 93 browsers_.reset(new BrowsersMap());
81 ShellUtil::GetRegisteredBrowsers(browsers_.get()); 94 ShellUtil::GetRegisteredBrowsers(browsers_.get());
82 if (!browsers_->empty()) { 95 if (!browsers_->empty()) {
83 layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); 96 layout->AddPaddingRow(0, related_vertical_spacing);
84 97
85 ++column_set_id; 98 ++column_set_id;
86 column_set = layout->AddColumnSet(column_set_id); 99 column_set = layout->AddColumnSet(column_set_id);
87 column_set->AddPaddingColumn(0, views::kCheckboxIndent); 100 column_set->AddPaddingColumn(0, checkbox_indent);
88 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 101 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
89 GridLayout::USE_PREF, 0, 0); 102 GridLayout::USE_PREF, 0, 0);
90 column_set->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); 103 column_set->AddPaddingColumn(0, related_horizontal_spacing);
91 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0, 104 column_set->AddColumn(GridLayout::LEADING, GridLayout::CENTER, 0,
92 GridLayout::USE_PREF, 0, 0); 105 GridLayout::USE_PREF, 0, 0);
93 layout->StartRow(0, column_set_id); 106 layout->StartRow(0, column_set_id);
94 change_default_browser_ = new views::Checkbox( 107 change_default_browser_ = new views::Checkbox(
95 l10n_util::GetStringUTF16(IDS_UNINSTALL_SET_DEFAULT_BROWSER)); 108 l10n_util::GetStringUTF16(IDS_UNINSTALL_SET_DEFAULT_BROWSER));
96 change_default_browser_->set_listener(this); 109 change_default_browser_->set_listener(this);
97 layout->AddView(change_default_browser_); 110 layout->AddView(change_default_browser_);
98 browsers_combo_ = new views::Combobox(this); 111 browsers_combo_ = new views::Combobox(this);
99 layout->AddView(browsers_combo_); 112 layout->AddView(browsers_combo_);
100 browsers_combo_->SetEnabled(false); 113 browsers_combo_->SetEnabled(false);
101 } 114 }
102 } 115 }
103 116
104 layout->AddPaddingRow(0, views::kRelatedControlSmallVerticalSpacing); 117 layout->AddPaddingRow(0, related_vertical_small);
105 } 118 }
106 119
107 bool UninstallView::Accept() { 120 bool UninstallView::Accept() {
108 user_selection_ = content::RESULT_CODE_NORMAL_EXIT; 121 user_selection_ = content::RESULT_CODE_NORMAL_EXIT;
109 if (delete_profile_->checked()) 122 if (delete_profile_->checked())
110 user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE; 123 user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE;
111 if (change_default_browser_ && change_default_browser_->checked()) { 124 if (change_default_browser_ && change_default_browser_->checked()) {
112 BrowsersMap::const_iterator i = browsers_->begin(); 125 BrowsersMap::const_iterator i = browsers_->begin();
113 std::advance(i, browsers_combo_->selected_index()); 126 std::advance(i, browsers_combo_->selected_index());
114 base::LaunchOptions options; 127 base::LaunchOptions options;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 187
175 base::RunLoop run_loop; 188 base::RunLoop run_loop;
176 UninstallView* view = new UninstallView(&result, 189 UninstallView* view = new UninstallView(&result,
177 run_loop.QuitClosure()); 190 run_loop.QuitClosure());
178 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show(); 191 views::DialogDelegate::CreateDialogWidget(view, NULL, NULL)->Show();
179 run_loop.Run(); 192 run_loop.Run();
180 return result; 193 return result;
181 } 194 }
182 195
183 } // namespace chrome 196 } // namespace chrome
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/conflicting_module_view_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698