Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(225)

Unified Diff: chrome/browser/ui/views/validation_message_bubble_view.cc

Issue 867323005: MacViews: Fix duplicate definition of ValidationMessageBubble::ShowAndCreate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FirstResponder
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/validation_message_bubble_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
+}
« no previous file with comments | « chrome/browser/ui/views/validation_message_bubble_view.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698