diff options
author | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
---|---|---|
committer | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
commit | f781782dd67077478e117c61dca4ea5eefce3544 (patch) | |
tree | 4801f724123cfdcbb69c4e7fe40a565b331723ae /chrome_frame/chrome_frame_activex.h | |
parent | 63cf4759efa2373e33436fb5df6849f930081226 (diff) | |
download | chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.zip chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.gz chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.bz2 |
Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming in a separate CL.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/218019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/chrome_frame_activex.h')
-rw-r--r-- | chrome_frame/chrome_frame_activex.h | 140 |
1 files changed, 140 insertions, 0 deletions
diff --git a/chrome_frame/chrome_frame_activex.h b/chrome_frame/chrome_frame_activex.h new file mode 100644 index 0000000..07b8122 --- /dev/null +++ b/chrome_frame/chrome_frame_activex.h @@ -0,0 +1,140 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ +#define CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ + +#include <atlbase.h> +#include <atlcom.h> +#include <atlctl.h> + +#include <set> +#include <string> + +#include "base/scoped_bstr_win.h" +#include "base/scoped_comptr_win.h" +#include "base/scoped_variant_win.h" +#include "chrome_frame/chrome_frame_activex_base.h" +#include "chrome_frame/com_type_info_holder.h" +#include "grit/chrome_frame_resources.h" + +// Include without path to make GYP build see it. +#include "chrome_tab.h" // NOLINT + +// ChromeFrameActivex: Implementation of the ActiveX control that is +// responsible for hosting a chrome frame, i.e. an iframe like widget which +// hosts the the chrome window. This object delegates to Chrome.exe +// (via the Chrome IPC-based automation mechanism) for the actual rendering. +class ATL_NO_VTABLE ChromeFrameActivex + : public ChromeFrameActivexBase<ChromeFrameActivex, CLSID_ChromeFrame>, + public IObjectSafetyImpl<ChromeFrameActivex, + INTERFACESAFE_FOR_UNTRUSTED_CALLER | + INTERFACESAFE_FOR_UNTRUSTED_DATA>, + public IPersistPropertyBag { + public: + typedef ChromeFrameActivexBase<ChromeFrameActivex, CLSID_ChromeFrame> Base; + ChromeFrameActivex(); + ~ChromeFrameActivex(); + +DECLARE_REGISTRY_RESOURCEID(IDR_CHROMEFRAME) + +BEGIN_COM_MAP(ChromeFrameActivex) + COM_INTERFACE_ENTRY(IObjectSafety) + COM_INTERFACE_ENTRY(IPersistPropertyBag) + COM_INTERFACE_ENTRY(IConnectionPointContainer) + COM_INTERFACE_ENTRY_CHAIN(Base) +END_COM_MAP() + +BEGIN_MSG_MAP(ChromeFrameActivex) + MESSAGE_HANDLER(WM_CREATE, OnCreate) + CHAIN_MSG_MAP(Base) +END_MSG_MAP() + + HRESULT FinalConstruct(); + + virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info); + + // IPersistPropertyBag implementation + STDMETHOD(GetClassID)(CLSID* class_id) { + if (class_id != NULL) + *class_id = GetObjectCLSID(); + return S_OK; + } + + STDMETHOD(InitNew)() { + return S_OK; + } + + STDMETHOD(Load)(IPropertyBag* bag, IErrorLog* error_log); + + STDMETHOD(Save)(IPropertyBag* bag, BOOL clear_dirty, BOOL save_all) { + return E_NOTIMPL; + } + + // Used to setup the document_url_ member needed for completing navigation. + // Create external tab (possibly in incognito mode). + HRESULT IOleObject_SetClientSite(IOleClientSite *pClientSite); + + // Overridden to perform security checks. + STDMETHOD(put_src)(BSTR src); + + protected: + virtual void OnAcceleratorPressed(int tab_handle, const MSG& accel_message); + virtual void OnLoad(int tab_handle, const GURL& url); + virtual void OnMessageFromChromeFrame(int tab_handle, + const std::string& message, + const std::string& origin, + const std::string& target); + + private: + + LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, + BOOL& handled); // NO_LINT + + // ChromeFrameDelegate overrides + virtual void ChromeFrameActivex::OnAutomationServerLaunchFailed( + AutomationLaunchResult reason, const std::string& server_version); + virtual void OnLoadFailed(int error_code, const std::string& url); + + // Helper function to execute a function on a script IDispatch interface. + HRESULT InvokeScriptFunction(const VARIANT& script, const std::string& param); + HRESULT InvokeScriptFunction(const VARIANT& script, VARIANT* param); + HRESULT GetContainingDocument(IHTMLDocument2** doc); + HRESULT GetDocumentWindow(IHTMLWindow2** window); + + // Gets the value of the 'id' attribute of the object element. + HRESULT GetObjectScriptId(IHTMLObjectElement* object_elem, BSTR* id); + + // Returns the object element in the HTML page. + // Note that if we're not being hosted inside an HTML + // document, then this call will fail. + HRESULT GetObjectElement(IHTMLObjectElement** element); + + HRESULT CreateScriptBlockForEvent(IHTMLElement2* insert_after, + BSTR instance_id, BSTR script, + BSTR event_name); + + // Creates a new event object that supports the |data| property. + // Note: you should supply an empty string for |origin| unless you're + // creating a "message" event. + HRESULT CreateDomEvent(const std::string& event_type, const std::string& data, + const std::string& origin, IDispatch** event); + + // Utility function that checks the size of the vector and if > 0 creates + // a variant for the string argument and forwards the call to the other + // FireEvent method. + void FireEvent(const EventHandlers& handlers, const std::string& arg); + + // Invokes all registered handlers in a vector of event handlers. + void FireEvent(const EventHandlers& handlers, IDispatch* event); + + // This variant is used for the privatemessage handler only. + void FireEvent(const EventHandlers& handlers, IDispatch* event, + BSTR target); + +}; + +OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) + +#endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ |