Skip to content

Commit

Permalink
The chrome frame install script instantiates the chrome frame activex…
Browse files Browse the repository at this point in the history
… via the new ActiveXObject call, which causes it

to not receive the IOleObject_SetClientSite call.

We now bootstrap our BHO in an explicit method call RegisterBHOIfNeeded

Fixes bug http://code.google.com/p/chromium/issues/detail?id=42790

Bug=42790

Review URL: http://codereview.chromium.org/1823001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46165 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ananta@chromium.org committed May 1, 2010
1 parent 975126c commit e12a3b8
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 14 deletions.
1 change: 1 addition & 0 deletions chrome_frame/CFInstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
try {
var obj = new ActiveXObject('ChromeTab.ChromeFrame');
if (obj) {
obj.RegisterBHOIfNeeded();
return true;
}
} catch(e) {
Expand Down
20 changes: 11 additions & 9 deletions chrome_frame/chrome_frame_activex.cc
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,14 @@ STDMETHODIMP ChromeFrameActivex::put_src(BSTR src) {
return Base::put_src(src);
}

STDMETHODIMP ChromeFrameActivex::SetSite(IUnknown* site) {
// We need to bootstrap our BHO if IE is running while chrome frame is
// installed. For new tabs and windows the newly registered BHO's are
// loaded. The bootstrapping is only needed for the current tab.
site_ = site;
return IObjectWithSiteImpl<ChromeFrameActivex>::SetSite(site);
}

HRESULT ChromeFrameActivex::IOleObject_SetClientSite(
IOleClientSite* client_site) {
HRESULT hr = Base::IOleObject_SetClientSite(client_site);
Expand Down Expand Up @@ -454,11 +462,6 @@ HRESULT ChromeFrameActivex::IOleObject_SetClientSite(
IsIEInPrivate(), true)) {
return E_FAIL;
}

// We need to bootstrap our BHO if IE is running while chrome frame is
// installed. For new tabs and windows the newly registered BHO's are
// loaded. The bootstrapping is only needed for the current tab.
RegisterBHOIfNeeded(client_site);
}

return hr;
Expand Down Expand Up @@ -606,9 +609,8 @@ HRESULT ChromeFrameActivex::InstallTopLevelHook(IOleClientSite* client_site) {
return chrome_wndproc_hook_ ? S_OK : E_FAIL;
}

HRESULT ChromeFrameActivex::RegisterBHOIfNeeded(
IOleClientSite* client_site) {
if (!client_site) {
HRESULT ChromeFrameActivex::RegisterBHOIfNeeded() {
if (!site_) {
NOTREACHED() << "Invalid client site";
return E_FAIL;
}
Expand All @@ -619,7 +621,7 @@ HRESULT ChromeFrameActivex::RegisterBHOIfNeeded(
}

ScopedComPtr<IWebBrowser2> web_browser2;
HRESULT hr = DoQueryService(SID_SWebBrowserApp, client_site,
HRESULT hr = DoQueryService(SID_SWebBrowserApp, site_,
web_browser2.Receive());
if (FAILED(hr) || web_browser2.get() == NULL) {
DLOG(WARNING) << "Failed to get IWebBrowser2 from client site. Error:"
Expand Down
18 changes: 13 additions & 5 deletions chrome_frame/chrome_frame_activex.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class ATL_NO_VTABLE ChromeFrameActivex
public IObjectSafetyImpl<ChromeFrameActivex,
INTERFACESAFE_FOR_UNTRUSTED_CALLER |
INTERFACESAFE_FOR_UNTRUSTED_DATA>,
public IObjectWithSiteImpl<ChromeFrameActivex>,
public IPersistPropertyBag {
public:
typedef ChromeFrameActivexBase<ChromeFrameActivex, CLSID_ChromeFrame> Base;
Expand All @@ -43,6 +44,7 @@ class ATL_NO_VTABLE ChromeFrameActivex
DECLARE_REGISTRY_RESOURCEID(IDR_CHROMEFRAME)

BEGIN_COM_MAP(ChromeFrameActivex)
COM_INTERFACE_ENTRY(IObjectWithSite)
COM_INTERFACE_ENTRY(IObjectSafety)
COM_INTERFACE_ENTRY(IPersistPropertyBag)
COM_INTERFACE_ENTRY(IConnectionPointContainer)
Expand Down Expand Up @@ -83,6 +85,15 @@ END_MSG_MAP()
// Overridden to perform security checks.
STDMETHOD(put_src)(BSTR src);

// IObjectWithSite
STDMETHOD(SetSite)(IUnknown* site);

// IChromeFrame
// On a fresh install of ChromeFrame the BHO will not be loaded in existing
// IE tabs/windows. This function instantiates the BHO and registers it
// explicitly.
STDMETHOD(RegisterBHOIfNeeded)();

protected:
// ChromeFrameDelegate overrides
virtual void OnLoad(int tab_handle, const GURL& url);
Expand Down Expand Up @@ -136,13 +147,10 @@ END_MSG_MAP()
// Installs a hook on the top-level window hosting the control.
HRESULT InstallTopLevelHook(IOleClientSite* client_site);

// On a fresh install of ChromeFrame the BHO will not be loaded in existing
// IE tabs/windows. This function instantiates the BHO and registers it
// explicitly.
HRESULT RegisterBHOIfNeeded(IOleClientSite* client_site);

// A hook attached to the top-level window containing the ActiveX control.
HHOOK chrome_wndproc_hook_;

ScopedComPtr<IUnknown> site_;
};

#endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_
4 changes: 4 additions & 0 deletions chrome_frame/chrome_frame_activex_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,10 @@ END_MSG_MAP()
return S_OK;
}

STDMETHOD(RegisterBHOIfNeeded)() {
return E_NOTIMPL;
}

// Returns the vector of event handlers for a given event (e.g. "load").
// If the event type isn't recognized, the function fills in a descriptive
// error (IErrorInfo) and returns E_INVALIDARG.
Expand Down
4 changes: 4 additions & 0 deletions chrome_frame/chrome_tab.idl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ interface IChromeFrame : IDispatch {
[id(14), hidden]
// This method is available only when the control is in privileged mode.
HRESULT getEnabledExtensions();

[id(15)]
// This method bootstraps the BHO if it is not already loaded.
HRESULT RegisterBHOIfNeeded();
};

[
Expand Down

0 comments on commit e12a3b8

Please sign in to comment.