diff options
author | mad@google.com <mad@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 20:41:54 +0000 |
---|---|---|
committer | mad@google.com <mad@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-09 20:41:54 +0000 |
commit | c4556418578b2c31744e82f78d3b12901bb48176 (patch) | |
tree | 5c44bdc1e3d5bbd6ccef9f772e8b043a80a4af05 /ceee/ie/plugin/bho/infobar_browser_window.h | |
parent | aa613d6a7ac972a04dd8cdacf2f859f94a8323f1 (diff) | |
download | chromium_src-c4556418578b2c31744e82f78d3b12901bb48176.zip chromium_src-c4556418578b2c31744e82f78d3b12901bb48176.tar.gz chromium_src-c4556418578b2c31744e82f78d3b12901bb48176.tar.bz2 |
Commit for vadimb to improved the way InfobarBrowserWindow is instantiated.
Taken from:
http://codereview.chromium.org/4648004/show
Improved the way InfobarBrowserWindow is instantiated.
2. Fixed AddRef/Release correspondence.
3. Fixed an assertion if infobar is closed before it was opened.
4. Renamed InfobarBrowserWindow::Delegate::OnWindowClose to OnBrowserWindowClose to reduce confusion with InfobarWindow::Delegate::OnWindowClose.
5. Created unit tests for infobar_api_module.
BUG=none
TEST=none
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@65567 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ceee/ie/plugin/bho/infobar_browser_window.h')
-rw-r--r-- | ceee/ie/plugin/bho/infobar_browser_window.h | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/ceee/ie/plugin/bho/infobar_browser_window.h b/ceee/ie/plugin/bho/infobar_browser_window.h index fd6c975..7e6dbcb 100644 --- a/ceee/ie/plugin/bho/infobar_browser_window.h +++ b/ceee/ie/plugin/bho/infobar_browser_window.h @@ -30,16 +30,32 @@ class InfobarBrowserWindow; typedef IDispEventSimpleImpl<0, InfobarBrowserWindow, &DIID_DIChromeFrameEvents> ChromeFrameEvents; +class __declspec(uuid("1AE72DA8-1E4E-4101-8D5D-D7859A366D60")) +IInfobarBrowserWindow : public IUnknown { + public: + // Creates and shows window. + STDMETHOD(CreateAndShowWindow)(HWND parent) = 0; + // Navigates the browser to the given URL if the browser has already been + // created, otherwise stores the URL to navigate later on. + STDMETHOD(SetUrl)(BSTR url) = 0; + // Sets the window size for the browser window. + STDMETHOD(SetWindowSize)(int width, int height) = 0; + // Tear the window down. + STDMETHOD(Teardown)() = 0; +}; + // The window that hosts CF where infobar URL is loaded. It implements a limited // site functionality needed for CF as well as handles sink events from CF. // TODO(vadimb@google.com): Refactor this class, ChromeFrameHost and ToolBand // to have a common functionality supported in a common base class. class ATL_NO_VTABLE InfobarBrowserWindow : public CComObjectRootEx<CComSingleThreadModel>, + public InitializingCoClass<InfobarBrowserWindow>, public IObjectWithSiteImpl<InfobarBrowserWindow>, public IServiceProviderImpl<InfobarBrowserWindow>, public IChromeFramePrivileged, public ChromeFrameEvents, + public IInfobarBrowserWindow, public CWindowImpl<InfobarBrowserWindow> { public: // Class to connect this an instance of InfobarBrowserWindow with a hosting @@ -49,7 +65,7 @@ class ATL_NO_VTABLE InfobarBrowserWindow public: virtual ~Delegate() {} // Informs about window.close() event. - virtual void OnWindowClose() = 0; + virtual void OnBrowserWindowClose() = 0; }; InfobarBrowserWindow(); @@ -58,6 +74,7 @@ class ATL_NO_VTABLE InfobarBrowserWindow BEGIN_COM_MAP(InfobarBrowserWindow) COM_INTERFACE_ENTRY(IServiceProvider) COM_INTERFACE_ENTRY(IChromeFramePrivileged) + COM_INTERFACE_ENTRY(IInfobarBrowserWindow) END_COM_MAP() BEGIN_SERVICE_MAP(InfobarBrowserWindow) @@ -97,17 +114,16 @@ class ATL_NO_VTABLE InfobarBrowserWindow STDMETHOD_(void, OnCfClose)(); // @} - // Initializes the browser window to the given site. - HRESULT Initialize(HWND parent); - // Tears down an initialized browser window. - HRESULT Teardown(); - - // Navigates the browser to the given URL if the browser has already been - // created, otherwise stores the URL to navigate later on. - void SetUrl(const std::wstring& url); + // @name IInfobarBrowserWindow implementation. + // @{ + STDMETHOD(CreateAndShowWindow)(HWND parent); + STDMETHOD(SetUrl)(BSTR url); + STDMETHOD(SetWindowSize)(int width, int height); + STDMETHOD(Teardown)(); + // @} - // Set the delegate to be informed about window.close() events. - void set_delegate(Delegate* delegate) { delegate_ = delegate; } + // Initializes the browser window to the given site. + HRESULT Initialize(BSTR url, Delegate* delegate); // Unit test seam. virtual InfobarEventsFunnel& infobar_events_funnel() { @@ -121,6 +137,8 @@ class ATL_NO_VTABLE InfobarBrowserWindow void OnDestroy(); // @} + virtual void OnFinalMessage(HWND window); + private: // The funnel for sending infobar events to the broker. InfobarEventsFunnel infobar_events_funnel_; @@ -145,6 +163,9 @@ class ATL_NO_VTABLE InfobarBrowserWindow // Subroutine of general initialization. Extracted to make testable. virtual HRESULT InitializeAndShowWindow(HWND parent); + // Set the delegate to be informed about window.close() events. + void set_delegate(Delegate* delegate) { delegate_ = delegate; } + // Navigate the browser to url_ if the browser has been created. void Navigate(); |