| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 #ifndef CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ | 4 #ifndef CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ |
| 5 #define CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ | 5 #define CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ |
| 6 | 6 |
| 7 #include <atlbase.h> | 7 #include <atlbase.h> |
| 8 #include <atlcom.h> | 8 #include <atlcom.h> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <exdisp.h> | 10 #include <exdisp.h> |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 ALLOW_THIS_IN_INITIALIZER_LIST( | 121 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 122 onloaderror_(this, &WebBrowserEventSink::OnLoadErrorInternal)), | 122 onloaderror_(this, &WebBrowserEventSink::OnLoadErrorInternal)), |
| 123 ALLOW_THIS_IN_INITIALIZER_LIST( | 123 ALLOW_THIS_IN_INITIALIZER_LIST( |
| 124 onload_(this, &WebBrowserEventSink::OnLoadInternal)) { | 124 onload_(this, &WebBrowserEventSink::OnLoadInternal)) { |
| 125 } | 125 } |
| 126 | 126 |
| 127 ~WebBrowserEventSink() { | 127 ~WebBrowserEventSink() { |
| 128 Uninitialize(); | 128 Uninitialize(); |
| 129 } | 129 } |
| 130 | 130 |
| 131 void Uninitialize() { | 131 void Uninitialize(); |
| 132 chrome_frame_ = NULL; | |
| 133 if (web_browser2_.get()) { | |
| 134 DispEventUnadvise(web_browser2_); | |
| 135 web_browser2_->Quit(); | |
| 136 web_browser2_.Release(); | |
| 137 // Give IE some time to quit and release our references | |
| 138 Sleep(1000); | |
| 139 } | |
| 140 } | |
| 141 | 132 |
| 142 // Helper function to launch IE and navigate to a URL. | 133 // Helper function to launch IE and navigate to a URL. |
| 143 // Returns S_OK on success, S_FALSE if the test was not run, other | 134 // Returns S_OK on success, S_FALSE if the test was not run, other |
| 144 // errors on failure. | 135 // errors on failure. |
| 145 HRESULT LaunchIEAndNavigate(const std::wstring& navigate_url); | 136 HRESULT LaunchIEAndNavigate(const std::wstring& navigate_url); |
| 146 | 137 |
| 147 HRESULT Navigate(const std::wstring& navigate_url); | 138 HRESULT Navigate(const std::wstring& navigate_url); |
| 148 | 139 |
| 140 // Set input focus to chrome frame window. |
| 141 void SetFocusToChrome(); |
| 142 |
| 143 // Send keyboard input to the renderer window hosted in chrome using |
| 144 // SendInput API |
| 145 void SendInputToChrome(const std::string& input_string); |
| 146 |
| 149 BEGIN_COM_MAP(WebBrowserEventSink) | 147 BEGIN_COM_MAP(WebBrowserEventSink) |
| 150 END_COM_MAP() | 148 END_COM_MAP() |
| 151 | 149 |
| 152 BEGIN_SINK_MAP(WebBrowserEventSink) | 150 BEGIN_SINK_MAP(WebBrowserEventSink) |
| 153 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, | 151 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, |
| 154 OnBeforeNavigate2Internal, &kBeforeNavigate2Info) | 152 OnBeforeNavigate2Internal, &kBeforeNavigate2Info) |
| 155 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, | 153 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_DOWNLOADBEGIN, |
| 156 OnDownloadBegin, &kVoidMethodInfo) | 154 OnDownloadBegin, &kVoidMethodInfo) |
| 157 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, | 155 SINK_ENTRY_INFO(0, DIID_DWebBrowserEvents2, DISPID_NAVIGATECOMPLETE2, |
| 158 OnNavigateComplete2Internal, &kNavigateComplete2Info) | 156 OnNavigateComplete2Internal, &kNavigateComplete2Info) |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 IWebBrowser2* web_browser2() { | 203 IWebBrowser2* web_browser2() { |
| 206 return web_browser2_.get(); | 204 return web_browser2_.get(); |
| 207 } | 205 } |
| 208 | 206 |
| 209 protected: | 207 protected: |
| 210 // IChromeFrame callbacks | 208 // IChromeFrame callbacks |
| 211 HRESULT OnLoadInternal(const VARIANT* param); | 209 HRESULT OnLoadInternal(const VARIANT* param); |
| 212 HRESULT OnLoadErrorInternal(const VARIANT* param); | 210 HRESULT OnLoadErrorInternal(const VARIANT* param); |
| 213 HRESULT OnMessageInternal(const VARIANT* param); | 211 HRESULT OnMessageInternal(const VARIANT* param); |
| 214 | 212 |
| 215 void ConnectToChromeFrame(); | 213 void ConnectToChromeFrame(); |
| 214 HWND GetChromeRendererWindow(); |
| 216 | 215 |
| 217 public: | 216 public: |
| 218 ScopedComPtr<IWebBrowser2> web_browser2_; | 217 ScopedComPtr<IWebBrowser2> web_browser2_; |
| 219 ScopedComPtr<IChromeFrame> chrome_frame_; | 218 ScopedComPtr<IChromeFrame> chrome_frame_; |
| 220 DispCallback<WebBrowserEventSink> onmessage_; | 219 DispCallback<WebBrowserEventSink> onmessage_; |
| 221 DispCallback<WebBrowserEventSink> onloaderror_; | 220 DispCallback<WebBrowserEventSink> onloaderror_; |
| 222 DispCallback<WebBrowserEventSink> onload_; | 221 DispCallback<WebBrowserEventSink> onload_; |
| 223 | 222 |
| 224 protected: | 223 protected: |
| 225 static _ATL_FUNC_INFO kBeforeNavigate2Info; | 224 static _ATL_FUNC_INFO kBeforeNavigate2Info; |
| 226 static _ATL_FUNC_INFO kNavigateComplete2Info; | 225 static _ATL_FUNC_INFO kNavigateComplete2Info; |
| 227 static _ATL_FUNC_INFO kNavigateErrorInfo; | 226 static _ATL_FUNC_INFO kNavigateErrorInfo; |
| 228 static _ATL_FUNC_INFO kNewWindow3Info; | 227 static _ATL_FUNC_INFO kNewWindow3Info; |
| 229 static _ATL_FUNC_INFO kVoidMethodInfo; | 228 static _ATL_FUNC_INFO kVoidMethodInfo; |
| 230 }; | 229 }; |
| 231 | 230 |
| 232 #endif // CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ | 231 #endif // CHROME_FRAME_TEST_CHROME_FRAME_UNITTESTS_H_ |
| 233 | 232 |
| OLD | NEW |