| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/views/bubble/bubble_dialog_delegate.h" | 5 #include "ui/views/bubble/bubble_dialog_delegate.h" |
| 6 | 6 |
| 7 #include "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "ui/accessibility/ax_node_data.h" | 8 #include "ui/accessibility/ax_node_data.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" | 9 #include "ui/base/material_design/material_design_controller.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| 11 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
| 12 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
| 13 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
| 14 #include "ui/views/bubble/bubble_frame_view.h" | 14 #include "ui/views/bubble/bubble_frame_view.h" |
| 15 #include "ui/views/focus/view_storage.h" | 15 #include "ui/views/focus/view_storage.h" |
| 16 #include "ui/views/layout/layout_constants.h" | 16 #include "ui/views/layout/layout_constants.h" |
| 17 #include "ui/views/view.h" |
| 17 #include "ui/views/widget/widget.h" | 18 #include "ui/views/widget/widget.h" |
| 18 #include "ui/views/widget/widget_observer.h" | 19 #include "ui/views/widget/widget_observer.h" |
| 19 #include "ui/views/window/dialog_client_view.h" | 20 #include "ui/views/window/dialog_client_view.h" |
| 20 | 21 |
| 21 #if defined(OS_WIN) | 22 #if defined(OS_WIN) |
| 22 #include "ui/base/win/shell.h" | 23 #include "ui/base/win/shell.h" |
| 23 #endif | 24 #endif |
| 24 | 25 |
| 25 namespace views { | 26 namespace views { |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // Create a widget to host the bubble. | 30 // Create a widget to host the bubble. |
| 30 Widget* CreateBubbleWidget(BubbleDialogDelegateView* bubble) { | 31 Widget* CreateBubbleWidget(BubbleDialogDelegateView* bubble) { |
| 31 Widget* bubble_widget = new Widget(); | 32 Widget* bubble_widget = new Widget(); |
| 32 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE); | 33 Widget::InitParams bubble_params(Widget::InitParams::TYPE_BUBBLE); |
| 33 bubble_params.delegate = bubble; | 34 bubble_params.delegate = bubble; |
| 34 bubble_params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; | 35 bubble_params.opacity = Widget::InitParams::TRANSLUCENT_WINDOW; |
| 35 bubble_params.accept_events = bubble->accept_events(); | 36 bubble_params.accept_events = bubble->accept_events(); |
| 36 if (bubble->parent_window()) | 37 if (bubble->parent_window()) |
| 37 bubble_params.parent = bubble->parent_window(); | 38 bubble_params.parent = bubble->parent_window(); |
| 38 else if (bubble->anchor_widget()) | 39 else if (bubble->anchor_widget()) |
| 39 bubble_params.parent = bubble->anchor_widget()->GetNativeView(); | 40 bubble_params.parent = bubble->anchor_widget()->GetNativeView(); |
| 40 bubble_params.activatable = bubble->CanActivate() | 41 bubble_params.activatable = bubble->CanActivate() |
| 41 ? Widget::InitParams::ACTIVATABLE_YES | 42 ? Widget::InitParams::ACTIVATABLE_YES |
| 42 : Widget::InitParams::ACTIVATABLE_NO; | 43 : Widget::InitParams::ACTIVATABLE_NO; |
| 43 bubble->OnBeforeBubbleWidgetInit(&bubble_params, bubble_widget); | 44 bubble->OnBeforeBubbleWidgetInit(&bubble_params, bubble_widget); |
| 44 bubble_widget->Init(bubble_params); | 45 bubble_widget->Init(bubble_params); |
| 46 |
| 47 View* root_view = bubble_widget->GetRootView(); |
| 48 if (root_view != nullptr) |
| 49 root_view->SetFocusBehavior(View::FocusBehavior::ACCESSIBLE_ONLY); |
| 50 |
| 45 if (bubble_params.parent) | 51 if (bubble_params.parent) |
| 46 bubble_widget->StackAbove(bubble_params.parent); | 52 bubble_widget->StackAbove(bubble_params.parent); |
| 47 return bubble_widget; | 53 return bubble_widget; |
| 48 } | 54 } |
| 49 | 55 |
| 50 } // namespace | 56 } // namespace |
| 51 | 57 |
| 52 // static | 58 // static |
| 53 const char BubbleDialogDelegateView::kViewClassName[] = | 59 const char BubbleDialogDelegateView::kViewClassName[] = |
| 54 "BubbleDialogDelegateView"; | 60 "BubbleDialogDelegateView"; |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // http://crbug.com/474622 for details. | 325 // http://crbug.com/474622 for details. |
| 320 if (widget == GetWidget() && visible) { | 326 if (widget == GetWidget() && visible) { |
| 321 ui::AXNodeData node_data; | 327 ui::AXNodeData node_data; |
| 322 GetAccessibleNodeData(&node_data); | 328 GetAccessibleNodeData(&node_data); |
| 323 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) | 329 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) |
| 324 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 330 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 325 } | 331 } |
| 326 } | 332 } |
| 327 | 333 |
| 328 } // namespace views | 334 } // namespace views |
| OLD | NEW |