| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/views/validation_message_bubble_view.h" | 5 #include "chrome/browser/ui/views/validation_message_bubble_view.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/browser_dialogs.h" |
| 7 #include "chrome/grit/theme_resources.h" | 8 #include "chrome/grit/theme_resources.h" |
| 8 #include "content/public/browser/render_widget_host.h" | 9 #include "content/public/browser/render_widget_host.h" |
| 9 #include "content/public/browser/web_contents.h" | 10 #include "content/public/browser/web_contents.h" |
| 10 #include "ui/base/layout.h" | 11 #include "ui/base/layout.h" |
| 11 #include "ui/base/resource/resource_bundle.h" | 12 #include "ui/base/resource/resource_bundle.h" |
| 12 #include "ui/views/controls/image_view.h" | 13 #include "ui/views/controls/image_view.h" |
| 13 #include "ui/views/controls/label.h" | 14 #include "ui/views/controls/label.h" |
| 14 #include "ui/views/widget/widget.h" | 15 #include "ui/views/widget/widget.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 sub_label->SetBounds(text_start_x, | 72 sub_label->SetBounds(text_start_x, |
| 72 content_bottom + kTextVerticalMargin, | 73 content_bottom + kTextVerticalMargin, |
| 73 label_width, | 74 label_width, |
| 74 sub_label->GetHeightForWidth(label_width)); | 75 sub_label->GetHeightForWidth(label_width)); |
| 75 content_bottom += kTextVerticalMargin + sub_label->height(); | 76 content_bottom += kTextVerticalMargin + sub_label->height(); |
| 76 } | 77 } |
| 77 | 78 |
| 78 size_ = gfx::Size(text_start_x + label_width, content_bottom); | 79 size_ = gfx::Size(text_start_x + label_width, content_bottom); |
| 79 | 80 |
| 80 views::BubbleDialogDelegateView::CreateBubble(this)->ShowInactive(); | 81 views::BubbleDialogDelegateView::CreateBubble(this)->ShowInactive(); |
| 82 chrome::RecordDialogCreation(chrome::DialogIdentifier::VALIDATION_MESSAGE); |
| 81 } | 83 } |
| 82 | 84 |
| 83 ValidationMessageBubbleView::~ValidationMessageBubbleView() { | 85 ValidationMessageBubbleView::~ValidationMessageBubbleView() { |
| 84 } | 86 } |
| 85 | 87 |
| 86 gfx::Rect ValidationMessageBubbleView::RootViewToScreenRect( | 88 gfx::Rect ValidationMessageBubbleView::RootViewToScreenRect( |
| 87 const gfx::Rect& rect_in_root_view, | 89 const gfx::Rect& rect_in_root_view, |
| 88 const content::RenderWidgetHostView* render_widget_host_view) const { | 90 const content::RenderWidgetHostView* render_widget_host_view) const { |
| 89 gfx::NativeView view = render_widget_host_view->GetNativeView(); | 91 gfx::NativeView view = render_widget_host_view->GetNativeView(); |
| 90 const float scale = ui::GetScaleFactorForNativeView(view); | 92 const float scale = ui::GetScaleFactorForNativeView(view); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 103 void ValidationMessageBubbleView::SetPositionRelativeToAnchor( | 105 void ValidationMessageBubbleView::SetPositionRelativeToAnchor( |
| 104 content::RenderWidgetHost* widget_host, | 106 content::RenderWidgetHost* widget_host, |
| 105 const gfx::Rect& anchor_in_root_view) { | 107 const gfx::Rect& anchor_in_root_view) { |
| 106 SetAnchorRect( | 108 SetAnchorRect( |
| 107 RootViewToScreenRect(anchor_in_root_view, widget_host->GetView())); | 109 RootViewToScreenRect(anchor_in_root_view, widget_host->GetView())); |
| 108 } | 110 } |
| 109 | 111 |
| 110 void ValidationMessageBubbleView::CloseValidationMessage() { | 112 void ValidationMessageBubbleView::CloseValidationMessage() { |
| 111 GetWidget()->Close(); | 113 GetWidget()->Close(); |
| 112 } | 114 } |
| OLD | NEW |