diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 00:38:15 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-19 00:38:15 +0000 |
commit | 405e90f27ab9a7276635db529f3ea33fbbec7ba8 (patch) | |
tree | 7bbe3363e1816065679da85162590ba017eb40b5 /chrome_frame/urlmon_moniker.cc | |
parent | bfc7b586379bb03cd4a792d500800c107885ab94 (diff) | |
download | chromium_src-405e90f27ab9a7276635db529f3ea33fbbec7ba8.zip chromium_src-405e90f27ab9a7276635db529f3ea33fbbec7ba8.tar.gz chromium_src-405e90f27ab9a7276635db529f3ea33fbbec7ba8.tar.bz2 |
Fix a crash with the IMoniker::BindToObject patch in ChromeFrame which occurs during View Source. The crash
occurs because we don't have a NavigationManager instance.
Fix is to just call the original BindToObject method and bail.
Review URL: http://codereview.chromium.org/1133003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42044 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/urlmon_moniker.cc')
-rw-r--r-- | chrome_frame/urlmon_moniker.cc | 69 |
1 files changed, 37 insertions, 32 deletions
diff --git a/chrome_frame/urlmon_moniker.cc b/chrome_frame/urlmon_moniker.cc index dab39e3..85fad9f 100644 --- a/chrome_frame/urlmon_moniker.cc +++ b/chrome_frame/urlmon_moniker.cc @@ -436,42 +436,47 @@ HRESULT MonikerPatch::BindToObject(IMoniker_BindToObject_Fn original, HRESULT hr = me->GetDisplayName(bind_ctx, NULL, &url); DCHECK(SUCCEEDED(hr)); NavigationManager* mgr = NavigationManager::GetThreadInstance(); - DCHECK(mgr); - bool interest = mgr ? mgr->IsTopLevelUrl(url) : false; - if (interest) { - scoped_refptr<RequestData> request_data(mgr->GetActiveRequestData(url)); - if (request_data) { - DLOG(INFO) << " got cached content"; - mgr->set_referrer(request_data->headers()->GetReferrer()); - DLOG(INFO) << "referrer is: " << mgr->referrer(); - // Create a new CF document object and initialize it with - // the already cached data. - ScopedComPtr<IUnknown> cf_doc; - hr = cf_doc.CreateInstance(CLSID_ChromeActiveDocument); - DCHECK(SUCCEEDED(hr)); - ScopedComPtr<IPersistMoniker> persist_moniker; - hr = persist_moniker.QueryFrom(cf_doc); - DCHECK(SUCCEEDED(hr)); - hr = persist_moniker->Load(TRUE, me, bind_ctx, STGM_READ); - DCHECK(SUCCEEDED(hr)); - hr = persist_moniker.QueryInterface(iid, obj); - DCHECK(SUCCEEDED(hr)); + if (mgr) { + bool interest = mgr ? mgr->IsTopLevelUrl(url) : false; + if (interest) { + scoped_refptr<RequestData> request_data(mgr->GetActiveRequestData(url)); + if (request_data) { + DLOG(INFO) << " got cached content"; + mgr->set_referrer(request_data->headers()->GetReferrer()); + DLOG(INFO) << "referrer is: " << mgr->referrer(); + // Create a new CF document object and initialize it with + // the already cached data. + ScopedComPtr<IUnknown> cf_doc; + hr = cf_doc.CreateInstance(CLSID_ChromeActiveDocument); + DCHECK(SUCCEEDED(hr)); + ScopedComPtr<IPersistMoniker> persist_moniker; + hr = persist_moniker.QueryFrom(cf_doc); + DCHECK(SUCCEEDED(hr)); + hr = persist_moniker->Load(TRUE, me, bind_ctx, STGM_READ); + DCHECK(SUCCEEDED(hr)); + hr = persist_moniker.QueryInterface(iid, obj); + DCHECK(SUCCEEDED(hr)); + } else { + DLOG(INFO) << " creating callback object"; + CComObject<CFUrlmonBindStatusCallback>* callback = NULL; + hr = CComObject<CFUrlmonBindStatusCallback>::CreateInstance( + &callback); + callback->AddRef(); + hr = callback->Initialize(bind_ctx, mgr->GetActiveRequestHeaders()); + DCHECK(SUCCEEDED(hr)); + hr = original(me, bind_ctx, to_left, iid, obj); + callback->Release(); + if (SUCCEEDED(hr) && (*obj) == NULL) { + DCHECK(hr == MK_S_ASYNCHRONOUS); + } + } } else { - DLOG(INFO) << " creating callback object"; - CComObject<CFUrlmonBindStatusCallback>* callback = NULL; - hr = CComObject<CFUrlmonBindStatusCallback>::CreateInstance( - &callback); - callback->AddRef(); - hr = callback->Initialize(bind_ctx, mgr->GetActiveRequestHeaders()); - DCHECK(SUCCEEDED(hr)); + DLOG(INFO) << " -- calling original. (no interest)"; hr = original(me, bind_ctx, to_left, iid, obj); - callback->Release(); - if (SUCCEEDED(hr) && (*obj) == NULL) { - DCHECK(hr == MK_S_ASYNCHRONOUS); - } } } else { - DLOG(INFO) << " -- calling original. (no interest)"; + // We don't have a NavigationManager instance for cases like View Source + // etc. hr = original(me, bind_ctx, to_left, iid, obj); } |