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

Side by Side Diff: chrome/browser/ui/views/permission_bubble/permission_prompt_impl.cc

Issue 2980713002: Views a11y: Obey DialogDelegate::GetAccessibleWindowRole() rather than making a dialog-within-a-dia… (Closed)
Patch Set: Fix test Created 3 years, 5 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/ui/views/permission_bubble/permission_prompt_impl.h" 5 #include "chrome/browser/ui/views/permission_bubble/permission_prompt_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 : public views::BubbleDialogDelegateView { 51 : public views::BubbleDialogDelegateView {
52 public: 52 public:
53 PermissionsBubbleDialogDelegateView( 53 PermissionsBubbleDialogDelegateView(
54 PermissionPromptImpl* owner, 54 PermissionPromptImpl* owner,
55 const std::vector<PermissionRequest*>& requests); 55 const std::vector<PermissionRequest*>& requests);
56 ~PermissionsBubbleDialogDelegateView() override; 56 ~PermissionsBubbleDialogDelegateView() override;
57 57
58 void CloseBubble(); 58 void CloseBubble();
59 59
60 // BubbleDialogDelegateView: 60 // BubbleDialogDelegateView:
61 ui::AXRole GetAccessibleWindowRole() const override;
61 bool ShouldShowCloseButton() const override; 62 bool ShouldShowCloseButton() const override;
62 base::string16 GetWindowTitle() const override; 63 base::string16 GetWindowTitle() const override;
63 void AddedToWidget() override; 64 void AddedToWidget() override;
64 void OnWidgetDestroying(views::Widget* widget) override; 65 void OnWidgetDestroying(views::Widget* widget) override;
65 void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
66 bool Cancel() override; 66 bool Cancel() override;
67 bool Accept() override; 67 bool Accept() override;
68 bool Close() override; 68 bool Close() override;
69 int GetDefaultDialogButton() const override; 69 int GetDefaultDialogButton() const override;
70 int GetDialogButtons() const override; 70 int GetDialogButtons() const override;
71 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; 71 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
72 void SizeToContents() override; 72 void SizeToContents() override;
73 73
74 // Updates the anchor's arrow and view. Also repositions the bubble so it's 74 // Updates the anchor's arrow and view. Also repositions the bubble so it's
75 // displayed in the correct location. 75 // displayed in the correct location.
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 PermissionsBubbleDialogDelegateView::~PermissionsBubbleDialogDelegateView() { 140 PermissionsBubbleDialogDelegateView::~PermissionsBubbleDialogDelegateView() {
141 if (owner_) 141 if (owner_)
142 owner_->Closing(); 142 owner_->Closing();
143 } 143 }
144 144
145 void PermissionsBubbleDialogDelegateView::CloseBubble() { 145 void PermissionsBubbleDialogDelegateView::CloseBubble() {
146 owner_ = nullptr; 146 owner_ = nullptr;
147 GetWidget()->Close(); 147 GetWidget()->Close();
148 } 148 }
149 149
150 ui::AXRole PermissionsBubbleDialogDelegateView::GetAccessibleWindowRole()
151 const {
152 return ui::AX_ROLE_ALERT_DIALOG;
153 }
154
150 bool PermissionsBubbleDialogDelegateView::ShouldShowCloseButton() const { 155 bool PermissionsBubbleDialogDelegateView::ShouldShowCloseButton() const {
151 return true; 156 return true;
152 } 157 }
153 158
154 base::string16 PermissionsBubbleDialogDelegateView::GetWindowTitle() const { 159 base::string16 PermissionsBubbleDialogDelegateView::GetWindowTitle() const {
155 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT, 160 return l10n_util::GetStringFUTF16(IDS_PERMISSIONS_BUBBLE_PROMPT,
156 display_origin_); 161 display_origin_);
157 } 162 }
158 163
159 void PermissionsBubbleDialogDelegateView::AddedToWidget() { 164 void PermissionsBubbleDialogDelegateView::AddedToWidget() {
(...skipping 10 matching lines...) Expand all
170 175
171 void PermissionsBubbleDialogDelegateView::OnWidgetDestroying( 176 void PermissionsBubbleDialogDelegateView::OnWidgetDestroying(
172 views::Widget* widget) { 177 views::Widget* widget) {
173 views::BubbleDialogDelegateView::OnWidgetDestroying(widget); 178 views::BubbleDialogDelegateView::OnWidgetDestroying(widget);
174 if (owner_) { 179 if (owner_) {
175 owner_->Closing(); 180 owner_->Closing();
176 owner_ = nullptr; 181 owner_ = nullptr;
177 } 182 }
178 } 183 }
179 184
180 void PermissionsBubbleDialogDelegateView::GetAccessibleNodeData(
181 ui::AXNodeData* node_data) {
182 views::BubbleDialogDelegateView::GetAccessibleNodeData(node_data);
183 node_data->role = ui::AX_ROLE_ALERT_DIALOG;
184 }
185
186 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const { 185 int PermissionsBubbleDialogDelegateView::GetDefaultDialogButton() const {
187 // To prevent permissions being accepted accidentally, and as a security 186 // To prevent permissions being accepted accidentally, and as a security
188 // measure against crbug.com/619429, permission prompts should not be accepted 187 // measure against crbug.com/619429, permission prompts should not be accepted
189 // as the default action. 188 // as the default action.
190 return ui::DIALOG_BUTTON_NONE; 189 return ui::DIALOG_BUTTON_NONE;
191 } 190 }
192 191
193 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const { 192 int PermissionsBubbleDialogDelegateView::GetDialogButtons() const {
194 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; 193 return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL;
195 } 194 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 344
346 void PermissionPromptImpl::Accept() { 345 void PermissionPromptImpl::Accept() {
347 if (delegate_) 346 if (delegate_)
348 delegate_->Accept(); 347 delegate_->Accept();
349 } 348 }
350 349
351 void PermissionPromptImpl::Deny() { 350 void PermissionPromptImpl::Deny() {
352 if (delegate_) 351 if (delegate_)
353 delegate_->Deny(); 352 delegate_->Deny();
354 } 353 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698