Skip to content

Commit

Permalink
Convert Checkbox fields to properties.
Browse files Browse the repository at this point in the history
Bug: 957260
Change-Id: Ie4200dbd0916044bee1f9cd177eeb38812f5dba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1594234
Commit-Queue: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Xiyuan Xia <xiyuan@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Allen Bauer <kylixrd@chromium.org>
Auto-Submit: Peter Kasting <pkasting@chromium.org>
Cr-Commit-Position: refs/heads/master@{#659232}
  • Loading branch information
pkasting authored and Commit Bot committed May 13, 2019
1 parent b5723d9 commit e95d05c
Show file tree
Hide file tree
Showing 37 changed files with 134 additions and 112 deletions.
2 changes: 1 addition & 1 deletion ash/session/multiprofiles_intro_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ bool MultiprofilesIntroDialog::Cancel() {
}

bool MultiprofilesIntroDialog::Accept() {
std::move(on_accept_).Run(true, never_show_again_checkbox_->checked());
std::move(on_accept_).Run(true, never_show_again_checkbox_->GetChecked());
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion ash/session/teleport_warning_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool TeleportWarningDialog::Cancel() {
}

bool TeleportWarningDialog::Accept() {
std::move(on_accept_).Run(true, never_show_again_checkbox_->checked());
std::move(on_accept_).Run(true, never_show_again_checkbox_->GetChecked());
return true;
}

Expand Down
10 changes: 5 additions & 5 deletions ash/system/message_center/notifier_settings_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ void NotifierSettingsView::NotifierButton::SetChecked(bool checked) {
checkbox_->SetChecked(checked);
}

bool NotifierSettingsView::NotifierButton::checked() const {
return checkbox_->checked();
bool NotifierSettingsView::NotifierButton::GetChecked() const {
return checkbox_->GetChecked();
}

void NotifierSettingsView::NotifierButton::ButtonPressed(
Expand All @@ -343,7 +343,7 @@ void NotifierSettingsView::NotifierButton::ButtonPressed(
// The checkbox state has already changed at this point, but we'll update
// the state on NotifierSettingsView::ButtonPressed() too, so here change
// back to the previous state.
checkbox_->SetChecked(!checkbox_->checked());
checkbox_->SetChecked(!checkbox_->GetChecked());
Button::NotifyClick(event);
}

Expand Down Expand Up @@ -611,9 +611,9 @@ void NotifierSettingsView::ButtonPressed(views::Button* sender,
return;

NotifierButton* button = *iter;
button->SetChecked(!button->checked());
button->SetChecked(!button->GetChecked());
Shell::Get()->message_center_controller()->SetNotifierEnabled(
button->notifier_id(), button->checked());
button->notifier_id(), button->GetChecked());
Shell::Get()->message_center_controller()->RequestNotifierSettingsUpdate();
}

Expand Down
2 changes: 1 addition & 1 deletion ash/system/message_center/notifier_settings_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class ASH_EXPORT NotifierSettingsView

void UpdateIconImage(const gfx::ImageSkia& icon);
void SetChecked(bool checked);
bool checked() const;
bool GetChecked() const;
const message_center::NotifierId& notifier_id() const {
return notifier_id_;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ bool CardUnmaskPromptViews::Accept() {
year_input_->visible()
? year_input_->GetTextForRow(year_input_->GetSelectedIndex())
: base::string16(),
storage_checkbox_ ? storage_checkbox_->checked() : false);
storage_checkbox_ ? storage_checkbox_->GetChecked() : false);
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ MigratableCardView::MigratableCardView(
MigratableCardView::~MigratableCardView() = default;

bool MigratableCardView::IsSelected() {
return !checkbox_ || checkbox_->checked();
return !checkbox_ || checkbox_->GetChecked();
}

std::string MigratableCardView::GetGuid() {
Expand Down Expand Up @@ -201,7 +201,7 @@ void MigratableCardView::ButtonPressed(views::Button* sender,
// button if needed.
parent_dialog_->DialogModelChanged();
// The warning text will be visible only when user unchecks the checkbox.
checkbox_uncheck_text_container_->SetVisible(!checkbox_->checked());
checkbox_uncheck_text_container_->SetVisible(!checkbox_->GetChecked());
InvalidateLayout();
parent_dialog_->UpdateLayout();
} else {
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ui/views/chrome_cleaner_dialog_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void ChromeCleanerDialog::ButtonPressed(views::Button* sender,
if (sender == details_button_) {
if (dialog_controller_) {
dialog_controller_->DetailsButtonClicked(
/*logs_enabled=*/logs_permission_checkbox_->checked());
/*logs_enabled=*/logs_permission_checkbox_->GetChecked());
dialog_controller_ = nullptr;
}
GetWidget()->Close();
Expand All @@ -203,7 +203,7 @@ void ChromeCleanerDialog::ButtonPressed(views::Button* sender,
DCHECK_EQ(logs_permission_checkbox_, sender);

if (dialog_controller_)
dialog_controller_->SetLogsEnabled(logs_permission_checkbox_->checked());
dialog_controller_->SetLogsEnabled(logs_permission_checkbox_->GetChecked());
}

// safe_browsing::ChromeCleanerController::Observer overrides
Expand Down Expand Up @@ -240,7 +240,7 @@ void ChromeCleanerDialog::HandleDialogInteraction(
switch (result) {
case DialogInteractionResult::kAccept:
dialog_controller_->Accept(
/*logs_enabled=*/logs_permission_checkbox_->checked());
/*logs_enabled=*/logs_permission_checkbox_->GetChecked());
break;
case DialogInteractionResult::kCancel:
dialog_controller_->Cancel();
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/content_setting_bubble_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ void ContentSettingBubbleContents::OnListItemRemovedAt(int index) {
int ContentSettingBubbleContents::GetSelectedRadioOption() {
for (RadioGroup::const_iterator i(radio_group_.begin());
i != radio_group_.end(); ++i) {
if ((*i)->checked())
if ((*i)->GetChecked())
return i - radio_group_.begin();
}
NOTREACHED();
Expand Down Expand Up @@ -646,7 +646,7 @@ void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
DCHECK(content_setting_bubble_model_);
if (sender == manage_checkbox_) {
content_setting_bubble_model_->OnManageCheckboxChecked(
manage_checkbox_->checked());
manage_checkbox_->GetChecked());

// Toggling the check state may change the dialog button text.
DialogModelChanged();
Expand Down
21 changes: 10 additions & 11 deletions chrome/browser/ui/views/create_application_shortcut_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,10 @@ base::string16 CreateChromeApplicationShortcutView::GetDialogButtonLabel(
bool CreateChromeApplicationShortcutView::IsDialogButtonEnabled(
ui::DialogButton button) const {
if (button == ui::DIALOG_BUTTON_OK)
return desktop_check_box_->checked() ||
((menu_check_box_ != nullptr) &&
menu_check_box_->checked()) ||
return desktop_check_box_->GetChecked() ||
((menu_check_box_ != nullptr) && menu_check_box_->GetChecked()) ||
((quick_launch_check_box_ != nullptr) &&
quick_launch_check_box_->checked());
quick_launch_check_box_->GetChecked());

return true;
}
Expand All @@ -194,15 +193,15 @@ bool CreateChromeApplicationShortcutView::Accept() {
return false;

web_app::ShortcutLocations creation_locations;
creation_locations.on_desktop = desktop_check_box_->checked();
if (menu_check_box_ != nullptr && menu_check_box_->checked()) {
creation_locations.on_desktop = desktop_check_box_->GetChecked();
if (menu_check_box_ != nullptr && menu_check_box_->GetChecked()) {
creation_locations.applications_menu_location =
web_app::APP_MENU_LOCATION_SUBDIR_CHROMEAPPS;
}

#if defined(OS_WIN)
creation_locations.in_quick_launch_bar = quick_launch_check_box_ == nullptr ?
false : quick_launch_check_box_->checked();
creation_locations.in_quick_launch_bar =
quick_launch_check_box_ && quick_launch_check_box_->GetChecked();
#elif defined(OS_POSIX)
// Create shortcut in Mac dock or as Linux (gnome/kde) application launcher
// are not implemented yet.
Expand All @@ -226,13 +225,13 @@ void CreateChromeApplicationShortcutView::ButtonPressed(
const ui::Event& event) {
if (sender == desktop_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateOnDesktop,
desktop_check_box_->checked());
desktop_check_box_->GetChecked());
} else if (sender == menu_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateInAppsMenu,
menu_check_box_->checked());
menu_check_box_->GetChecked());
} else if (sender == quick_launch_check_box_) {
profile_->GetPrefs()->SetBoolean(prefs::kWebAppCreateInQuickLaunchBar,
quick_launch_check_box_->checked());
quick_launch_check_box_->GetChecked());
}

// When no checkbox is checked we should not have the action button enabled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ bool DesktopMediaPickerDialogView::Accept() {
DesktopMediaID source = source_optional.value();
source.audio_share = audio_share_checkbox_ &&
audio_share_checkbox_->visible() &&
audio_share_checkbox_->checked();
audio_share_checkbox_->GetChecked();

if (source.type == DesktopMediaID::TYPE_WEB_CONTENTS) {
// Activate the selected tab and bring the browser window for the selected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void BookmarkAppConfirmationView::WindowClosing() {
bool BookmarkAppConfirmationView::Accept() {
web_app_info_.title = GetTrimmedTitle();
web_app_info_.open_as_window =
open_as_window_checkbox_ && open_as_window_checkbox_->checked();
open_as_window_checkbox_ && open_as_window_checkbox_->GetChecked();
std::move(callback_).Run(true,
std::make_unique<WebApplicationInfo>(web_app_info_));
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ base::string16 ExtensionUninstallDialogDelegateView::GetDialogButtonLabel(

bool ExtensionUninstallDialogDelegateView::Accept() {
if (dialog_)
dialog_->DialogAccepted(checkbox_ && checkbox_->checked());
dialog_->DialogAccepted(checkbox_ && checkbox_->GetChecked());
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ void MediaGalleriesDialogViews::ButtonPressed(views::Button* sender,
iter != checkbox_map_.end(); ++iter) {
if (sender == iter->second->checkbox()) {
controller_->DidToggleEntry(iter->first,
iter->second->checkbox()->checked());
iter->second->checkbox()->GetChecked());
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ TEST_F(MediaGalleriesDialogTest, InitializeCheckboxes) {
EXPECT_EQ(2U, dialog.checkbox_map_.size());

MediaGalleryCheckboxView* checkbox_view1 = dialog.checkbox_map_[1];
EXPECT_TRUE(checkbox_view1->checkbox()->checked());
EXPECT_TRUE(checkbox_view1->checkbox()->GetChecked());

MediaGalleryCheckboxView* checkbox_view2 = dialog.checkbox_map_[2];
EXPECT_FALSE(checkbox_view2->checkbox()->checked());
EXPECT_FALSE(checkbox_view2->checkbox()->GetChecked());
}

// Tests that toggling checkboxes updates the controller.
Expand All @@ -98,7 +98,7 @@ TEST_F(MediaGalleriesDialogTest, ToggleCheckboxes) {
MediaGalleriesDialogViews dialog(controller());
EXPECT_EQ(1U, dialog.checkbox_map_.size());
views::Checkbox* checkbox = dialog.checkbox_map_[1]->checkbox();
EXPECT_TRUE(checkbox->checked());
EXPECT_TRUE(checkbox->GetChecked());

ui::KeyEvent dummy_event(ui::ET_KEY_PRESSED, ui::VKEY_A, ui::EF_NONE);
EXPECT_CALL(*controller(), DidToggleEntry(1, false));
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/external_protocol_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ bool ExternalProtocolDialog::Accept() {
UMA_HISTOGRAM_LONG_TIMES("clickjacking.launch_url",
base::TimeTicks::Now() - creation_time_);

const bool remember = remember_decision_checkbox_->checked();
const bool remember = remember_decision_checkbox_->GetChecked();
ExternalProtocolHandler::RecordHandleStateMetrics(
remember, ExternalProtocolHandler::DONT_BLOCK);

Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/ui/views/first_run_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ views::View* FirstRunDialog::CreateExtraView() {
bool FirstRunDialog::Accept() {
GetWidget()->Hide();

ChangeMetricsReportingStateWithReply(report_crashes_->checked(),
ChangeMetricsReportingStateWithReply(report_crashes_->GetChecked(),
base::Bind(&InitCrashReporterIfEnabled));

if (make_default_->checked())
if (make_default_->GetChecked())
shell_integration::SetAsDefaultBrowser();

Done();
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/ime/ime_warning_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void ImeWarningBubbleView::ShowBubble(
}

bool ImeWarningBubbleView::Accept() {
if (never_show_checkbox_->checked()) {
if (never_show_checkbox_->GetChecked()) {
std::move(response_callback_)
.Run(ImeWarningBubblePermissionStatus::GRANTED_AND_NEVER_SHOW);
} else {
Expand Down
10 changes: 4 additions & 6 deletions chrome/browser/ui/views/intent_picker_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,8 @@ void IntentPickerBubbleView::CloseBubble() {
}

bool IntentPickerBubbleView::Accept() {
bool should_persist = remember_selection_checkbox_
? remember_selection_checkbox_->checked()
: false;
bool should_persist = remember_selection_checkbox_ &&
remember_selection_checkbox_->GetChecked();
RunCallback(app_info_[selected_app_tag_].launch_name,
app_info_[selected_app_tag_].type,
apps::IntentPickerCloseReason::OPEN_APP, should_persist);
Expand All @@ -223,9 +222,8 @@ bool IntentPickerBubbleView::Cancel() {
#else
kInvalidLaunchName;
#endif
bool should_persist = remember_selection_checkbox_
? remember_selection_checkbox_->checked()
: false;
bool should_persist = remember_selection_checkbox_ &&
remember_selection_checkbox_->GetChecked();
RunCallback(launch_name, apps::mojom::AppType::kUnknown,
apps::IntentPickerCloseReason::STAY_IN_CHROME, should_persist);
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ void MediaRemotingDialogView::WindowClosing() {
void MediaRemotingDialogView::ReportPermission(bool allowed) {
DCHECK(remember_choice_checkbox_);
DCHECK(permission_callback_);
if (remember_choice_checkbox_->checked()) {
if (remember_choice_checkbox_->GetChecked()) {
pref_service_->SetBoolean(::prefs::kMediaRouterMediaRemotingEnabled,
allowed);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/session_crashed_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void SessionCrashedBubbleView::OpenStartupPages() {
void SessionCrashedBubbleView::MaybeEnableUma() {
// Record user's choice for opt-in in to UMA.
// There's no opt-out choice in the crash restore bubble.
if (uma_option_ && uma_option_->checked()) {
if (uma_option_ && uma_option_->GetChecked()) {
ChangeMetricsReportingState(true);
RecordBubbleHistogramValue(SESSION_CRASHED_BUBBLE_UMA_OPTIN);
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/ui/views/translate/translate_bubble_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ void TranslateBubbleView::ButtonPressed(views::Button* sender,
case BUTTON_ID_ALWAYS_TRANSLATE: {
views::Checkbox* always_checkbox = GetAlwaysTranslateCheckbox();
DCHECK(always_checkbox);
should_always_translate_ = always_checkbox->checked();
should_always_translate_ = always_checkbox->GetChecked();
translate::ReportUiAction(should_always_translate_
? translate::ALWAYS_TRANSLATE_CHECKED
: translate::ALWAYS_TRANSLATE_UNCHECKED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndCancelButton) {
// Check the initial state.
EXPECT_FALSE(mock_model_->should_always_translate_);
EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->checked());
EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->GetChecked());

// Click the checkbox. The state is not saved yet.
bubble_->advanced_always_translate_checkbox_->SetChecked(true);
Expand All @@ -313,7 +313,7 @@ TEST_F(TranslateBubbleViewTest, AlwaysTranslateCheckboxAndDoneButton) {
// Check the initial state.
EXPECT_FALSE(mock_model_->should_always_translate_);
EXPECT_EQ(0, mock_model_->set_always_translate_called_count_);
EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->checked());
EXPECT_FALSE(bubble_->advanced_always_translate_checkbox_->GetChecked());

// Click the checkbox. The state is not saved yet.
bubble_->advanced_always_translate_checkbox_->SetChecked(true);
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/ui/views/uninstall_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ void UninstallView::SetupControls() {

bool UninstallView::Accept() {
user_selection_ = service_manager::RESULT_CODE_NORMAL_EXIT;
if (delete_profile_->checked())
if (delete_profile_->GetChecked())
user_selection_ = chrome::RESULT_CODE_UNINSTALL_DELETE_PROFILE;
if (change_default_browser_ && change_default_browser_->checked()) {
if (change_default_browser_ && change_default_browser_->GetChecked()) {
BrowsersMap::const_iterator i = browsers_->begin();
std::advance(i, browsers_combo_->GetSelectedIndex());
base::LaunchOptions options;
Expand Down Expand Up @@ -156,7 +156,7 @@ void UninstallView::ButtonPressed(views::Button* sender,
if (change_default_browser_ == sender) {
// Disable the browsers combobox if the user unchecks the checkbox.
DCHECK(browsers_combo_);
browsers_combo_->SetEnabled(change_default_browser_->checked());
browsers_combo_->SetEnabled(change_default_browser_->GetChecked());
}
}

Expand Down
2 changes: 1 addition & 1 deletion ui/message_center/views/notification_view_md.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,7 @@ void NotificationViewMD::ToggleInlineSettings(const ui::Event& event) {

bool inline_settings_visible = !settings_row_->visible();
bool disable_notification =
settings_row_->visible() && block_all_button_->checked();
settings_row_->visible() && block_all_button_->GetChecked();

settings_row_->SetVisible(inline_settings_visible);
content_row_->SetVisible(!inline_settings_visible);
Expand Down
Loading

0 comments on commit e95d05c

Please sign in to comment.