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 #ifndef CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ | 5 #ifndef CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ |
6 #define CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ | 6 #define CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 class RenderWidgetHost; | 13 class RenderWidgetHost; |
14 } | 14 } |
15 | 15 |
16 namespace gfx { | 16 namespace gfx { |
17 class Rect; | 17 class Rect; |
18 } | 18 } |
19 | 19 |
20 class ValidationMessageBubble { | 20 class ValidationMessageBubble { |
21 public: | 21 public: |
22 // Open a tooltip-like window to show the specified messages. The window | 22 // Open a tooltip-like window to show the specified messages. The window |
23 // should not change focus state. | 23 // should not change focus state. |
24 static std::unique_ptr<ValidationMessageBubble> CreateAndShow( | 24 static base::WeakPtr<ValidationMessageBubble> CreateAndShow( |
25 content::RenderWidgetHost* widget_host, | 25 content::RenderWidgetHost* widget_host, |
26 const gfx::Rect& anchor_in_root_view, | 26 const gfx::Rect& anchor_in_root_view, |
27 const base::string16& main_text, | 27 const base::string16& main_text, |
28 const base::string16& sub_text); | 28 const base::string16& sub_text); |
29 | 29 |
30 // Close the window and destruct the object. | |
31 virtual ~ValidationMessageBubble() {} | |
32 | |
33 // Move the window to a position such that the bubble arrow points to the | 30 // Move the window to a position such that the bubble arrow points to the |
34 // specified anchor. |anchor_in_root_view| is in DIP unit, and relative to | 31 // specified anchor. |anchor_in_root_view| is in DIP unit, and relative to |
35 // RWHV for |widget_host|. | 32 // RWHV for |widget_host|. |
36 virtual void SetPositionRelativeToAnchor( | 33 virtual void SetPositionRelativeToAnchor( |
37 content::RenderWidgetHost* widget_host, | 34 content::RenderWidgetHost* widget_host, |
38 const gfx::Rect& anchor_in_root_view) = 0; | 35 const gfx::Rect& anchor_in_root_view) = 0; |
| 36 |
| 37 // Called to close the bubble. This should lead to destruction of |this|. |
| 38 virtual void CloseValidationMessage() = 0; |
| 39 |
| 40 protected: |
| 41 virtual ~ValidationMessageBubble() {} |
39 }; | 42 }; |
40 | 43 |
41 #endif // CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ | 44 #endif // CHROME_BROWSER_UI_VALIDATION_MESSAGE_BUBBLE_H_ |
OLD | NEW |