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/first_run/try_chrome_dialog_view.h" | 5 #include "chrome/browser/ui/views/try_chrome_dialog_view.h" |
6 | 6 |
7 #include <shellapi.h> | 7 #include <shellapi.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
12 #include "base/run_loop.h" | 12 #include "base/run_loop.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "chrome/browser/process_singleton.h" | 14 #include "chrome/browser/process_singleton.h" |
15 #include "chrome/browser/ui/views/harmony/chrome_layout_provider.h" | |
15 #include "chrome/grit/chromium_strings.h" | 16 #include "chrome/grit/chromium_strings.h" |
16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
17 #include "chrome/grit/theme_resources.h" | 18 #include "chrome/grit/theme_resources.h" |
18 #include "chrome/install_static/install_util.h" | 19 #include "chrome/install_static/install_util.h" |
19 #include "chrome/installer/util/user_experiment.h" | 20 #include "chrome/installer/util/user_experiment.h" |
20 #include "components/strings/grit/components_strings.h" | 21 #include "components/strings/grit/components_strings.h" |
21 #include "ui/aura/window.h" | 22 #include "ui/aura/window.h" |
22 #include "ui/aura/window_tree_host.h" | 23 #include "ui/aura/window_tree_host.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 25 #include "ui/base/resource/resource_bundle.h" |
26 #include "ui/display/screen.h" | |
25 #include "ui/gfx/image/image.h" | 27 #include "ui/gfx/image/image.h" |
26 #include "ui/resources/grit/ui_resources.h" | 28 #include "ui/resources/grit/ui_resources.h" |
27 #include "ui/views/background.h" | 29 #include "ui/views/background.h" |
28 #include "ui/views/controls/button/checkbox.h" | 30 #include "ui/views/controls/button/checkbox.h" |
29 #include "ui/views/controls/button/image_button.h" | 31 #include "ui/views/controls/button/image_button.h" |
30 #include "ui/views/controls/button/md_text_button.h" | 32 #include "ui/views/controls/button/md_text_button.h" |
31 #include "ui/views/controls/button/radio_button.h" | 33 #include "ui/views/controls/button/radio_button.h" |
32 #include "ui/views/controls/image_view.h" | 34 #include "ui/views/controls/image_view.h" |
33 #include "ui/views/controls/link.h" | 35 #include "ui/views/controls/link.h" |
34 #include "ui/views/controls/separator.h" | 36 #include "ui/views/controls/separator.h" |
35 #include "ui/views/layout/grid_layout.h" | 37 #include "ui/views/layout/grid_layout.h" |
36 #include "ui/views/layout/layout_constants.h" | |
37 #include "ui/views/layout/layout_provider.h" | 38 #include "ui/views/layout/layout_provider.h" |
38 #include "ui/views/widget/widget.h" | 39 #include "ui/views/widget/widget.h" |
39 | 40 |
40 namespace { | 41 namespace { |
41 | 42 |
42 const wchar_t kHelpCenterUrl[] = | 43 const wchar_t kHelpCenterUrl[] = |
43 L"https://support.google.com/chrome/answer/150752"; | 44 L"https://support.google.com/chrome/answer/150752"; |
44 | 45 |
45 enum ButtonTags { | 46 enum ButtonTags { |
46 BT_NONE, | 47 BT_NONE, |
47 BT_CLOSE_BUTTON, | 48 BT_CLOSE_BUTTON, |
48 BT_OK_BUTTON, | 49 BT_OK_BUTTON, |
49 BT_TRY_IT_RADIO, | 50 BT_TRY_IT_RADIO, |
50 BT_DONT_BUG_RADIO | 51 BT_DONT_BUG_RADIO |
51 }; | 52 }; |
52 | 53 |
53 const int kRadioGroupID = 1; | 54 const int kRadioGroupID = 1; |
54 | 55 |
55 } // namespace | 56 } // namespace |
56 | 57 |
57 // static | 58 // static |
59 bool TryChromeDialogView::for_testing_ = false; | |
60 | |
61 // static | |
58 TryChromeDialogView::Result TryChromeDialogView::Show( | 62 TryChromeDialogView::Result TryChromeDialogView::Show( |
59 size_t flavor, | 63 size_t flavor, |
60 const ActiveModalDialogListener& listener) { | 64 const ActiveModalDialogListener& listener) { |
61 if (flavor > 10000) { | 65 if (flavor > 10000) { |
62 // This is a test value. We want to make sure we exercise | 66 // This is a test value. We want to make sure we exercise |
63 // returning this early. See TryChromeDialogBrowserTest test. | 67 // returning this early. See TryChromeDialogBrowserTest test. |
64 return NOT_NOW; | 68 return NOT_NOW; |
65 } | 69 } |
66 TryChromeDialogView dialog(flavor); | 70 TryChromeDialogView dialog(flavor); |
67 return dialog.ShowModal(listener); | 71 return dialog.ShowModal(listener); |
68 } | 72 } |
69 | 73 |
70 TryChromeDialogView::TryChromeDialogView(size_t flavor) | 74 TryChromeDialogView::TryChromeDialogView(size_t flavor) |
71 : flavor_(flavor), | 75 : flavor_(flavor), |
72 popup_(NULL), | 76 popup_(NULL), |
73 try_chrome_(NULL), | 77 try_chrome_(NULL), |
74 kill_chrome_(NULL), | 78 kill_chrome_(NULL), |
75 dont_try_chrome_(NULL), | 79 dont_try_chrome_(NULL), |
76 make_default_(NULL), | 80 make_default_(NULL), |
77 result_(COUNT) { | 81 result_(COUNT) {} |
78 } | |
79 | 82 |
80 TryChromeDialogView::~TryChromeDialogView() { | 83 TryChromeDialogView::~TryChromeDialogView() {} |
81 } | |
82 | 84 |
83 TryChromeDialogView::Result TryChromeDialogView::ShowModal( | 85 TryChromeDialogView::Result TryChromeDialogView::ShowModal( |
84 const ActiveModalDialogListener& listener) { | 86 const ActiveModalDialogListener& listener) { |
85 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 87 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
86 | 88 |
87 views::ImageView* icon = new views::ImageView(); | 89 views::ImageView* icon = new views::ImageView(); |
88 icon->SetImage(rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_32).ToImageSkia()); | 90 icon->SetImage(rb.GetNativeImageNamed(IDR_PRODUCT_LOGO_32).ToImageSkia()); |
89 gfx::Size icon_size = icon->GetPreferredSize(); | 91 gfx::Size icon_size = icon->GetPreferredSize(); |
90 | 92 |
91 // An approximate window size. After Layout() we'll get better bounds. | 93 // An approximate window size. After Layout() we'll get better bounds. |
92 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); | 94 views::Widget::InitParams params(views::Widget::InitParams::TYPE_POPUP); |
93 params.activatable = views::Widget::InitParams::ACTIVATABLE_YES; | 95 params.activatable = views::Widget::InitParams::ACTIVATABLE_YES; |
94 params.bounds = gfx::Rect(310, 200); | 96 params.bounds = gfx::Rect(310, 200); |
95 popup_ = new views::Widget; | 97 popup_ = new views::Widget; |
96 popup_->Init(params); | 98 popup_->Init(params); |
97 | 99 |
98 views::View* root_view = popup_->GetRootView(); | 100 views::View* root_view = popup_->GetRootView(); |
99 // The window color is a tiny bit off-white. | 101 // The window color is a tiny bit off-white. |
100 root_view->set_background( | 102 root_view->set_background( |
101 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); | 103 views::Background::CreateSolidBackground(0xfc, 0xfc, 0xfc)); |
102 | 104 |
103 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); | 105 views::GridLayout* layout = views::GridLayout::CreatePanel(root_view); |
104 views::ColumnSet* columns; | 106 views::ColumnSet* columns; |
105 | 107 |
108 ChromeLayoutProvider* provider = ChromeLayoutProvider::Get(); | |
109 const int label_spacing = | |
110 provider->GetDistanceMetric(DISTANCE_RELATED_LABEL_HORIZONTAL); | |
111 const int unrelated_space_horiz = | |
112 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_HORIZONTAL); | |
113 const int unrelated_space_vert = | |
114 provider->GetDistanceMetric(DISTANCE_UNRELATED_CONTROL_VERTICAL); | |
115 const int button_spacing_horiz = | |
116 provider->GetDistanceMetric(views::DISTANCE_RELATED_BUTTON_HORIZONTAL); | |
117 | |
106 // First row: [icon][pad][text][pad][button]. | 118 // First row: [icon][pad][text][pad][button]. |
107 columns = layout->AddColumnSet(0); | 119 columns = layout->AddColumnSet(0); |
108 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, | 120 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING, 0, |
109 views::GridLayout::FIXED, icon_size.width(), | 121 views::GridLayout::FIXED, icon_size.width(), |
110 icon_size.height()); | 122 icon_size.height()); |
111 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); | 123 columns->AddPaddingColumn(0, label_spacing); |
112 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, | 124 columns->AddColumn(views::GridLayout::FILL, views::GridLayout::FILL, 1, |
113 views::GridLayout::USE_PREF, 0, 0); | 125 views::GridLayout::USE_PREF, 0, 0); |
114 columns->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); | 126 columns->AddPaddingColumn(0, unrelated_space_horiz); |
115 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 1, | 127 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 1, |
116 views::GridLayout::USE_PREF, 0, 0); | 128 views::GridLayout::USE_PREF, 0, 0); |
117 | 129 |
118 // Optional second row: [pad][pad][radio 1]. | 130 int icon_padding = icon_size.width() + label_spacing; |
131 // Optional second row: [pad][radio 1]. | |
119 columns = layout->AddColumnSet(1); | 132 columns = layout->AddColumnSet(1); |
120 columns->AddPaddingColumn(0, icon_size.width()); | 133 columns->AddPaddingColumn(0, icon_padding); |
121 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); | |
122 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 134 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
123 views::GridLayout::USE_PREF, 0, 0); | 135 views::GridLayout::USE_PREF, 0, 0); |
124 | 136 |
125 // Third row: [pad][pad][radio 2]. | 137 // Third row: [pad][radio 2]. |
126 columns = layout->AddColumnSet(2); | 138 columns = layout->AddColumnSet(2); |
127 columns->AddPaddingColumn(0, icon_size.width()); | 139 columns->AddPaddingColumn(0, icon_padding); |
128 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); | |
129 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 140 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
130 views::GridLayout::USE_PREF, 0, 0); | 141 views::GridLayout::USE_PREF, 0, 0); |
131 | 142 |
132 // Fourth row: [pad][pad][button][pad][button]. | 143 // Fourth row: [pad][button][pad][button]. |
133 columns = layout->AddColumnSet(3); | 144 columns = layout->AddColumnSet(3); |
134 columns->AddPaddingColumn(0, icon_size.width()); | 145 columns->AddPaddingColumn(0, icon_padding); |
135 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, | 146 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, |
136 views::GridLayout::USE_PREF, 0, 0); | 147 views::GridLayout::USE_PREF, 0, 0); |
137 columns->AddPaddingColumn(0, views::LayoutProvider::Get()->GetDistanceMetric( | 148 columns->AddPaddingColumn(0, button_spacing_horiz); |
138 views::DISTANCE_RELATED_BUTTON_HORIZONTAL)); | |
139 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, | 149 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, |
140 views::GridLayout::USE_PREF, 0, 0); | 150 views::GridLayout::USE_PREF, 0, 0); |
141 | 151 |
142 // Fifth row: [pad][pad][link]. | 152 // Fifth row: [pad][link]. |
143 columns = layout->AddColumnSet(4); | 153 columns = layout->AddColumnSet(4); |
144 columns->AddPaddingColumn(0, icon_size.width()); | 154 columns->AddPaddingColumn(0, icon_padding); |
145 columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); | |
146 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, | 155 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
147 views::GridLayout::USE_PREF, 0, 0); | 156 views::GridLayout::USE_PREF, 0, 0); |
148 | 157 |
149 // Optional fourth row: [button]. | 158 // Optional fourth row: [button]. |
150 columns = layout->AddColumnSet(5); | 159 columns = layout->AddColumnSet(5); |
151 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, | 160 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, |
152 views::GridLayout::USE_PREF, 0, 0); | 161 views::GridLayout::USE_PREF, 0, 0); |
153 | 162 |
154 // Optional fourth row: [divider] | 163 // Optional fourth row: [divider] |
155 columns = layout->AddColumnSet(6); | 164 columns = layout->AddColumnSet(6); |
156 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, | 165 columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, |
157 views::GridLayout::USE_PREF, 0, 0); | 166 views::GridLayout::USE_PREF, 0, 0); |
158 | 167 |
159 // Optional fifth row [checkbox][pad][button] | 168 // Optional fifth row [checkbox][pad][button] |
160 columns = layout->AddColumnSet(7); | 169 columns = layout->AddColumnSet(7); |
161 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, | 170 columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, |
162 views::GridLayout::USE_PREF, 0, 0); | 171 views::GridLayout::USE_PREF, 0, 0); |
163 columns->AddPaddingColumn(0, views::kUnrelatedControlHorizontalSpacing); | 172 columns->AddPaddingColumn(0, unrelated_space_horiz); |
164 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 1, | 173 columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 1, |
165 views::GridLayout::USE_PREF, 0, 0); | 174 views::GridLayout::USE_PREF, 0, 0); |
166 | 175 |
167 // First row. | 176 // First row. |
168 layout->StartRow(0, 0); | 177 layout->StartRow(0, 0); |
169 layout->AddView(icon); | 178 layout->AddView(icon); |
170 | 179 |
171 // Find out what experiment we are conducting. | 180 // Find out what experiment we are conducting. |
172 installer::ExperimentDetails experiment; | 181 installer::ExperimentDetails experiment; |
173 if (!install_static::SupportsRetentionExperiments() || | 182 if ((!for_testing_ && !install_static::SupportsRetentionExperiments()) || |
Peter Kasting
2017/04/28 06:16:41
I don't think we should use a private static for t
ananta
2017/04/28 14:57:01
I added a force parameter to the Show() function w
| |
174 !installer::CreateExperimentDetails(flavor_, &experiment) || | 183 !installer::CreateExperimentDetails(flavor_, &experiment) || |
175 !experiment.heading) { | 184 !experiment.heading) { |
176 NOTREACHED() << "Cannot determine which headline to show."; | 185 NOTREACHED() << "Cannot determine which headline to show."; |
177 return DIALOG_ERROR; | 186 return DIALOG_ERROR; |
178 } | 187 } |
179 views::Label* label = | 188 views::Label* label = |
180 new views::Label(l10n_util::GetStringUTF16(experiment.heading), | 189 new views::Label(l10n_util::GetStringUTF16(experiment.heading), |
181 views::style::CONTEXT_DIALOG_TITLE); | 190 views::style::CONTEXT_DIALOG_TITLE); |
182 label->SetMultiLine(true); | 191 label->SetMultiLine(true); |
183 label->SizeToFit(200); | 192 label->SizeToFit(200); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 layout->AddView(kill_chrome_); | 232 layout->AddView(kill_chrome_); |
224 } | 233 } |
225 | 234 |
226 views::LabelButton* accept_button = | 235 views::LabelButton* accept_button = |
227 views::MdTextButton::CreateSecondaryUiButton( | 236 views::MdTextButton::CreateSecondaryUiButton( |
228 this, l10n_util::GetStringUTF16(IDS_OK)); | 237 this, l10n_util::GetStringUTF16(IDS_OK)); |
229 accept_button->set_tag(BT_OK_BUTTON); | 238 accept_button->set_tag(BT_OK_BUTTON); |
230 | 239 |
231 views::Separator* separator = NULL; | 240 views::Separator* separator = NULL; |
232 if (experiment.flags & installer::kToastUiMakeDefault) { | 241 if (experiment.flags & installer::kToastUiMakeDefault) { |
233 // In this flavor we have some veritical space, then a separator line | 242 // In this flavor we have some vertical space, then a separator line |
234 // and the 'make default' checkbox and the OK button on the same row. | 243 // and the 'make default' checkbox and the OK button on the same row. |
235 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 244 layout->AddPaddingRow(0, unrelated_space_vert); |
236 layout->StartRow(0, 6); | 245 layout->StartRow(0, 6); |
237 separator = new views::Separator(); | 246 separator = new views::Separator(); |
238 layout->AddView(separator); | 247 layout->AddView(separator); |
239 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); | 248 layout->AddPaddingRow(0, unrelated_space_vert); |
240 | 249 |
241 layout->StartRow(0, 7); | 250 layout->StartRow(0, 7); |
242 make_default_ = new views::Checkbox( | 251 make_default_ = new views::Checkbox( |
243 l10n_util::GetStringUTF16(IDS_TRY_TOAST_SET_DEFAULT)); | 252 l10n_util::GetStringUTF16(IDS_TRY_TOAST_SET_DEFAULT)); |
244 make_default_->SetChecked(true); | 253 make_default_->SetChecked(true); |
245 layout->AddView(make_default_); | 254 layout->AddView(make_default_); |
246 layout->AddView(accept_button); | 255 layout->AddView(accept_button); |
247 } else { | 256 } else { |
248 // On this other flavor there is no checkbox, the OK button and possibly | 257 // On this other flavor there is no checkbox, the OK button and possibly |
249 // the cancel button are in the same row. | 258 // the cancel button are in the same row. |
250 layout->StartRowWithPadding(0, dont_bug_me_button ? 3 : 5, 0, 10); | 259 layout->StartRowWithPadding(0, dont_bug_me_button ? 3 : 5, 0, 10); |
251 layout->AddView(accept_button); | 260 layout->AddView(accept_button); |
252 if (dont_bug_me_button) { | 261 if (dont_bug_me_button) { |
253 // The dialog needs a "Don't bug me" as a button or as a radio button, | 262 // The dialog needs a "Don't bug me" as a button or as a radio button, |
254 // this the button case. | 263 // this the button case. |
255 views::LabelButton* cancel_button = | 264 views::LabelButton* cancel_button = |
256 views::MdTextButton::CreateSecondaryUiButton( | 265 views::MdTextButton::CreateSecondaryUiButton( |
257 this, l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); | 266 this, l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); |
258 cancel_button->set_tag(BT_CLOSE_BUTTON); | 267 cancel_button->set_tag(BT_CLOSE_BUTTON); |
259 layout->AddView(cancel_button); | 268 layout->AddView(cancel_button); |
260 } | 269 } |
261 } | 270 } |
262 | 271 |
263 if (experiment.flags & installer::kToastUiWhyLink) { | 272 if (experiment.flags & installer::kToastUiWhyLink) { |
264 layout->StartRowWithPadding(0, 4, 0, 10); | 273 layout->StartRowWithPadding(0, 4, 0, 10); |
265 views::Link* link = new views::Link( | 274 views::Link* link = |
266 l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY)); | 275 new views::Link(l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY)); |
267 link->set_listener(this); | 276 link->set_listener(this); |
268 layout->AddView(link); | 277 layout->AddView(link); |
269 } | 278 } |
270 | 279 |
271 // We resize the window according to the layout manager. This takes into | 280 // We resize the window according to the layout manager. This takes into |
272 // account the differences between XP and Vista fonts and buttons. | 281 // account the differences between XP and Vista fonts and buttons. |
273 layout->Layout(root_view); | 282 layout->Layout(root_view); |
274 gfx::Size preferred = layout->GetPreferredSize(root_view); | 283 gfx::Size preferred = layout->GetPreferredSize(root_view); |
275 if (separator) { | 284 if (separator) { |
276 int separator_height = separator->GetPreferredSize().height(); | 285 int separator_height = separator->GetPreferredSize().height(); |
277 separator->SetSize(gfx::Size(preferred.width(), separator_height)); | 286 separator->SetSize(gfx::Size(preferred.width(), separator_height)); |
278 } | 287 } |
279 | 288 |
280 gfx::Rect pos = ComputeWindowPosition(preferred, base::i18n::IsRTL()); | 289 gfx::Rect pos = ComputeWindowPosition(preferred, base::i18n::IsRTL()); |
281 popup_->SetBounds(pos); | 290 |
291 // Bounds have to be in DIPs. | |
Peter Kasting
2017/04/28 06:16:41
This comment can probably be omitted since all bou
ananta
2017/04/28 14:57:00
Done.
| |
292 popup_->SetBounds(display::Screen::GetScreen()->ScreenToDIPRectInWindow( | |
Peter Kasting
2017/04/28 06:16:41
This conversion should probably be done in Compute
ananta
2017/04/28 14:57:01
Thanks. Done.
| |
293 popup_->GetNativeView(), pos)); | |
282 | 294 |
283 // Carve the toast shape into the window. | 295 // Carve the toast shape into the window. |
284 HWND toast_window; | 296 HWND toast_window; |
285 toast_window = popup_->GetNativeView()->GetHost()->GetAcceleratedWidget(); | 297 toast_window = popup_->GetNativeView()->GetHost()->GetAcceleratedWidget(); |
286 SetToastRegion(toast_window, preferred.width(), preferred.height()); | 298 SetToastRegion(toast_window, preferred.width(), preferred.height()); |
287 | 299 |
288 // Time to show the window in a modal loop. | 300 // Time to show the window in a modal loop. |
289 popup_->Show(); | 301 popup_->Show(); |
290 if (!listener.is_null()) | 302 if (!listener.is_null()) |
291 listener.Run(popup_->GetNativeView()); | 303 listener.Run(popup_->GetNativeView()); |
(...skipping 16 matching lines...) Expand all Loading... | |
308 // |rcWork| is the work area, accounting for the visible taskbars. | 320 // |rcWork| is the work area, accounting for the visible taskbars. |
309 origin.set_x(is_RTL ? info.rcWork.left : info.rcWork.right - size.width()); | 321 origin.set_x(is_RTL ? info.rcWork.left : info.rcWork.right - size.width()); |
310 origin.set_y(info.rcWork.bottom - size.height()); | 322 origin.set_y(info.rcWork.bottom - size.height()); |
311 } | 323 } |
312 | 324 |
313 return gfx::Rect(origin, size); | 325 return gfx::Rect(origin, size); |
314 } | 326 } |
315 | 327 |
316 void TryChromeDialogView::SetToastRegion(HWND window, int w, int h) { | 328 void TryChromeDialogView::SetToastRegion(HWND window, int w, int h) { |
317 static const POINT polygon[] = { | 329 static const POINT polygon[] = { |
318 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side. | 330 {0, 4}, {1, 2}, {2, 1}, {4, 0}, // Left side. |
319 {w-4, 0}, {w-2, 1}, {w-1, 2}, {w, 4}, // Right side. | 331 {w - 4, 0}, {w - 2, 1}, {w - 1, 2}, {w, 4}, // Right side. |
320 {w, h}, {0, h} | 332 {w, h}, {0, h}}; |
321 }; | |
322 HRGN region = ::CreatePolygonRgn(polygon, arraysize(polygon), WINDING); | 333 HRGN region = ::CreatePolygonRgn(polygon, arraysize(polygon), WINDING); |
323 ::SetWindowRgn(window, region, FALSE); | 334 ::SetWindowRgn(window, region, FALSE); |
324 } | 335 } |
325 | 336 |
326 void TryChromeDialogView::ButtonPressed(views::Button* sender, | 337 void TryChromeDialogView::ButtonPressed(views::Button* sender, |
327 const ui::Event& event) { | 338 const ui::Event& event) { |
328 if (sender->tag() == BT_DONT_BUG_RADIO) { | 339 if (sender->tag() == BT_DONT_BUG_RADIO) { |
329 if (make_default_) { | 340 if (make_default_) { |
330 make_default_->SetChecked(false); | 341 make_default_->SetChecked(false); |
331 make_default_->SetVisible(false); | 342 make_default_->SetVisible(false); |
(...skipping 18 matching lines...) Expand all Loading... | |
350 else if (dont_try_chrome_ && dont_try_chrome_->checked()) | 361 else if (dont_try_chrome_ && dont_try_chrome_->checked()) |
351 result_ = NOT_NOW; | 362 result_ = NOT_NOW; |
352 else if (kill_chrome_ && kill_chrome_->checked()) | 363 else if (kill_chrome_ && kill_chrome_->checked()) |
353 result_ = UNINSTALL_CHROME; | 364 result_ = UNINSTALL_CHROME; |
354 else | 365 else |
355 NOTREACHED() << "Unknown radio button selected"; | 366 NOTREACHED() << "Unknown radio button selected"; |
356 } | 367 } |
357 | 368 |
358 if (make_default_) { | 369 if (make_default_) { |
359 if ((result_ == TRY_CHROME) && make_default_->checked()) | 370 if ((result_ == TRY_CHROME) && make_default_->checked()) |
360 result_ = TRY_CHROME_AS_DEFAULT; | 371 result_ = TRY_CHROME_AS_DEFAULT; |
361 } | 372 } |
362 | 373 |
363 popup_->Close(); | 374 popup_->Close(); |
364 base::MessageLoop::current()->QuitWhenIdle(); | 375 base::MessageLoop::current()->QuitWhenIdle(); |
365 } | 376 } |
366 | 377 |
367 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) { | 378 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) { |
368 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); | 379 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); |
369 } | 380 } |
OLD | NEW |