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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) { | 99 ClientView* BubbleDialogDelegateView::CreateClientView(Widget* widget) { |
100 DialogClientView* client = new DialogClientView(widget, GetContentsView()); | 100 DialogClientView* client = new DialogClientView(widget, GetContentsView()); |
101 client->SetButtonRowInsets(gfx::Insets()); | 101 client->SetButtonRowInsets(gfx::Insets()); |
102 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_); | 102 widget->non_client_view()->set_mirror_client_in_rtl(mirror_arrow_in_rtl_); |
103 return client; | 103 return client; |
104 } | 104 } |
105 | 105 |
106 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( | 106 NonClientFrameView* BubbleDialogDelegateView::CreateNonClientFrameView( |
107 Widget* widget) { | 107 Widget* widget) { |
108 BubbleFrameView* frame = new BubbleFrameView(title_margins_, margins_); | 108 BubbleFrameView* frame = new BubbleFrameView(title_margins_, margins_); |
109 // Note: In CreateBubble, the call to SizeToContents() will cause | |
110 // the relayout that this call requires. | |
111 frame->SetTitleFontList(GetTitleFontList()); | |
112 frame->SetFootnoteView(CreateFootnoteView()); | 109 frame->SetFootnoteView(CreateFootnoteView()); |
113 | 110 |
114 BubbleBorder::Arrow adjusted_arrow = arrow(); | 111 BubbleBorder::Arrow adjusted_arrow = arrow(); |
115 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_) | 112 if (base::i18n::IsRTL() && mirror_arrow_in_rtl_) |
116 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); | 113 adjusted_arrow = BubbleBorder::horizontal_mirror(adjusted_arrow); |
117 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>( | 114 frame->SetBubbleBorder(std::unique_ptr<BubbleBorder>( |
118 new BubbleBorder(adjusted_arrow, shadow(), color()))); | 115 new BubbleBorder(adjusted_arrow, shadow(), color()))); |
119 return frame; | 116 return frame; |
120 } | 117 } |
121 | 118 |
122 const char* BubbleDialogDelegateView::GetClassName() const { | 119 const char* BubbleDialogDelegateView::GetClassName() const { |
123 return kViewClassName; | 120 return kViewClassName; |
124 } | 121 } |
125 | 122 |
| 123 void BubbleDialogDelegateView::AddedToWidget() { |
| 124 SetupTitleView(); |
| 125 } |
| 126 |
126 void BubbleDialogDelegateView::OnWidgetDestroying(Widget* widget) { | 127 void BubbleDialogDelegateView::OnWidgetDestroying(Widget* widget) { |
127 if (anchor_widget() == widget) | 128 if (anchor_widget() == widget) |
128 SetAnchorView(NULL); | 129 SetAnchorView(NULL); |
129 } | 130 } |
130 | 131 |
131 void BubbleDialogDelegateView::OnWidgetVisibilityChanging(Widget* widget, | 132 void BubbleDialogDelegateView::OnWidgetVisibilityChanging(Widget* widget, |
132 bool visible) { | 133 bool visible) { |
133 #if defined(OS_WIN) | 134 #if defined(OS_WIN) |
134 // On Windows we need to handle this before the bubble is visible or hidden. | 135 // On Windows we need to handle this before the bubble is visible or hidden. |
135 // Please see the comment on the OnWidgetVisibilityChanging function. On | 136 // Please see the comment on the OnWidgetVisibilityChanging function. On |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 | 228 |
228 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { | 229 gfx::Rect BubbleDialogDelegateView::GetBubbleBounds() { |
229 // The argument rect has its origin at the bubble's arrow anchor point; | 230 // The argument rect has its origin at the bubble's arrow anchor point; |
230 // its size is the preferred size of the bubble's client view (this view). | 231 // its size is the preferred size of the bubble's client view (this view). |
231 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); | 232 bool anchor_minimized = anchor_widget() && anchor_widget()->IsMinimized(); |
232 return GetBubbleFrameView()->GetUpdatedWindowBounds( | 233 return GetBubbleFrameView()->GetUpdatedWindowBounds( |
233 GetAnchorRect(), GetWidget()->client_view()->GetPreferredSize(), | 234 GetAnchorRect(), GetWidget()->client_view()->GetPreferredSize(), |
234 adjust_if_offscreen_ && !anchor_minimized); | 235 adjust_if_offscreen_ && !anchor_minimized); |
235 } | 236 } |
236 | 237 |
237 const gfx::FontList& BubbleDialogDelegateView::GetTitleFontList() const { | 238 View* BubbleDialogDelegateView::CreateTitleView( |
238 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 239 const base::string16& title_text) { |
239 if (ui::MaterialDesignController::IsSecondaryUiMaterial()) | 240 return nullptr; |
240 return rb.GetFontListWithDelta(ui::kTitleFontSizeDelta); | 241 } |
241 return rb.GetFontList(ui::ResourceBundle::MediumFont); | 242 |
| 243 void BubbleDialogDelegateView::SetupTitleView() { |
| 244 View* title_view = CreateTitleView(GetWindowTitle()); |
| 245 if (title_view) |
| 246 GetBubbleFrameView()->SetTitleView(title_view); |
242 } | 247 } |
243 | 248 |
244 void BubbleDialogDelegateView::OnNativeThemeChanged( | 249 void BubbleDialogDelegateView::OnNativeThemeChanged( |
245 const ui::NativeTheme* theme) { | 250 const ui::NativeTheme* theme) { |
246 UpdateColorsFromTheme(theme); | 251 UpdateColorsFromTheme(theme); |
247 } | 252 } |
248 | 253 |
249 void BubbleDialogDelegateView::Init() {} | 254 void BubbleDialogDelegateView::Init() {} |
250 | 255 |
251 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) { | 256 void BubbleDialogDelegateView::SetAnchorView(View* anchor_view) { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
317 // http://crbug.com/474622 for details. | 322 // http://crbug.com/474622 for details. |
318 if (widget == GetWidget() && visible) { | 323 if (widget == GetWidget() && visible) { |
319 ui::AXNodeData node_data; | 324 ui::AXNodeData node_data; |
320 GetAccessibleNodeData(&node_data); | 325 GetAccessibleNodeData(&node_data); |
321 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) | 326 if (node_data.role == ui::AX_ROLE_ALERT_DIALOG) |
322 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); | 327 NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, true); |
323 } | 328 } |
324 } | 329 } |
325 | 330 |
326 } // namespace views | 331 } // namespace views |
OLD | NEW |