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_view_state.h" | 8 #include "ui/accessibility/ax_view_state.h" |
| 9 #include "ui/base/material_design/material_design_controller.h" |
9 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
10 #include "ui/gfx/color_utils.h" | 11 #include "ui/gfx/color_utils.h" |
11 #include "ui/gfx/geometry/rect.h" | 12 #include "ui/gfx/geometry/rect.h" |
12 #include "ui/native_theme/native_theme.h" | 13 #include "ui/native_theme/native_theme.h" |
13 #include "ui/views/bubble/bubble_frame_view.h" | 14 #include "ui/views/bubble/bubble_frame_view.h" |
14 #include "ui/views/focus/view_storage.h" | 15 #include "ui/views/focus/view_storage.h" |
15 #include "ui/views/layout/layout_constants.h" | 16 #include "ui/views/layout/layout_constants.h" |
16 #include "ui/views/widget/widget.h" | 17 #include "ui/views/widget/widget.h" |
17 #include "ui/views/widget/widget_observer.h" | 18 #include "ui/views/widget/widget_observer.h" |
18 #include "ui/views/window/dialog_client_view.h" | 19 #include "ui/views/window/dialog_client_view.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 BubbleFrameView* BubbleDialogDelegateView::GetBubbleFrameView() const { | 288 BubbleFrameView* BubbleDialogDelegateView::GetBubbleFrameView() const { |
288 const NonClientView* view = | 289 const NonClientView* view = |
289 GetWidget() ? GetWidget()->non_client_view() : NULL; | 290 GetWidget() ? GetWidget()->non_client_view() : NULL; |
290 return view ? static_cast<BubbleFrameView*>(view->frame_view()) : NULL; | 291 return view ? static_cast<BubbleFrameView*>(view->frame_view()) : NULL; |
291 } | 292 } |
292 | 293 |
293 void BubbleDialogDelegateView::UpdateColorsFromTheme( | 294 void BubbleDialogDelegateView::UpdateColorsFromTheme( |
294 const ui::NativeTheme* theme) { | 295 const ui::NativeTheme* theme) { |
295 if (!color_explicitly_set_) | 296 if (!color_explicitly_set_) |
296 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); | 297 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); |
297 set_background(Background::CreateSolidBackground(color())); | 298 // The background color is handled by the BubbleFrameView, so it shouldn't be |
| 299 // necessary to set the color on |this|. I am cowardly leaving it in place for |
| 300 // pre-MD bubbles in case this is necessary for some reason. |
| 301 if (!ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 302 set_background(Background::CreateSolidBackground(color())); |
298 BubbleFrameView* frame_view = GetBubbleFrameView(); | 303 BubbleFrameView* frame_view = GetBubbleFrameView(); |
299 if (frame_view) | 304 if (frame_view) |
300 frame_view->bubble_border()->set_background_color(color()); | 305 frame_view->bubble_border()->set_background_color(color()); |
301 } | 306 } |
302 | 307 |
303 void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget, | 308 void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget, |
304 bool visible) { | 309 bool visible) { |
305 if (widget == GetWidget() && anchor_widget() && | 310 if (widget == GetWidget() && anchor_widget() && |
306 anchor_widget()->GetTopLevelWidget()) { | 311 anchor_widget()->GetTopLevelWidget()) { |
307 anchor_widget()->GetTopLevelWidget()->SetAlwaysRenderAsActive(visible); | 312 anchor_widget()->GetTopLevelWidget()->SetAlwaysRenderAsActive(visible); |
308 } | 313 } |
309 | 314 |
310 // Fire AX_EVENT_ALERT for bubbles marked as AX_ROLE_ALERT_DIALOG; this | 315 // Fire AX_EVENT_ALERT for bubbles marked as AX_ROLE_ALERT_DIALOG; this |
311 // instructs accessibility tools to read the bubble in its entirety rather | 316 // instructs accessibility tools to read the bubble in its entirety rather |
312 // than just its title and initially focused view. See | 317 // than just its title and initially focused view. See |
313 // http://crbug.com/474622 for details. | 318 // http://crbug.com/474622 for details. |
314 if (widget == GetWidget() && visible) { | 319 if (widget == GetWidget() && visible) { |
315 ui::AXViewState state; | 320 ui::AXViewState state; |
316 GetAccessibleState(&state); | 321 GetAccessibleState(&state); |
317 if (state.role == ui::AX_ROLE_ALERT_DIALOG) | 322 if (state.role == ui::AX_ROLE_ALERT_DIALOG) |
318 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 323 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
319 } | 324 } |
320 } | 325 } |
321 | 326 |
322 } // namespace views | 327 } // namespace views |
OLD | NEW |