| 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_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 5 #ifndef CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| 6 #define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 6 #define CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| 7 | 7 |
| 8 #include "googleurl/src/gurl.h" | 8 #include "googleurl/src/gurl.h" |
| 9 #include "chrome/browser/extensions/extension_host.h" | 9 #include "chrome/browser/extensions/extension_host.h" |
| 10 #include "chrome/browser/views/browser_bubble.h" | 10 #include "chrome/browser/views/browser_bubble.h" |
| 11 #include "chrome/browser/views/bubble_border.h" |
| 11 #include "chrome/common/notification_observer.h" | 12 #include "chrome/common/notification_observer.h" |
| 12 #include "chrome/common/notification_registrar.h" | 13 #include "chrome/common/notification_registrar.h" |
| 13 | 14 |
| 14 class Browser; | 15 class Browser; |
| 15 class ExtensionHost; | 16 class ExtensionHost; |
| 16 | 17 |
| 17 class ExtensionPopup : public BrowserBubble, | 18 class ExtensionPopup : public BrowserBubble, |
| 18 public NotificationObserver { | 19 public NotificationObserver { |
| 19 public: | 20 public: |
| 20 virtual ~ExtensionPopup(); | 21 virtual ~ExtensionPopup(); |
| 21 | 22 |
| 22 // Create and show a popup with |url| positioned below |relative_to| in | 23 // Create and show a popup with |url| positioned below |relative_to| in |
| 23 // |browser| coordinates. This is anchored to the lower right corner of the | 24 // screen coordinates. This is anchored to the lower middle of the rect, |
| 24 // rect, extending to the left, just like the wrench and page menus. | 25 // extending to the left, just like the wrench and page menus. |
| 25 // | 26 // |
| 26 // The actual display of the popup is delayed until the page contents | 27 // The actual display of the popup is delayed until the page contents |
| 27 // finish loading in order to minimize UI flashing and resizing. | 28 // finish loading in order to minimize UI flashing and resizing. |
| 28 static ExtensionPopup* Show(const GURL& url, Browser* browser, | 29 static ExtensionPopup* Show(const GURL& url, Browser* browser, |
| 29 const gfx::Rect& relative_to, | 30 const gfx::Rect& relative_to, |
| 30 int height); | 31 int height); |
| 31 | 32 |
| 32 ExtensionHost* host() const { return extension_host_.get(); } | 33 ExtensionHost* host() const { return extension_host_.get(); } |
| 33 | 34 |
| 34 // BrowserBubble overrides. | 35 // BrowserBubble overrides. |
| 35 virtual void Show(); | 36 virtual void Show(); |
| 37 virtual void Hide(); |
| 36 | 38 |
| 37 // NotificationObserver overrides. | 39 // NotificationObserver overrides. |
| 38 virtual void Observe(NotificationType type, | 40 virtual void Observe(NotificationType type, |
| 39 const NotificationSource& source, | 41 const NotificationSource& source, |
| 40 const NotificationDetails& details); | 42 const NotificationDetails& details); |
| 41 | 43 |
| 42 private: | 44 private: |
| 43 ExtensionPopup(ExtensionHost* host, | 45 ExtensionPopup(ExtensionHost* host, |
| 44 views::Widget* frame, | 46 views::Widget* frame, |
| 45 const gfx::Rect& relative_to); | 47 const gfx::Rect& relative_to); |
| 46 | 48 |
| 47 // The area on the screen that the popup should be positioned relative to. | 49 // The area on the screen that the popup should be positioned relative to. |
| 48 const gfx::Rect relative_to_; | 50 gfx::Rect relative_to_; |
| 49 | 51 |
| 50 // The contained host for the view. | 52 // The contained host for the view. |
| 51 scoped_ptr<ExtensionHost> extension_host_; | 53 scoped_ptr<ExtensionHost> extension_host_; |
| 52 | 54 |
| 53 NotificationRegistrar registrar_; | 55 NotificationRegistrar registrar_; |
| 54 | 56 |
| 57 // A separate widget and associated pieces to draw a border behind the |
| 58 // popup. This has to be a separate window in order to support transparency. |
| 59 // Layered windows can't contain native child windows, so we wouldn't be |
| 60 // able to have the ExtensionView child. |
| 61 scoped_ptr<views::Widget> border_widget_; |
| 62 BubbleBorder* border_; |
| 63 views::View* border_view_; |
| 64 |
| 55 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 65 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
| 56 }; | 66 }; |
| 57 | 67 |
| 58 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_POPUP_H_ | 68 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_POPUP_H_ |
| OLD | NEW |