| 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 "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "ui/accessibility/ax_node_data.h" | 10 #include "ui/accessibility/ax_node_data.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 GetWidget()->Close(); | 151 GetWidget()->Close(); |
| 152 } | 152 } |
| 153 | 153 |
| 154 void BubbleDialogDelegateView::OnWidgetBoundsChanged( | 154 void BubbleDialogDelegateView::OnWidgetBoundsChanged( |
| 155 Widget* widget, | 155 Widget* widget, |
| 156 const gfx::Rect& new_bounds) { | 156 const gfx::Rect& new_bounds) { |
| 157 if (GetBubbleFrameView() && anchor_widget() == widget) | 157 if (GetBubbleFrameView() && anchor_widget() == widget) |
| 158 SizeToContents(); | 158 SizeToContents(); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void BubbleDialogDelegateView::AddedToWidget() { |
| 162 View* title_view = CreateTitleView(); |
| 163 if (title_view) { |
| 164 GetBubbleFrameView()->SetTitleView(title_view); |
| 165 PropagateUpdateTitleView(title_view); |
| 166 } |
| 167 } |
| 168 |
| 161 View* BubbleDialogDelegateView::GetAnchorView() const { | 169 View* BubbleDialogDelegateView::GetAnchorView() const { |
| 162 return anchor_view_tracker_->view(); | 170 return anchor_view_tracker_->view(); |
| 163 } | 171 } |
| 164 | 172 |
| 165 gfx::Rect BubbleDialogDelegateView::GetAnchorRect() const { | 173 gfx::Rect BubbleDialogDelegateView::GetAnchorRect() const { |
| 166 if (!GetAnchorView()) | 174 if (!GetAnchorView()) |
| 167 return anchor_rect_; | 175 return anchor_rect_; |
| 168 | 176 |
| 169 anchor_rect_ = GetAnchorView()->GetBoundsInScreen(); | 177 anchor_rect_ = GetAnchorView()->GetBoundsInScreen(); |
| 170 anchor_rect_.Inset(anchor_view_insets_); | 178 anchor_rect_.Inset(anchor_view_insets_); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 adjust_if_offscreen_ && !anchor_minimized); | 242 adjust_if_offscreen_ && !anchor_minimized); |
| 235 } | 243 } |
| 236 | 244 |
| 237 const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const { | 245 const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const { |
| 238 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 246 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 239 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 247 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) |
| 240 return rb.GetFontListWithDelta(ui::kTitleFontSizeDelta); | 248 return rb.GetFontListWithDelta(ui::kTitleFontSizeDelta); |
| 241 return rb.GetFontList(ui::ResourceBundle::MediumFont); | 249 return rb.GetFontList(ui::ResourceBundle::MediumFont); |
| 242 } | 250 } |
| 243 | 251 |
| 252 View* BubbleDialogDelegateView::CreateTitleView() { |
| 253 return nullptr; |
| 254 } |
| 255 |
| 256 void BubbleDialogDelegateView::PropagateUpdateTitleView(View* title_view) { |
| 257 if (title_view) |
| 258 UpdateTitleView(title_view, GetWindowTitle(), ShouldShowWindowTitle()); |
| 259 } |
| 260 |
| 244 void BubbleDialogDelegateView::OnNativeThemeChanged( | 261 void BubbleDialogDelegateView::OnNativeThemeChanged( |
| 245 const ui::NativeTheme* theme) { | 262 const ui::NativeTheme* theme) { |
| 246 UpdateColorsFromTheme(theme); | 263 UpdateColorsFromTheme(theme); |
| 247 } | 264 } |
| 248 | 265 |
| 249 void BubbleDialogDelegateView::Init() {} | 266 void BubbleDialogDelegateView::Init() {} |
| 250 | 267 |
| 251 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) { | 268 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) { |
| 252 // When the anchor view gets set the associated anchor widget might | 269 // When the anchor view gets set the associated anchor widget might |
| 253 // change as well. | 270 // change as well. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 // http://crbug.com/474622 for details. | 334 // http://crbug.com/474622 for details. |
| 318 if (widget == GetWidget() && visible) { | 335 if (widget == GetWidget() && visible) { |
| 319 ui::AXNodeData node_data; | 336 ui::AXNodeData node_data; |
| 320 GetAccessibleNodeData(&node_data); | 337 GetAccessibleNodeData(&node_data); |
| 321 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) | 338 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) |
| 322 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 339 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
| 323 } | 340 } |
| 324 } | 341 } |
| 325 | 342 |
| 326 } // namespace views | 343 } // namespace views |
| OLD | NEW |