| 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 "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/browser/views/browser_bubble.h" | 9 #include "chrome/browser/views/browser_bubble.h" |
| 10 #include "chrome/browser/views/extensions/extension_view.h" | 10 #include "chrome/browser/views/extensions/extension_view.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 // is ref-counted, and thus will be released shortly after | 36 // is ref-counted, and thus will be released shortly after |
| 37 // making this delegate call. | 37 // making this delegate call. |
| 38 virtual void ExtensionPopupClosed(ExtensionPopup* popup) {} | 38 virtual void ExtensionPopupClosed(ExtensionPopup* popup) {} |
| 39 | 39 |
| 40 // Called when the ExtensionHost is first created for the pop-up view. | 40 // Called when the ExtensionHost is first created for the pop-up view. |
| 41 // Note that this is invoked BEFORE the ExtensionPopup is created, and can | 41 // Note that this is invoked BEFORE the ExtensionPopup is created, and can |
| 42 // be used to provide extra configuration of the host before it is pushed | 42 // be used to provide extra configuration of the host before it is pushed |
| 43 // into the popup. An example use is for automation resource routing in | 43 // into the popup. An example use is for automation resource routing in |
| 44 // Chrome-Frame. See extension_popup_api.cc. | 44 // Chrome-Frame. See extension_popup_api.cc. |
| 45 virtual void ExtensionHostCreated(ExtensionHost* host) {} | 45 virtual void ExtensionHostCreated(ExtensionHost* host) {} |
| 46 |
| 47 // Called when the ExtensionPopup is resized. Note that the popup may have |
| 48 // an empty bounds, if a popup is repositioned before the hosted content |
| 49 // has loaded. |
| 50 virtual void ExtensionPopupResized(ExtensionPopup* popup) {} |
| 46 }; | 51 }; |
| 47 | 52 |
| 48 enum PopupChrome { | 53 enum PopupChrome { |
| 49 BUBBLE_CHROME, | 54 BUBBLE_CHROME, |
| 50 RECTANGLE_CHROME | 55 RECTANGLE_CHROME |
| 51 }; | 56 }; |
| 52 | 57 |
| 53 virtual ~ExtensionPopup(); | 58 virtual ~ExtensionPopup(); |
| 54 | 59 |
| 55 // Create and show a popup with |url| positioned adjacent to |relative_to| in | 60 // Create and show a popup with |url| positioned adjacent to |relative_to| in |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 | 98 |
| 94 // Some clients wish to do their own custom focus change management. If this | 99 // Some clients wish to do their own custom focus change management. If this |
| 95 // is set to false, then the ExtensionPopup will not do anything in response | 100 // is set to false, then the ExtensionPopup will not do anything in response |
| 96 // to the BubbleLostFocus() calls it gets from the BrowserBubble. | 101 // to the BubbleLostFocus() calls it gets from the BrowserBubble. |
| 97 void set_close_on_lost_focus(bool close_on_lost_focus) { | 102 void set_close_on_lost_focus(bool close_on_lost_focus) { |
| 98 close_on_lost_focus_ = close_on_lost_focus; | 103 close_on_lost_focus_ = close_on_lost_focus; |
| 99 } | 104 } |
| 100 | 105 |
| 101 ExtensionHost* host() const { return extension_host_.get(); } | 106 ExtensionHost* host() const { return extension_host_.get(); } |
| 102 | 107 |
| 108 // Assigns the arrow location of the popup view, and updates the popup |
| 109 // border widget, if necessary. |
| 110 void SetArrowPosition(BubbleBorder::ArrowLocation arrow_location); |
| 111 BubbleBorder::ArrowLocation arrow_position() const { |
| 112 return anchor_position_; |
| 113 } |
| 114 |
| 115 // Gives the desired bounds (in screen coordinates) given the rect to point |
| 116 // to and the size of the contained contents. Includes all of the |
| 117 // border-chrome surrounding the pop-up as well. |
| 118 gfx::Rect GetOuterBounds() const; |
| 119 |
| 103 // BrowserBubble overrides. | 120 // BrowserBubble overrides. |
| 104 virtual void Hide(); | 121 virtual void Hide(); |
| 105 virtual void Show(bool activate); | 122 virtual void Show(bool activate); |
| 106 virtual void ResizeToView(); | 123 virtual void ResizeToView(); |
| 107 | 124 |
| 108 // BrowserBubble::Delegate methods. | 125 // BrowserBubble::Delegate methods. |
| 109 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); | 126 virtual void BubbleBrowserWindowMoved(BrowserBubble* bubble); |
| 110 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); | 127 virtual void BubbleBrowserWindowClosing(BrowserBubble* bubble); |
| 111 virtual void BubbleGotFocus(BrowserBubble* bubble); | 128 virtual void BubbleGotFocus(BrowserBubble* bubble); |
| 112 virtual void BubbleLostFocus(BrowserBubble* bubble, | 129 virtual void BubbleLostFocus(BrowserBubble* bubble, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 131 private: | 148 private: |
| 132 ExtensionPopup(ExtensionHost* host, | 149 ExtensionPopup(ExtensionHost* host, |
| 133 views::Widget* frame, | 150 views::Widget* frame, |
| 134 const gfx::Rect& relative_to, | 151 const gfx::Rect& relative_to, |
| 135 BubbleBorder::ArrowLocation arrow_location, | 152 BubbleBorder::ArrowLocation arrow_location, |
| 136 bool activate_on_show, | 153 bool activate_on_show, |
| 137 bool inspect_with_devtools, | 154 bool inspect_with_devtools, |
| 138 PopupChrome chrome, | 155 PopupChrome chrome, |
| 139 Observer* observer); | 156 Observer* observer); |
| 140 | 157 |
| 141 // Gives the desired bounds (in screen coordinates) given the rect to point | |
| 142 // to and the size of the contained contents. Includes all of the | |
| 143 // border-chrome surrounding the pop-up as well. | |
| 144 gfx::Rect GetOuterBounds(const gfx::Rect& position_relative_to, | |
| 145 const gfx::Size& contents_size) const; | |
| 146 | |
| 147 // The area on the screen that the popup should be positioned relative to. | 158 // The area on the screen that the popup should be positioned relative to. |
| 148 gfx::Rect relative_to_; | 159 gfx::Rect relative_to_; |
| 149 | 160 |
| 150 // The contained host for the view. | 161 // The contained host for the view. |
| 151 scoped_ptr<ExtensionHost> extension_host_; | 162 scoped_ptr<ExtensionHost> extension_host_; |
| 152 | 163 |
| 153 // Flag used to indicate if the pop-up should be activated upon first display. | 164 // Flag used to indicate if the pop-up should be activated upon first display. |
| 154 bool activate_on_show_; | 165 bool activate_on_show_; |
| 155 | 166 |
| 156 // Flag used to indicate if the pop-up should open a devtools window once | 167 // Flag used to indicate if the pop-up should open a devtools window once |
| (...skipping 24 matching lines...) Expand all Loading... |
| 181 | 192 |
| 182 // A cached copy of the arrow-position for the bubble chrome. | 193 // A cached copy of the arrow-position for the bubble chrome. |
| 183 // If a black-border was requested, we still need this value to determine | 194 // If a black-border was requested, we still need this value to determine |
| 184 // the position of the pop-up in relation to |relative_to_|. | 195 // the position of the pop-up in relation to |relative_to_|. |
| 185 BubbleBorder::ArrowLocation anchor_position_; | 196 BubbleBorder::ArrowLocation anchor_position_; |
| 186 | 197 |
| 187 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); | 198 DISALLOW_COPY_AND_ASSIGN(ExtensionPopup); |
| 188 }; | 199 }; |
| 189 | 200 |
| 190 #endif // CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ | 201 #endif // CHROME_BROWSER_VIEWS_EXTENSIONS_EXTENSION_POPUP_H_ |
| OLD | NEW |