Chromium Code Reviews| 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..51dbe6187e4db7f75fce6d8358280b90595f62ca 100644 |
| --- a/chrome/browser/ui/views/validation_message_bubble_view.cc |
| +++ b/chrome/browser/ui/views/validation_message_bubble_view.cc |
| @@ -4,15 +4,52 @@ |
| #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: |
| + ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen, |
| + const string16& main_text, |
| + const string16& sub_text); |
| + |
| + virtual ~ValidationMessageBubbleImpl() { |
| + delegate_->GetWidget()->Hide(); |
|
sky
2013/05/01 14:05:05
How do you know delegate_ is valid here?
tkent
2013/05/01 21:42:30
I thought it's always valid. It might be a wrong
|
| + } |
| + |
| + private: |
| + ValidationMessageBubbleDelegate* delegate_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl); |
| +}; |
| + |
| +ValidationMessageBubbleImpl::ValidationMessageBubbleImpl( |
| + const gfx::Rect& anchor_in_screen, |
| + const string16& main_text, |
| + const string16& sub_text) { |
| + // The delegate_ will kill itself in ValidationMessageBubbleDelegate:: |
|
sky
2013/05/01 14:05:05
nit: wrap ValidationMessageBubbleDelegate::DeleteD
tkent
2013/05/01 21:42:30
Done.
|
| + // DeleteDelegate. |
| + delegate_ = new ValidationMessageBubbleDelegate( |
| + anchor_in_screen, main_text, sub_text); |
| + 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 |