Commit b573fcc4 authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

Change default selection in getDisplayMedia to cancel

To prevent permissions being accepted accidentally, permission prompts should
not be accepted as the default action. This CL changes default selection to
cancel button to reflect that.

Bug: 326740
Change-Id: I29d3e5c61c6a56546c7d9ada0824d3fccb91bc4f
Reviewed-on: https://chromium-review.googlesource.com/c/1334856Reviewed-by: default avatarChristopher Thompson <cthomp@chromium.org>
Reviewed-by: default avatarQiang Chen <qiangchen@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608064}
parent 9a27b84f
......@@ -299,6 +299,12 @@ views::View* DesktopMediaPickerDialogView::GetInitiallyFocusedView() {
return list_views_[0];
}
int DesktopMediaPickerDialogView::GetDefaultDialogButton() const {
// To prevent permissions being accepted accidentally, permission prompts
// should not be accepted as the default action.
return ui::DIALOG_BUTTON_CANCEL;
}
base::string16 DesktopMediaPickerDialogView::GetDialogButtonLabel(
ui::DialogButton button) const {
return l10n_util::GetStringUTF16(button == ui::DIALOG_BUTTON_OK
......
......@@ -49,6 +49,7 @@ class DesktopMediaPickerDialogView : public views::DialogDelegateView,
base::string16 GetWindowTitle() const override;
bool IsDialogButtonEnabled(ui::DialogButton button) const override;
views::View* GetInitiallyFocusedView() override;
int GetDefaultDialogButton() const override;
base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
View* CreateExtraView() override;
bool Accept() override;
......
......@@ -15,6 +15,9 @@
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/test/test_browser_dialog.h"
#include "content/public/browser/desktop_media_id.h"
#include "ui/views/controls/button/label_button.h"
#include "ui/views/window/dialog_client_view.h"
#include "ui/views/window/dialog_delegate.h"
class DesktopMediaPickerViewsBrowserTest : public DialogBrowserTest {
public:
......@@ -43,7 +46,7 @@ class DesktopMediaPickerViewsBrowserTest : public DialogBrowserTest {
DesktopMediaPicker::DoneCallback());
}
private:
protected:
std::unique_ptr<DesktopMediaPickerViews> picker_;
DISALLOW_COPY_AND_ASSIGN(DesktopMediaPickerViewsBrowserTest);
......@@ -54,3 +57,12 @@ class DesktopMediaPickerViewsBrowserTest : public DialogBrowserTest {
IN_PROC_BROWSER_TEST_F(DesktopMediaPickerViewsBrowserTest, InvokeUi_default) {
ShowAndVerifyUi();
}
IN_PROC_BROWSER_TEST_F(DesktopMediaPickerViewsBrowserTest,
InitiallyFocusesCancel) {
ShowUi(std::string());
views::DialogDelegate* dialog =
picker_->GetDialogViewForTesting()->AsDialogDelegate();
EXPECT_EQ(dialog->GetDialogClientView()->cancel_button(),
dialog->DialogDelegate::GetInitiallyFocusedView());
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment