Index: chrome/browser/ui/views/validation_message_bubble_view.cc |
diff --git a/chrome/browser/ui/views/validation_message_bubble_view.cc b/chrome/browser/ui/views/validation_message_bubble_view.cc |
index 4cd54819be819a0277b33841368726f30b9e648d..9eea2bae47255ee80a433d5282df44846519a041 100644 |
--- a/chrome/browser/ui/views/validation_message_bubble_view.cc |
+++ b/chrome/browser/ui/views/validation_message_bubble_view.cc |
@@ -2,76 +2,43 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/ui/validation_message_bubble.h" |
+#include "chrome/browser/ui/views/validation_message_bubble_view.h" |
-#include "chrome/browser/platform_util.h" |
-#include "chrome/browser/ui/views/validation_message_bubble_delegate.h" |
#include "content/public/browser/render_widget_host.h" |
#include "content/public/browser/render_widget_host_view.h" |
+#include "content/public/browser/web_contents.h" |
#include "ui/views/widget/widget.h" |
-namespace { |
- |
-// A ValidationMessageBubble implementation for Views. |
-class ValidationMessageBubbleImpl |
- : public chrome::ValidationMessageBubble, |
- public ValidationMessageBubbleDelegate::Observer { |
- public: |
- ValidationMessageBubbleImpl(content::RenderWidgetHost* widget_host, |
- const gfx::Rect& anchor_in_screen, |
- const base::string16& main_text, |
- const base::string16& sub_text); |
- |
- ~ValidationMessageBubbleImpl() override { |
- if (delegate_ != NULL) |
- delegate_->Close(); |
- } |
- |
- void SetPositionRelativeToAnchor( |
- content::RenderWidgetHost* widget_host, |
- const gfx::Rect& anchor_in_root_view) override { |
- if (!delegate_) |
- return; |
- delegate_->SetPositionRelativeToAnchor(anchor_in_root_view + |
- widget_host->GetView()->GetViewBounds().origin().OffsetFromOrigin()); |
- } |
- |
- // ValidationMessageBubbleDelegate::Observer override: |
- void WindowClosing() override { delegate_ = NULL; } |
- |
- private: |
- ValidationMessageBubbleDelegate* delegate_; |
- |
- DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl); |
-}; |
- |
-ValidationMessageBubbleImpl::ValidationMessageBubbleImpl( |
- content::RenderWidgetHost* widget_host, |
- const gfx::Rect& anchor_in_screen, |
+ValidationMessageBubbleView::ValidationMessageBubbleView( |
+ content::WebContents* web_contents, |
+ const gfx::Rect& anchor_in_root_view, |
const base::string16& main_text, |
const base::string16& sub_text) { |
+ content::RenderWidgetHostView* rwhv = web_contents->GetRenderWidgetHostView(); |
+ const gfx::Rect anchor_in_screen = |
+ anchor_in_root_view + rwhv->GetViewBounds().origin().OffsetFromOrigin(); |
delegate_ = new ValidationMessageBubbleDelegate( |
anchor_in_screen, main_text, sub_text, this); |
- delegate_->set_parent_window(platform_util::GetTopLevel( |
- widget_host->GetView()->GetNativeView())); |
+ delegate_->set_parent_window(rwhv->GetNativeView()); |
views::BubbleDelegateView::CreateBubble(delegate_); |
delegate_->GetWidget()->ShowInactive(); |
} |
-} // namespace |
- |
-namespace chrome { |
+ValidationMessageBubbleView::~ValidationMessageBubbleView() { |
+ if (delegate_) |
+ delegate_->Close(); |
+} |
-scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( |
+void ValidationMessageBubbleView::SetPositionRelativeToAnchor( |
content::RenderWidgetHost* widget_host, |
- const gfx::Rect& anchor_in_root_view, |
- const base::string16& main_text, |
- const base::string16& sub_text) { |
- const gfx::Rect anchor_in_screen = anchor_in_root_view |
- + widget_host->GetView()->GetViewBounds().origin().OffsetFromOrigin(); |
- scoped_ptr<ValidationMessageBubble> bubble(new ValidationMessageBubbleImpl( |
- widget_host, anchor_in_screen, main_text, sub_text)); |
- return bubble.Pass(); |
+ const gfx::Rect& anchor_in_root_view) { |
+ if (!delegate_) |
+ return; |
+ delegate_->SetPositionRelativeToAnchor( |
+ anchor_in_root_view + |
+ widget_host->GetView()->GetViewBounds().origin().OffsetFromOrigin()); |
} |
-} // namespace chrome |
+void ValidationMessageBubbleView::WindowClosing() { |
+ delegate_ = NULL; |
+} |