OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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_GTK_EXTENSION_POPUP_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_ |
6 #define CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_ | 6 #define CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_ |
7 | 7 |
8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/task.h" |
9 #include "chrome/browser/gtk/info_bubble_gtk.h" | 10 #include "chrome/browser/gtk/info_bubble_gtk.h" |
10 #include "chrome/common/notification_observer.h" | 11 #include "chrome/common/notification_observer.h" |
11 #include "chrome/common/notification_registrar.h" | 12 #include "chrome/common/notification_registrar.h" |
12 #include "gfx/rect.h" | 13 #include "gfx/rect.h" |
13 | 14 |
14 class Browser; | 15 class Browser; |
15 class ExtensionHost; | 16 class ExtensionHost; |
16 class GURL; | 17 class GURL; |
17 | 18 |
18 class ExtensionPopupGtk : public NotificationObserver, | 19 class ExtensionPopupGtk : public NotificationObserver, |
19 public InfoBubbleGtkDelegate { | 20 public InfoBubbleGtkDelegate { |
20 public: | 21 public: |
21 ExtensionPopupGtk(Browser* browser, | 22 ExtensionPopupGtk(Browser* browser, |
22 ExtensionHost* host, | 23 ExtensionHost* host, |
23 const gfx::Rect& relative_to); | 24 const gfx::Rect& relative_to, |
| 25 bool inspect); |
24 virtual ~ExtensionPopupGtk(); | 26 virtual ~ExtensionPopupGtk(); |
25 | 27 |
26 static void Show(const GURL& url, | 28 static void Show(const GURL& url, |
27 Browser* browser, | 29 Browser* browser, |
28 const gfx::Rect& relative_to); | 30 const gfx::Rect& relative_to, |
| 31 bool inspect); |
29 | 32 |
30 // NotificationObserver implementation. | 33 // NotificationObserver implementation. |
31 virtual void Observe(NotificationType type, | 34 virtual void Observe(NotificationType type, |
32 const NotificationSource& source, | 35 const NotificationSource& source, |
33 const NotificationDetails& details); | 36 const NotificationDetails& details); |
34 | 37 |
35 // InfoBubbleGtkDelegate implementation. | 38 // InfoBubbleGtkDelegate implementation. |
36 virtual void InfoBubbleClosing(InfoBubbleGtk* bubble, | 39 virtual void InfoBubbleClosing(InfoBubbleGtk* bubble, |
37 bool closed_by_escape); | 40 bool closed_by_escape); |
38 | 41 |
39 // Destroys the popup widget. This will in turn destroy us since we delete | 42 // Destroys the popup widget. This will in turn destroy us since we delete |
40 // ourselves when the info bubble closes. Returns true if we successfully | 43 // ourselves when the info bubble closes. Returns true if we successfully |
41 // closed the bubble. | 44 // closed the bubble. |
42 bool DestroyPopup(); | 45 bool DestroyPopup(); |
43 | 46 |
44 // Get the currently showing extension popup, or NULL. | 47 // Get the currently showing extension popup, or NULL. |
45 static ExtensionPopupGtk* get_current_extension_popup() { | 48 static ExtensionPopupGtk* get_current_extension_popup() { |
46 return current_extension_popup_; | 49 return current_extension_popup_; |
47 } | 50 } |
48 | 51 |
| 52 bool being_inspected() const { |
| 53 return being_inspected_; |
| 54 } |
| 55 |
49 private: | 56 private: |
50 // Shows the popup widget. Called after loading completes. | 57 // Shows the popup widget. Called after loading completes. |
51 void ShowPopup(); | 58 void ShowPopup(); |
52 | 59 |
53 Browser* browser_; | 60 Browser* browser_; |
54 | 61 |
55 InfoBubbleGtk* bubble_; | 62 InfoBubbleGtk* bubble_; |
56 | 63 |
57 // We take ownership of the popup ExtensionHost. | 64 // We take ownership of the popup ExtensionHost. |
58 scoped_ptr<ExtensionHost> host_; | 65 scoped_ptr<ExtensionHost> host_; |
59 | 66 |
60 // The rect that we use to position the popup. It is the bounds of the | 67 // The rect that we use to position the popup. It is the bounds of the |
61 // browser action button. | 68 // browser action button. |
62 gfx::Rect relative_to_; | 69 gfx::Rect relative_to_; |
63 | 70 |
64 NotificationRegistrar registrar_; | 71 NotificationRegistrar registrar_; |
65 | 72 |
66 static ExtensionPopupGtk* current_extension_popup_; | 73 static ExtensionPopupGtk* current_extension_popup_; |
67 | 74 |
| 75 // Whether a devtools window is attached to this bubble. |
| 76 bool being_inspected_; |
| 77 |
| 78 ScopedRunnableMethodFactory<ExtensionPopupGtk> method_factory_; |
| 79 |
68 // Used for testing. --------------------------------------------------------- | 80 // Used for testing. --------------------------------------------------------- |
69 gfx::Rect GetViewBounds(); | 81 gfx::Rect GetViewBounds(); |
70 | 82 |
71 friend class BrowserActionTestUtil; | 83 friend class BrowserActionTestUtil; |
72 | 84 |
73 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupGtk); | 85 DISALLOW_COPY_AND_ASSIGN(ExtensionPopupGtk); |
74 }; | 86 }; |
75 | 87 |
76 #endif // CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_ | 88 #endif // CHROME_BROWSER_GTK_EXTENSION_POPUP_GTK_H_ |
OLD | NEW |