| 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/material_design/material_design_controller.h" |
| 10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 BubbleFrameView* BubbleDialogDelegateView::GetBubbleFrameView() const { | 288 BubbleFrameView* BubbleDialogDelegateView::GetBubbleFrameView() const { |
| 289 const NonClientView* view = | 289 const NonClientView* view = |
| 290 GetWidget() ? GetWidget()->non_client_view() : NULL; | 290 GetWidget() ? GetWidget()->non_client_view() : NULL; |
| 291 return view ? static_cast<BubbleFrameView*>(view->frame_view()) : NULL; | 291 return view ? static_cast<BubbleFrameView*>(view->frame_view()) : NULL; |
| 292 } | 292 } |
| 293 | 293 |
| 294 void BubbleDialogDelegateView::UpdateColorsFromTheme( | 294 void BubbleDialogDelegateView::UpdateColorsFromTheme( |
| 295 const ui::NativeTheme* theme) { | 295 const ui::NativeTheme* theme) { |
| 296 if (!color_explicitly_set_) | 296 if (!color_explicitly_set_) |
| 297 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); | 297 color_ = theme->GetSystemColor(ui::NativeTheme::kColorId_BubbleBackground); |
| 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())); | |
| 303 BubbleFrameView* frame_view = GetBubbleFrameView(); | 298 BubbleFrameView* frame_view = GetBubbleFrameView(); |
| 304 if (frame_view) | 299 if (frame_view) |
| 305 frame_view->bubble_border()->set_background_color(color()); | 300 frame_view->bubble_border()->set_background_color(color()); |
| 306 } | 301 } |
| 307 | 302 |
| 308 void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget, | 303 void BubbleDialogDelegateView::HandleVisibilityChanged(Widget* widget, |
| 309 bool visible) { | 304 bool visible) { |
| 310 if (widget == GetWidget() && anchor_widget() && | 305 if (widget == GetWidget() && anchor_widget() && |
| 311 anchor_widget()->GetTopLevelWidget()) { | 306 anchor_widget()->GetTopLevelWidget()) { |
| 312 anchor_widget()->GetTopLevelWidget()->SetAlwaysRenderAsActive(visible); | 307 anchor_widget()->GetTopLevelWidget()->SetAlwaysRenderAsActive(visible); |
| 313 } | 308 } |
| 314 | 309 |
| 315 // Fire AX_EVENT_ALERT for bubbles marked as AX_ROLE_ALERT_DIALOG; this | 310 // Fire AX_EVENT_ALERT for bubbles marked as AX_ROLE_ALERT_DIALOG; this |
| 316 // instructs accessibility tools to read the bubble in its entirety rather | 311 // instructs accessibility tools to read the bubble in its entirety rather |
| 317 // than just its title and initially focused view. See | 312 // than just its title and initially focused view. See |
| 318 // http://crbug.com/474622 for details. | 313 // http://crbug.com/474622 for details. |
| 319 if (widget == GetWidget() && visible) { | 314 if (widget == GetWidget() && visible) { |
| 320 ui::AXViewState state; | 315 ui::AXViewState state; |
| 321 GetAccessibleState(&state); | 316 GetAccessibleState(&state); |
| 322 if (state.role == ui::AX_ROLE_ALERT_DIALOG) | 317 if (state.role == ui::AX_ROLE_ALERT_DIALOG) |
| 323 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 318 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 324 } | 319 } |
| 325 } | 320 } |
| 326 | 321 |
| 327 } // namespace views | 322 } // namespace views |
| OLD | NEW |