Chromium Code Reviews| Index: chrome/browser/first_run/try_chrome_dialog_view.cc |
| =================================================================== |
| --- chrome/browser/first_run/try_chrome_dialog_view.cc (revision 147935) |
| +++ chrome/browser/first_run/try_chrome_dialog_view.cc (working copy) |
| @@ -18,6 +18,7 @@ |
| #include "ui/base/l10n/l10n_util.h" |
| #include "ui/base/resource/resource_bundle.h" |
| #include "ui/gfx/image/image.h" |
| +#include "ui/views/controls/button/checkbox.h" |
| #include "ui/views/controls/button/image_button.h" |
| #include "ui/views/controls/button/radio_button.h" |
| #include "ui/views/controls/button/text_button.h" |
| @@ -32,6 +33,14 @@ |
| const wchar_t kHelpCenterUrl[] = |
| L"https://www.google.com/support/chrome/bin/answer.py?answer=150752"; |
| +enum ButtonTags { |
| + BT_NONE, |
| + BT_CLOSE_BUTTON, |
| + BT_OK_BUTTON, |
| + BT_TRY_IT_RADIO, |
| + BT_DONT_BUG_RADIO |
| +}; |
| + |
| } // namespace |
| // static |
| @@ -53,7 +62,8 @@ |
| try_chrome_(NULL), |
| kill_chrome_(NULL), |
| dont_try_chrome_(NULL), |
| - result_(COUNT) { |
| + make_default_(NULL), |
| + result_(COUNT) { |
| } |
| TryChromeDialogView::~TryChromeDialogView() { |
| @@ -102,7 +112,7 @@ |
| views::GridLayout::USE_PREF, 0, 0); |
| columns->AddColumn(views::GridLayout::TRAILING, views::GridLayout::FILL, 1, |
| views::GridLayout::USE_PREF, 0, 0); |
| - // Second row: [pad][pad][radio 1]. |
| + // Optional second row: [pad][pad][radio 1]. |
|
Finnur
2012/07/26 12:27:07
Can you add a line break above this and on lines 1
cpu_(ooo_6.6-7.5)
2012/07/27 03:06:23
Done.
|
| columns = layout->AddColumnSet(1); |
| columns->AddPaddingColumn(0, icon_size.width()); |
| columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); |
| @@ -117,7 +127,6 @@ |
| // Fourth row: [pad][pad][button][pad][button]. |
| columns = layout->AddColumnSet(3); |
| columns->AddPaddingColumn(0, icon_size.width()); |
| - columns->AddPaddingColumn(0, views::kRelatedControlHorizontalSpacing); |
| columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 0, |
| views::GridLayout::USE_PREF, 0, 0); |
| columns->AddPaddingColumn(0, views::kRelatedButtonHSpacing); |
| @@ -133,6 +142,13 @@ |
| columns = layout->AddColumnSet(5); |
| columns->AddColumn(views::GridLayout::CENTER, views::GridLayout::FILL, 1, |
| views::GridLayout::USE_PREF, 0, 0); |
| + // Optional fourth row: [pad][pad][checkbox]. |
| + columns = layout->AddColumnSet(6); |
| + columns->AddPaddingColumn(0, icon_size.width()); |
| + columns->AddPaddingColumn(0, |
| + views::kRelatedControlHorizontalSpacing + views::kPanelHorizIndentation); |
| + columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::FILL, 1, |
| + views::GridLayout::USE_PREF, 0, 0); |
| // First row views. |
| layout->StartRow(0, 0); |
| layout->AddView(icon); |
| @@ -171,45 +187,59 @@ |
| const string16 try_it(l10n_util::GetStringUTF16(IDS_TRY_TOAST_TRY_OPT)); |
| layout->StartRowWithPadding(0, 1, 0, 10); |
| try_chrome_ = new views::RadioButton(try_it, 1); |
| + try_chrome_->SetChecked(true); |
| + try_chrome_->set_tag(BT_TRY_IT_RADIO); |
| + try_chrome_->set_listener(this); |
| layout->AddView(try_chrome_); |
| - try_chrome_->SetChecked(true); |
| - // Third row views. |
| - layout->StartRow(0, 2); |
| - if (experiment.compact_bubble) { |
| + // Decide if the don't bug me is a button or a radio button. |
| + bool dont_bug_me_button = |
| + experiment.flags & BrowserDistribution::kDontBugMeAsButton ? true : false; |
| + |
| + // Optional third and fourth row views. |
| + if (!dont_bug_me_button) { |
| + layout->StartRow(0, 1); |
| // The compact bubble has, as its second radio button, "Don't bug me". |
|
Finnur
2012/07/26 12:27:07
This comment refers to the compact bubble. Do we w
cpu_(ooo_6.6-7.5)
2012/07/27 03:06:23
Reworded the comments mentioning compact and regul
|
| const string16 decline(l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); |
| dont_try_chrome_ = new views::RadioButton(decline, 1); |
| + dont_try_chrome_->set_tag(BT_DONT_BUG_RADIO); |
| + dont_try_chrome_->set_listener(this); |
| layout->AddView(dont_try_chrome_); |
| - } else { |
| + } |
| + if (experiment.flags & BrowserDistribution::kUninstall) { |
| + layout->StartRow(0, 2); |
| // The regular bubble has, as its second radio button, "Uninstall Chrome". |
| const string16 kill_it(l10n_util::GetStringUTF16(IDS_UNINSTALL_CHROME)); |
| kill_chrome_ = new views::RadioButton(kill_it, 1); |
| layout->AddView(kill_chrome_); |
| } |
| + if (experiment.flags & BrowserDistribution::kMakeDefault) { |
| + layout->StartRow(0, 6); |
| + const string16 default_text( |
| + l10n_util::GetStringUTF16(IDS_TRY_TOAST_SET_DEFAULT)); |
| + make_default_ = new views::Checkbox(default_text); |
| + layout->AddView(make_default_); |
| + make_default_->SetChecked(true); |
|
Finnur
2012/07/26 12:27:07
nit: For consistency with line 190 maybe move this
cpu_(ooo_6.6-7.5)
2012/07/27 03:06:23
Done.
|
| + } |
| - // Fourth row views. |
| + // Button row, the last or next to last depending on the 'why?' link. |
| const string16 ok_it(l10n_util::GetStringUTF16(IDS_OK)); |
| - const string16 cancel_it(l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); |
| - const string16 why_this(l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY)); |
| views::Button* accept_button = new views::NativeTextButton(this, ok_it); |
| accept_button->set_tag(BT_OK_BUTTON); |
| - // The compact bubble uses a centered button column for buttons, since only |
| - // the OK button appears. |
| - int column_id_buttons = experiment.compact_bubble ? 5 : 3; |
| - layout->StartRowWithPadding(0, column_id_buttons, 0, 10); |
| + layout->StartRowWithPadding(0, dont_bug_me_button ? 3 : 5, 0, 10); |
| layout->AddView(accept_button); |
| - if (!experiment.compact_bubble) { |
| + if (dont_bug_me_button) { |
| // The regular bubble needs a "Don't bug me" as a button, since it is not |
| - // one of the options for the radio buttons. We also decided to include the |
| - // "Why am I seeing this?" link for the regular bubble only. |
| + // one of the options for the radio buttons. |
| + const string16 cancel_it(l10n_util::GetStringUTF16(IDS_TRY_TOAST_CANCEL)); |
| views::Button* cancel_button = new views::NativeTextButton(this, cancel_it); |
| cancel_button->set_tag(BT_CLOSE_BUTTON); |
| layout->AddView(cancel_button); |
| - |
| - // Fifth row views. |
| + } |
| + if (experiment.flags & BrowserDistribution::kWhyLink) { |
| layout->StartRowWithPadding(0, 4, 0, 10); |
| + const string16 why_this(l10n_util::GetStringUTF16(IDS_TRY_TOAST_WHY)); |
| views::Link* link = new views::Link(why_this); |
| link->set_listener(this); |
| layout->AddView(link); |
| @@ -269,14 +299,26 @@ |
| void TryChromeDialogView::ButtonPressed(views::Button* sender, |
| const views::Event& event) { |
| - if (sender->tag() == BT_CLOSE_BUTTON) { |
| + if (sender->tag() == BT_DONT_BUG_RADIO) { |
| + if (make_default_) { |
| + make_default_->SetChecked(false); |
| + make_default_->SetState(views::CustomButton::BS_DISABLED); |
| + } |
| + return; |
| + } else if (sender->tag() == BT_TRY_IT_RADIO) { |
| + if (make_default_) { |
| + make_default_->SetChecked(true); |
| + make_default_->SetState(views::CustomButton::BS_NORMAL); |
| + } |
| + return; |
| + } else if (sender->tag() == BT_CLOSE_BUTTON) { |
| // The user pressed cancel or the [x] button. |
| result_ = NOT_NOW; |
| } else if (!try_chrome_) { |
| // We don't have radio buttons, the user pressed ok. |
| result_ = TRY_CHROME; |
| } else { |
| - // The outcome is according to the selected ratio button. |
| + // The outcome is according to the selected radio button. |
| if (try_chrome_->checked()) |
| result_ = TRY_CHROME; |
| else if (dont_try_chrome_ && dont_try_chrome_->checked()) |
| @@ -286,6 +328,12 @@ |
| else |
| NOTREACHED() << "Unknown radio button selected"; |
| } |
| + |
| + if (result_ == TRY_CHROME) { |
| + if (make_default_->checked()) |
|
Finnur
2012/07/26 12:27:07
nit: collapse 332 and 333 into one line and loose
cpu_(ooo_6.6-7.5)
2012/07/27 03:06:23
Done.
|
| + result_ = TRY_CHROME_AS_DEFAULT; |
| + } |
| + |
| popup_->Close(); |
| MessageLoop::current()->Quit(); |
| } |