| 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/validation_message_bubble.h" | 5 #include "chrome/browser/ui/validation_message_bubble.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/views/validation_message_bubble_delegate.h" |
| 8 #include "ui/views/widget/widget.h" |
| 9 |
| 10 namespace { |
| 11 |
| 12 // A ValidationMessageBubble implementation for Views. |
| 13 class ValidationMessageBubbleImpl |
| 14 : public chrome::ValidationMessageBubble, |
| 15 public ValidationMessageBubbleDelegate::Observer { |
| 16 public: |
| 17 ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen, |
| 18 const string16& main_text, |
| 19 const string16& sub_text); |
| 20 |
| 21 virtual ~ValidationMessageBubbleImpl() { |
| 22 if (delegate_ != NULL) |
| 23 delegate_->Hide(); |
| 24 } |
| 25 |
| 26 // ValidationMessageBubbleDelegate::Observer override: |
| 27 virtual void WindowClosing() OVERRIDE { |
| 28 delegate_ = NULL; |
| 29 } |
| 30 |
| 31 private: |
| 32 ValidationMessageBubbleDelegate* delegate_; |
| 33 |
| 34 DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl); |
| 35 }; |
| 36 |
| 37 ValidationMessageBubbleImpl::ValidationMessageBubbleImpl( |
| 38 const gfx::Rect& anchor_in_screen, |
| 39 const string16& main_text, |
| 40 const string16& sub_text) { |
| 41 delegate_ = new ValidationMessageBubbleDelegate( |
| 42 anchor_in_screen, main_text, sub_text, this); |
| 43 views::BubbleDelegateView::CreateBubble(delegate_); |
| 44 delegate_->GetWidget()->Show(); |
| 45 } |
| 46 |
| 47 } // namespace |
| 48 |
| 7 namespace chrome { | 49 namespace chrome { |
| 8 | 50 |
| 9 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( | 51 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( |
| 10 content::RenderWidgetHost* widget_host, | 52 content::RenderWidgetHost*, |
| 11 const gfx::Rect& anchor_in_screen, | 53 const gfx::Rect& anchor_in_screen, |
| 12 const string16& main_text, | 54 const string16& main_text, |
| 13 const string16& sub_text) { | 55 const string16& sub_text) { |
| 14 // TODO(tkent): Implement this and enable it. crbug.com/235719. | 56 scoped_ptr<ValidationMessageBubble> bubble( |
| 15 return scoped_ptr<ValidationMessageBubble>().Pass(); | 57 new ValidationMessageBubbleImpl(anchor_in_screen, main_text, sub_text)); |
| 58 return bubble.Pass(); |
| 16 } | 59 } |
| 17 | 60 |
| 18 } | 61 } // namespace chrome |
| OLD | NEW |