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

Side by Side Diff: chrome/browser/ui/views/infobars/infobar_view.cc

Issue 2477463003: Replace ui::AXViewState with AXNodeData and AXActionData (Closed)
Patch Set: Fix test Created 4 years, 1 month 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/ui/views/infobars/infobar_view.h" 5 #include "chrome/browser/ui/views/infobars/infobar_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/ui/infobar_container_delegate.h" 13 #include "chrome/browser/ui/infobar_container_delegate.h"
14 #include "chrome/browser/ui/views/infobars/infobar_background.h" 14 #include "chrome/browser/ui/views/infobars/infobar_background.h"
15 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
16 #include "chrome/grit/theme_resources.h" 16 #include "chrome/grit/theme_resources.h"
17 #include "components/infobars/core/infobar_delegate.h" 17 #include "components/infobars/core/infobar_delegate.h"
18 #include "components/strings/grit/components_strings.h" 18 #include "components/strings/grit/components_strings.h"
19 #include "third_party/skia/include/effects/SkGradientShader.h" 19 #include "third_party/skia/include/effects/SkGradientShader.h"
20 #include "ui/accessibility/ax_view_state.h" 20 #include "ui/accessibility/ax_node_data.h"
21 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
22 #include "ui/gfx/canvas.h" 22 #include "ui/gfx/canvas.h"
23 #include "ui/gfx/color_palette.h" 23 #include "ui/gfx/color_palette.h"
24 #include "ui/gfx/image/image.h" 24 #include "ui/gfx/image/image.h"
25 #include "ui/gfx/paint_vector_icon.h" 25 #include "ui/gfx/paint_vector_icon.h"
26 #include "ui/gfx/vector_icons_public.h" 26 #include "ui/gfx/vector_icons_public.h"
27 #include "ui/native_theme/common_theme.h" 27 #include "ui/native_theme/common_theme.h"
28 #include "ui/native_theme/native_theme.h" 28 #include "ui/native_theme/native_theme.h"
29 #include "ui/views/controls/button/image_button.h" 29 #include "ui/views/controls/button/image_button.h"
30 #include "ui/views/controls/button/label_button_border.h" 30 #include "ui/views/controls/button/label_button_border.h"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 if (!widget || widget->IsActive()) 271 if (!widget || widget->IsActive())
272 FocusLastFocusedExternalView(); 272 FocusLastFocusedExternalView();
273 } 273 }
274 274
275 void InfoBarView::PlatformSpecificOnHeightsRecalculated() { 275 void InfoBarView::PlatformSpecificOnHeightsRecalculated() {
276 // Ensure that notifying our container of our size change will result in a 276 // Ensure that notifying our container of our size change will result in a
277 // re-layout. 277 // re-layout.
278 InvalidateLayout(); 278 InvalidateLayout();
279 } 279 }
280 280
281 void InfoBarView::GetAccessibleState(ui::AXViewState* state) { 281 void InfoBarView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
282 state->name = l10n_util::GetStringUTF16( 282 node_data->SetName(l10n_util::GetStringUTF8(
283 (delegate()->GetInfoBarType() == 283 (delegate()->GetInfoBarType() == infobars::InfoBarDelegate::WARNING_TYPE)
284 infobars::InfoBarDelegate::WARNING_TYPE) ? 284 ? IDS_ACCNAME_INFOBAR_WARNING
285 IDS_ACCNAME_INFOBAR_WARNING : IDS_ACCNAME_INFOBAR_PAGE_ACTION); 285 : IDS_ACCNAME_INFOBAR_PAGE_ACTION));
286 state->role = ui::AX_ROLE_ALERT; 286 node_data->role = ui::AX_ROLE_ALERT;
287 state->keyboard_shortcut = base::ASCIIToUTF16("Alt+Shift+A"); 287 node_data->AddStringAttribute(ui::AX_ATTR_SHORTCUT, "Alt+Shift+A");
288 } 288 }
289 289
290 gfx::Size InfoBarView::GetPreferredSize() const { 290 gfx::Size InfoBarView::GetPreferredSize() const {
291 return gfx::Size( 291 return gfx::Size(
292 kEdgeItemPadding + (icon_ ? (icon_->width() + kIconToLabelSpacing) : 0) + 292 kEdgeItemPadding + (icon_ ? (icon_->width() + kIconToLabelSpacing) : 0) +
293 ContentMinimumWidth() + kBeforeCloseButtonSpacing + 293 ContentMinimumWidth() + kBeforeCloseButtonSpacing +
294 close_button_->width() + kEdgeItemPadding, 294 close_button_->width() + kEdgeItemPadding,
295 total_height()); 295 total_height());
296 } 296 }
297 297
298 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) { 298 void InfoBarView::OnWillChangeFocus(View* focused_before, View* focused_now) {
299 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now); 299 views::ExternalFocusTracker::OnWillChangeFocus(focused_before, focused_now);
300 300
301 // This will trigger some screen readers to read the entire contents of this 301 // This will trigger some screen readers to read the entire contents of this
302 // infobar. 302 // infobar.
303 if (focused_before && focused_now && !Contains(focused_before) && 303 if (focused_before && focused_now && !Contains(focused_before) &&
304 Contains(focused_now)) { 304 Contains(focused_now)) {
305 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); 305 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true);
306 } 306 }
307 } 307 }
308 308
309 bool InfoBarView::DoesIntersectRect(const View* target, 309 bool InfoBarView::DoesIntersectRect(const View* target,
310 const gfx::Rect& rect) const { 310 const gfx::Rect& rect) const {
311 DCHECK_EQ(this, target); 311 DCHECK_EQ(this, target);
312 // Only events that intersect the portion below the arrow are interesting. 312 // Only events that intersect the portion below the arrow are interesting.
313 gfx::Rect non_arrow_bounds = GetLocalBounds(); 313 gfx::Rect non_arrow_bounds = GetLocalBounds();
314 non_arrow_bounds.Inset(0, arrow_height(), 0, 0); 314 non_arrow_bounds.Inset(0, arrow_height(), 0, 0);
315 return rect.Intersects(non_arrow_bounds); 315 return rect.Intersects(non_arrow_bounds);
316 } 316 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/infobars/infobar_view.h ('k') | chrome/browser/ui/views/location_bar/bubble_icon_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698