Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: chrome_frame/chrome_frame_activex_base.h

Issue 3061036: Handle automation server crashes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome_frame/chrome_frame_activex.cc ('k') | chrome_frame/chrome_frame_automation.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 #include <atlctl.h> 10 #include <atlctl.h>
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 public CComCoClass<T, &class_id>, 168 public CComCoClass<T, &class_id>,
169 public CComControl<T>, 169 public CComControl<T>,
170 public ChromeFramePlugin<T> { 170 public ChromeFramePlugin<T> {
171 protected: 171 protected:
172 typedef std::set<ScopedComPtr<IDispatch> > EventHandlers; 172 typedef std::set<ScopedComPtr<IDispatch> > EventHandlers;
173 typedef ChromeFrameActivexBase<T, class_id> BasePlugin; 173 typedef ChromeFrameActivexBase<T, class_id> BasePlugin;
174 174
175 public: 175 public:
176 ChromeFrameActivexBase() 176 ChromeFrameActivexBase()
177 : ready_state_(READYSTATE_UNINITIALIZED), 177 : ready_state_(READYSTATE_UNINITIALIZED),
178 failed_to_fetch_in_place_frame_(false) { 178 url_fetcher_(new UrlmonUrlRequestManager()),
179 failed_to_fetch_in_place_frame_(false),
180 draw_sad_tab_(false) {
179 m_bWindowOnly = TRUE; 181 m_bWindowOnly = TRUE;
180 url_fetcher_.set_container(static_cast<IDispatch*>(this)); 182 url_fetcher_->set_container(static_cast<IDispatch*>(this));
181 } 183 }
182 184
183 ~ChromeFrameActivexBase() { 185 ~ChromeFrameActivexBase() {
184 url_fetcher_.set_container(NULL); 186 url_fetcher_->set_container(NULL);
185 } 187 }
186 188
187 DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE | OLEMISC_CANTLINKINSIDE | 189 DECLARE_OLEMISC_STATUS(OLEMISC_RECOMPOSEONRESIZE | OLEMISC_CANTLINKINSIDE |
188 OLEMISC_INSIDEOUT | OLEMISC_ACTIVATEWHENVISIBLE | 190 OLEMISC_INSIDEOUT | OLEMISC_ACTIVATEWHENVISIBLE |
189 OLEMISC_SETCLIENTSITEFIRST) 191 OLEMISC_SETCLIENTSITEFIRST)
190 192
191 DECLARE_NOT_AGGREGATABLE(T) 193 DECLARE_NOT_AGGREGATABLE(T)
192 194
193 BEGIN_COM_MAP(ChromeFrameActivexBase) 195 BEGIN_COM_MAP(ChromeFrameActivexBase)
194 COM_INTERFACE_ENTRY(IChromeFrame) 196 COM_INTERFACE_ENTRY(IChromeFrame)
195 COM_INTERFACE_ENTRY(IDispatch) 197 COM_INTERFACE_ENTRY(IDispatch)
196 COM_INTERFACE_ENTRY(IViewObjectEx) 198 COM_INTERFACE_ENTRY(IViewObjectEx)
197 COM_INTERFACE_ENTRY(IViewObject2) 199 COM_INTERFACE_ENTRY(IViewObject2)
198 COM_INTERFACE_ENTRY(IViewObject) 200 COM_INTERFACE_ENTRY(IViewObject)
199 COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless) 201 COM_INTERFACE_ENTRY(IOleInPlaceObjectWindowless)
200 COM_INTERFACE_ENTRY(IOleInPlaceObject) 202 COM_INTERFACE_ENTRY(IOleInPlaceObject)
201 COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless) 203 COM_INTERFACE_ENTRY2(IOleWindow, IOleInPlaceObjectWindowless)
202 COM_INTERFACE_ENTRY(IOleInPlaceActiveObject) 204 COM_INTERFACE_ENTRY(IOleInPlaceActiveObject)
203 COM_INTERFACE_ENTRY(IOleControl) 205 COM_INTERFACE_ENTRY(IOleControl)
204 COM_INTERFACE_ENTRY(IOleObject) 206 COM_INTERFACE_ENTRY(IOleObject)
205 COM_INTERFACE_ENTRY(ISupportErrorInfo) 207 COM_INTERFACE_ENTRY(ISupportErrorInfo)
206 COM_INTERFACE_ENTRY(IQuickActivate) 208 COM_INTERFACE_ENTRY(IQuickActivate)
207 COM_INTERFACE_ENTRY(IProvideClassInfo) 209 COM_INTERFACE_ENTRY(IProvideClassInfo)
208 COM_INTERFACE_ENTRY(IProvideClassInfo2) 210 COM_INTERFACE_ENTRY(IProvideClassInfo2)
211 COM_INTERFACE_ENTRY(IConnectionPointContainer)
209 COM_INTERFACE_ENTRY_FUNC_BLIND(0, InterfaceNotSupported) 212 COM_INTERFACE_ENTRY_FUNC_BLIND(0, InterfaceNotSupported)
210 END_COM_MAP() 213 END_COM_MAP()
211 214
212 BEGIN_CONNECTION_POINT_MAP(T) 215 BEGIN_CONNECTION_POINT_MAP(T)
213 CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink) 216 CONNECTION_POINT_ENTRY(IID_IPropertyNotifySink)
214 CONNECTION_POINT_ENTRY(DIID_DIChromeFrameEvents) 217 CONNECTION_POINT_ENTRY(DIID_DIChromeFrameEvents)
215 END_CONNECTION_POINT_MAP() 218 END_CONNECTION_POINT_MAP()
216 219
217 BEGIN_MSG_MAP(ChromeFrameActivexBase) 220 BEGIN_MSG_MAP(ChromeFrameActivexBase)
218 MESSAGE_HANDLER(WM_CREATE, OnCreate) 221 MESSAGE_HANDLER(WM_CREATE, OnCreate)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 IE_8, 266 IE_8,
264 IE_8 + 1); 267 IE_8 + 1);
265 } 268 }
266 return S_OK; 269 return S_OK;
267 } 270 }
268 271
269 void FinalRelease() { 272 void FinalRelease() {
270 Uninitialize(); 273 Uninitialize();
271 } 274 }
272 275
276 void ResetUrlRequestManager() {
277 url_fetcher_.reset(new UrlmonUrlRequestManager());
278 }
279
273 static HRESULT WINAPI InterfaceNotSupported(void* pv, REFIID riid, void** ppv, 280 static HRESULT WINAPI InterfaceNotSupported(void* pv, REFIID riid, void** ppv,
274 DWORD dw) { 281 DWORD dw) {
275 #ifndef NDEBUG 282 #ifndef NDEBUG
276 wchar_t buffer[64] = {0}; 283 wchar_t buffer[64] = {0};
277 ::StringFromGUID2(riid, buffer, arraysize(buffer)); 284 ::StringFromGUID2(riid, buffer, arraysize(buffer));
278 DLOG(INFO) << "E_NOINTERFACE: " << buffer; 285 DLOG(INFO) << "E_NOINTERFACE: " << buffer;
279 #endif 286 #endif
280 return E_NOINTERFACE; 287 return E_NOINTERFACE;
281 } 288 }
282 289
(...skipping 10 matching lines...) Expand all
293 } 300 }
294 return S_FALSE; 301 return S_FALSE;
295 } 302 }
296 303
297 // Called to draw our control when chrome hasn't been initialized. 304 // Called to draw our control when chrome hasn't been initialized.
298 virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info) { // NOLINT 305 virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info) { // NOLINT
299 if (NULL == draw_info.prcBounds) { 306 if (NULL == draw_info.prcBounds) {
300 NOTREACHED(); 307 NOTREACHED();
301 return E_FAIL; 308 return E_FAIL;
302 } 309 }
303 // Don't draw anything. 310
311 if (draw_sad_tab_) {
312 // TODO(tommi): Draw a proper sad tab.
313 RECT rc = {0};
314 if (draw_info.prcBounds) {
315 rc.top = draw_info.prcBounds->top;
316 rc.bottom = draw_info.prcBounds->bottom;
317 rc.left = draw_info.prcBounds->left;
318 rc.right = draw_info.prcBounds->right;
319 } else {
320 GetClientRect(&rc);
321 }
322 ::DrawTextA(draw_info.hdcDraw, ":-(", -1, &rc,
323 DT_CENTER | DT_VCENTER | DT_SINGLELINE);
324 } else {
325 // Don't draw anything.
326 }
304 return S_OK; 327 return S_OK;
305 } 328 }
306 329
307 330
308 // Used to setup the document_url_ member needed for completing navigation. 331 // Used to setup the document_url_ member needed for completing navigation.
309 // Create external tab (possibly in incognito mode). 332 // Create external tab (possibly in incognito mode).
310 HRESULT IOleObject_SetClientSite(IOleClientSite* client_site) { 333 HRESULT IOleObject_SetClientSite(IOleClientSite* client_site) {
311 // If we currently have a document site pointer, release it. 334 // If we currently have a document site pointer, release it.
312 doc_site_.Release(); 335 doc_site_.Release();
313 if (client_site) { 336 if (client_site) {
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 int align_flags, 528 int align_flags,
506 const IPC::ContextMenuParams& params) { 529 const IPC::ContextMenuParams& params) {
507 scoped_refptr<BasePlugin> ref(this); 530 scoped_refptr<BasePlugin> ref(this);
508 ChromeFramePlugin<T>::OnHandleContextMenu(tab_handle, menu_handle, 531 ChromeFramePlugin<T>::OnHandleContextMenu(tab_handle, menu_handle,
509 align_flags, params); 532 align_flags, params);
510 } 533 }
511 534
512 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, 535 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam,
513 BOOL& handled) { // NO_LINT 536 BOOL& handled) { // NO_LINT
514 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0); 537 ModifyStyle(0, WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0);
515 url_fetcher_.put_notification_window(m_hWnd); 538 url_fetcher_->put_notification_window(m_hWnd);
516 if (automation_client_.get()) { 539 if (automation_client_.get()) {
517 automation_client_->SetParentWindow(m_hWnd); 540 automation_client_->SetParentWindow(m_hWnd);
518 } else { 541 } else {
519 NOTREACHED() << "No automation server"; 542 NOTREACHED() << "No automation server";
520 return -1; 543 return -1;
521 } 544 }
522 // Only fire the 'interactive' ready state if we aren't there already. 545 // Only fire the 'interactive' ready state if we aren't there already.
523 if (ready_state_ < READYSTATE_INTERACTIVE) { 546 if (ready_state_ < READYSTATE_INTERACTIVE) {
524 ready_state_ = READYSTATE_INTERACTIVE; 547 ready_state_ = READYSTATE_INTERACTIVE;
525 FireOnChanged(DISPID_READYSTATE); 548 FireOnChanged(DISPID_READYSTATE);
526 } 549 }
527 return 0; 550 return 0;
528 } 551 }
529 552
530 LRESULT OnDestroy(UINT message, WPARAM wparam, LPARAM lparam, 553 LRESULT OnDestroy(UINT message, WPARAM wparam, LPARAM lparam,
531 BOOL& handled) { // NO_LINT 554 BOOL& handled) { // NO_LINT
532 DLOG(INFO) << __FUNCTION__; 555 DLOG(INFO) << __FUNCTION__;
533 return 0; 556 return 0;
534 } 557 }
535 558
536 // ChromeFrameDelegate override 559 // ChromeFrameDelegate override
537 virtual void OnAutomationServerReady() { 560 virtual void OnAutomationServerReady() {
561 draw_sad_tab_ = false;
538 ChromeFramePlugin<T>::OnAutomationServerReady(); 562 ChromeFramePlugin<T>::OnAutomationServerReady();
539 563
540 ready_state_ = READYSTATE_COMPLETE; 564 ready_state_ = READYSTATE_COMPLETE;
541 FireOnChanged(DISPID_READYSTATE); 565 FireOnChanged(DISPID_READYSTATE);
542 } 566 }
543 567
544 // ChromeFrameDelegate override 568 // ChromeFrameDelegate override
545 virtual void OnAutomationServerLaunchFailed( 569 virtual void OnAutomationServerLaunchFailed(
546 AutomationLaunchResult reason, const std::string& server_version) { 570 AutomationLaunchResult reason, const std::string& server_version) {
571 DLOG(INFO) << __FUNCTION__;
572 if (reason == AUTOMATION_SERVER_CRASHED)
573 draw_sad_tab_ = true;
574
547 ready_state_ = READYSTATE_UNINITIALIZED; 575 ready_state_ = READYSTATE_UNINITIALIZED;
548 FireOnChanged(DISPID_READYSTATE); 576 FireOnChanged(DISPID_READYSTATE);
549 } 577 }
550 578
551 // Overridden to take advantage of readystate prop changes and send those 579 // Overridden to take advantage of readystate prop changes and send those
552 // to potential listeners. 580 // to potential listeners.
553 HRESULT FireOnChanged(DISPID dispid) { 581 HRESULT FireOnChanged(DISPID dispid) {
554 if (dispid == DISPID_READYSTATE) { 582 if (dispid == DISPID_READYSTATE) {
555 Fire_onreadystatechanged(ready_state_); 583 Fire_onreadystatechanged(ready_state_);
556 } 584 }
(...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty, 1222 web_browser2->Navigate2(url.AsInput(), &flags, &empty, &empty,
1195 http_headers.AsInput()); 1223 http_headers.AsInput());
1196 } 1224 }
1197 1225
1198 ScopedBstr url_; 1226 ScopedBstr url_;
1199 ScopedComPtr<IOleDocumentSite> doc_site_; 1227 ScopedComPtr<IOleDocumentSite> doc_site_;
1200 1228
1201 // If false, we tried but failed to fetch an IOleInPlaceFrame from our host. 1229 // If false, we tried but failed to fetch an IOleInPlaceFrame from our host.
1202 // Cached here so we don't try to fetch it every time if we keep failing. 1230 // Cached here so we don't try to fetch it every time if we keep failing.
1203 bool failed_to_fetch_in_place_frame_; 1231 bool failed_to_fetch_in_place_frame_;
1232 bool draw_sad_tab_;
1233
1204 ScopedComPtr<IOleInPlaceFrame> in_place_frame_; 1234 ScopedComPtr<IOleInPlaceFrame> in_place_frame_;
1205 1235
1206 // For more information on the ready_state_ property see: 1236 // For more information on the ready_state_ property see:
1207 // http://msdn.microsoft.com/en-us/library/aa768179(VS.85).aspx# 1237 // http://msdn.microsoft.com/en-us/library/aa768179(VS.85).aspx#
1208 READYSTATE ready_state_; 1238 READYSTATE ready_state_;
1209 1239
1210 // The following members contain IDispatch interfaces representing the 1240 // The following members contain IDispatch interfaces representing the
1211 // onload/onerror/onmessage handlers on the page. 1241 // onload/onerror/onmessage handlers on the page.
1212 ScopedVariant onload_handler_; 1242 ScopedVariant onload_handler_;
1213 ScopedVariant onerror_handler_; 1243 ScopedVariant onerror_handler_;
1214 ScopedVariant onmessage_handler_; 1244 ScopedVariant onmessage_handler_;
1215 1245
1216 EventHandlers onmessage_; 1246 EventHandlers onmessage_;
1217 EventHandlers onloaderror_; 1247 EventHandlers onloaderror_;
1218 EventHandlers onload_; 1248 EventHandlers onload_;
1219 EventHandlers onreadystatechanged_; 1249 EventHandlers onreadystatechanged_;
1220 EventHandlers onprivatemessage_; 1250 EventHandlers onprivatemessage_;
1221 EventHandlers onextensionready_; 1251 EventHandlers onextensionready_;
1222 1252
1223 // Handle network requests when host network stack is used. Passed to the 1253 // Handle network requests when host network stack is used. Passed to the
1224 // automation client on initialization. 1254 // automation client on initialization.
1225 UrlmonUrlRequestManager url_fetcher_; 1255 scoped_ptr<UrlmonUrlRequestManager> url_fetcher_;
1226 }; 1256 };
1227 1257
1228 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_ 1258 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_BASE_H_
OLDNEW
« no previous file with comments | « chrome_frame/chrome_frame_activex.cc ('k') | chrome_frame/chrome_frame_automation.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698