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

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

Issue 14627004: Re-implement form validation message UI with native widgets (Views) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 8 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
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 076cba008f02e996523b872a0b40cf973bffc46c..f4685d8d99bc8884afa99573485c62bf7cda0ed4 100644
--- a/chrome/browser/ui/views/validation_message_bubble_view.cc
+++ b/chrome/browser/ui/views/validation_message_bubble_view.cc
@@ -4,15 +4,58 @@
#include "chrome/browser/ui/validation_message_bubble.h"
+#include "chrome/browser/ui/views/validation_message_bubble_delegate.h"
+#include "ui/views/widget/widget.h"
+
+namespace {
+
+// A ValidationMessageBubble implementation for Views.
+class ValidationMessageBubbleImpl
+ : public chrome::ValidationMessageBubble,
+ public ValidationMessageBubbleDelegate::Observer {
+ public:
+ ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen,
+ const string16& main_text,
+ const string16& sub_text);
+
+ virtual ~ValidationMessageBubbleImpl() {
+ if (delegate_ != NULL)
+ delegate_->Hide();
+ }
+
+ // ValidationMessageBubbleDelegate::Observer override:
+ virtual void WindowClosing() OVERRIDE {
+ delegate_ = NULL;
+ }
+
+ private:
+ ValidationMessageBubbleDelegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl);
+};
+
+ValidationMessageBubbleImpl::ValidationMessageBubbleImpl(
+ const gfx::Rect& anchor_in_screen,
+ const string16& main_text,
+ const string16& sub_text) {
+ delegate_ = new ValidationMessageBubbleDelegate(
+ anchor_in_screen, main_text, sub_text, this);
+ views::BubbleDelegateView::CreateBubble(delegate_);
+ delegate_->GetWidget()->Show();
+}
+
+} // namespace
+
namespace chrome {
scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow(
- content::RenderWidgetHost* widget_host,
+ content::RenderWidgetHost*,
const gfx::Rect& anchor_in_screen,
const string16& main_text,
const string16& sub_text) {
- // TODO(tkent): Implement this and enable it. crbug.com/235719.
- return scoped_ptr<ValidationMessageBubble>().Pass();
+ scoped_ptr<ValidationMessageBubble> bubble(
+ new ValidationMessageBubbleImpl(anchor_in_screen, main_text, sub_text));
+ return bubble.Pass();
}
-}
+} // namespace chrome

Powered by Google App Engine
This is Rietveld 408576698