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

Side by Side Diff: chrome/browser/first_run/try_chrome_dialog_view.cc

Issue 1978403003: [MD] Eliminate as many SetStyle(STYLE_BUTTON) calls as possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 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
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/first_run/try_chrome_dialog_view.h" 5 #include "chrome/browser/first_run/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/strings/string16.h" 12 #include "base/strings/string16.h"
13 #include "chrome/browser/process_singleton.h" 13 #include "chrome/browser/process_singleton.h"
14 #include "chrome/grit/chromium_strings.h" 14 #include "chrome/grit/chromium_strings.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "chrome/installer/util/browser_distribution.h" 16 #include "chrome/installer/util/browser_distribution.h"
17 #include "chrome/installer/util/user_experiment.h" 17 #include "chrome/installer/util/user_experiment.h"
18 #include "grit/components_strings.h" 18 #include "grit/components_strings.h"
19 #include "grit/theme_resources.h" 19 #include "grit/theme_resources.h"
20 #include "ui/aura/window.h" 20 #include "ui/aura/window.h"
21 #include "ui/aura/window_tree_host.h" 21 #include "ui/aura/window_tree_host.h"
22 #include "ui/base/l10n/l10n_util.h" 22 #include "ui/base/l10n/l10n_util.h"
23 #include "ui/base/resource/resource_bundle.h" 23 #include "ui/base/resource/resource_bundle.h"
24 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
25 #include "ui/resources/grit/ui_resources.h" 25 #include "ui/resources/grit/ui_resources.h"
26 #include "ui/views/background.h" 26 #include "ui/views/background.h"
27 #include "ui/views/controls/button/checkbox.h" 27 #include "ui/views/controls/button/checkbox.h"
28 #include "ui/views/controls/button/image_button.h" 28 #include "ui/views/controls/button/image_button.h"
29 #include "ui/views/controls/button/label_button.h" 29 #include "ui/views/controls/button/md_text_button.h"
30 #include "ui/views/controls/button/radio_button.h" 30 #include "ui/views/controls/button/radio_button.h"
31 #include "ui/views/controls/image_view.h" 31 #include "ui/views/controls/image_view.h"
32 #include "ui/views/controls/link.h" 32 #include "ui/views/controls/link.h"
33 #include "ui/views/controls/separator.h" 33 #include "ui/views/controls/separator.h"
34 #include "ui/views/layout/grid_layout.h" 34 #include "ui/views/layout/grid_layout.h"
35 #include "ui/views/layout/layout_constants.h" 35 #include "ui/views/layout/layout_constants.h"
36 #include "ui/views/widget/widget.h" 36 #include "ui/views/widget/widget.h"
37 37
38 namespace { 38 namespace {
39 39
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 dont_try_chrome_->set_listener(this); 214 dont_try_chrome_->set_listener(this);
215 layout->AddView(dont_try_chrome_); 215 layout->AddView(dont_try_chrome_);
216 } 216 }
217 if (experiment.flags & installer::kToastUiUninstall) { 217 if (experiment.flags & installer::kToastUiUninstall) {
218 layout->StartRow(0, 2); 218 layout->StartRow(0, 2);
219 kill_chrome_ = new views::RadioButton( 219 kill_chrome_ = new views::RadioButton(
220 l10n_util::GetStringUTF16(IDS_UNINSTALL_CHROME), kRadioGroupID); 220 l10n_util::GetStringUTF16(IDS_UNINSTALL_CHROME), kRadioGroupID);
221 layout->AddView(kill_chrome_); 221 layout->AddView(kill_chrome_);
222 } 222 }
223 223
224 views::LabelButton* accept_button = new views::LabelButton( 224 views::LabelButton* accept_button =
225 this, l10n_util::GetStringUTF16(IDS_OK)); 225 views::MdTextButton::CreateSecondaryUiButton(
226 accept_button->SetStyle(views::Button::STYLE_BUTTON); 226 this, l10n_util::GetStringUTF16(IDS_OK));
227 accept_button->set_tag(BT_OK_BUTTON); 227 accept_button->set_tag(BT_OK_BUTTON);
228 228
229 views::Separator* separator = NULL; 229 views::Separator* separator = NULL;
230 if (experiment.flags & installer::kToastUiMakeDefault) { 230 if (experiment.flags & installer::kToastUiMakeDefault) {
231 // In this flavor we have some veritical space, then a separator line 231 // In this flavor we have some veritical space, then a separator line
232 // and the 'make default' checkbox and the OK button on the same row. 232 // and the 'make default' checkbox and the OK button on the same row.
233 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 233 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
234 layout->StartRow(0, 6); 234 layout->StartRow(0, 6);
235 separator = new views::Separator(views::Separator::HORIZONTAL); 235 separator = new views::Separator(views::Separator::HORIZONTAL);
236 layout->AddView(separator); 236 layout->AddView(separator);
237 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing); 237 layout->AddPaddingRow(0, views::kUnrelatedControlVerticalSpacing);
238 238
239 layout->StartRow(0, 7); 239 layout->StartRow(0, 7);
240 make_default_ = new views::Checkbox( 240 make_default_ = new views::Checkbox(
241 l10n_util::GetStringUTF16(IDS_TRY_TOAST_SET_DEFAULT)); 241 l10n_util::GetStringUTF16(IDS_TRY_TOAST_SET_DEFAULT));
242 make_default_->SetChecked(true); 242 make_default_->SetChecked(true);
243 layout->AddView(make_default_); 243 layout->AddView(make_default_);
244 layout->AddView(accept_button); 244 layout->AddView(accept_button);
245 } else { 245 } else {
246 // On this other flavor there is no checkbox, the OK button and possibly 246 // On this other flavor there is no checkbox, the OK button and possibly
247 // the cancel button are in the same row. 247 // the cancel button are in the same row.
248 layout->StartRowWithPadding(0, dont_bug_me_button ? 3 : 5, 0, 10); 248 layout->StartRowWithPadding(0, dont_bug_me_button ? 3 : 5, 0, 10);
249 layout->AddView(accept_button); 249 layout->AddView(accept_button);
250 if (dont_bug_me_button) { 250 if (dont_bug_me_button) {
251 // The dialog needs a "Don't bug me" as a button or as a radio button, 251 // The dialog needs a "Don't bug me" as a button or as a radio button,
252 // this the button case. 252 // this the button case.
253 views::LabelButton* cancel_button = new views::LabelButton( 253 views::LabelButton* cancel_button =
254 this, l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); 254 views::MdTextButton::CreateSecondaryUiButton(
255 cancel_button->SetStyle(views::Button::STYLE_BUTTON); 255 this, l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL));
256 cancel_button->set_tag(BT_CLOSE_BUTTON); 256 cancel_button->set_tag(BT_CLOSE_BUTTON);
257 layout->AddView(cancel_button); 257 layout->AddView(cancel_button);
258 } 258 }
259 } 259 }
260 260
261 if (experiment.flags & installer::kToastUiWhyLink) { 261 if (experiment.flags & installer::kToastUiWhyLink) {
262 layout->StartRowWithPadding(0, 4, 0, 10); 262 layout->StartRowWithPadding(0, 4, 0, 10);
263 views::Link* link = new views::Link( 263 views::Link* link = new views::Link(
264 l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY)); 264 l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY));
265 link->set_listener(this); 265 link->set_listener(this);
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 result_ = TRY_CHROME_AS_DEFAULT; 360 result_ = TRY_CHROME_AS_DEFAULT;
361 } 361 }
362 362
363 popup_->Close(); 363 popup_->Close();
364 base::MessageLoop::current()->QuitWhenIdle(); 364 base::MessageLoop::current()->QuitWhenIdle();
365 } 365 }
366 366
367 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) { 367 void TryChromeDialogView::LinkClicked(views::Link* source, int event_flags) {
368 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW); 368 ::ShellExecuteW(NULL, L"open", kHelpCenterUrl, NULL, NULL, SW_SHOW);
369 } 369 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698