Chromium Code Reviews| 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 : public chrome::ValidationMessageBubble { | |
| 14 public: | |
| 15 ValidationMessageBubbleImpl(const gfx::Rect& anchor_in_screen, | |
| 16 const string16& main_text, | |
| 17 const string16& sub_text); | |
| 18 | |
| 19 virtual ~ValidationMessageBubbleImpl() { | |
| 20 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
| |
| 21 } | |
| 22 | |
| 23 private: | |
| 24 ValidationMessageBubbleDelegate* delegate_; | |
| 25 | |
| 26 DISALLOW_COPY_AND_ASSIGN(ValidationMessageBubbleImpl); | |
| 27 }; | |
| 28 | |
| 29 ValidationMessageBubbleImpl::ValidationMessageBubbleImpl( | |
| 30 const gfx::Rect& anchor_in_screen, | |
| 31 const string16& main_text, | |
| 32 const string16& sub_text) { | |
| 33 // 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.
| |
| 34 // DeleteDelegate. | |
| 35 delegate_ = new ValidationMessageBubbleDelegate( | |
| 36 anchor_in_screen, main_text, sub_text); | |
| 37 views::BubbleDelegateView::CreateBubble(delegate_); | |
| 38 delegate_->GetWidget()->Show(); | |
| 39 } | |
| 40 | |
| 41 } // namespace | |
| 42 | |
| 7 namespace chrome { | 43 namespace chrome { |
| 8 | 44 |
| 9 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( | 45 scoped_ptr<ValidationMessageBubble> ValidationMessageBubble::CreateAndShow( |
| 10 content::RenderWidgetHost* widget_host, | 46 content::RenderWidgetHost*, |
| 11 const gfx::Rect& anchor_in_screen, | 47 const gfx::Rect& anchor_in_screen, |
| 12 const string16& main_text, | 48 const string16& main_text, |
| 13 const string16& sub_text) { | 49 const string16& sub_text) { |
| 14 // TODO(tkent): Implement this and enable it. crbug.com/235719. | 50 scoped_ptr<ValidationMessageBubble> bubble( |
| 15 return scoped_ptr<ValidationMessageBubble>().Pass(); | 51 new ValidationMessageBubbleImpl(anchor_in_screen, main_text, sub_text)); |
| 52 return bubble.Pass(); | |
| 16 } | 53 } |
| 17 | 54 |
| 18 } | 55 } // namespace chrome |
| OLD | NEW |