| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ | |
| 6 #define CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ | |
| 7 | |
| 8 #include <atlbase.h> | |
| 9 #include <atlcom.h> | |
| 10 #include <atlctl.h> | |
| 11 | |
| 12 #include <set> | |
| 13 #include <string> | |
| 14 #include <vector> | |
| 15 | |
| 16 #include "chrome_frame/chrome_frame_activex_base.h" | |
| 17 #include "chrome_frame/chrome_tab.h" | |
| 18 #include "chrome_frame/com_type_info_holder.h" | |
| 19 #include "grit/chrome_frame_resources.h" | |
| 20 | |
| 21 // ChromeFrameActivex: Implementation of the ActiveX control that is | |
| 22 // responsible for hosting a chrome frame, i.e. an iframe like widget which | |
| 23 // hosts the the chrome window. This object delegates to Chrome.exe | |
| 24 // (via the Chrome IPC-based automation mechanism) for the actual rendering. | |
| 25 class ATL_NO_VTABLE ChromeFrameActivex | |
| 26 : public ChromeFrameActivexBase<ChromeFrameActivex, CLSID_ChromeFrame>, | |
| 27 public IObjectSafetyImpl<ChromeFrameActivex, | |
| 28 INTERFACESAFE_FOR_UNTRUSTED_CALLER | | |
| 29 INTERFACESAFE_FOR_UNTRUSTED_DATA>, | |
| 30 public IObjectWithSiteImpl<ChromeFrameActivex>, | |
| 31 public IPersistPropertyBag { | |
| 32 public: | |
| 33 typedef ChromeFrameActivexBase<ChromeFrameActivex, CLSID_ChromeFrame> Base; | |
| 34 ChromeFrameActivex(); | |
| 35 ~ChromeFrameActivex(); | |
| 36 | |
| 37 DECLARE_REGISTRY_RESOURCEID(IDR_CHROMEFRAME_ACTIVEX) | |
| 38 | |
| 39 BEGIN_COM_MAP(ChromeFrameActivex) | |
| 40 COM_INTERFACE_ENTRY(IObjectWithSite) | |
| 41 COM_INTERFACE_ENTRY(IObjectSafety) | |
| 42 COM_INTERFACE_ENTRY(IPersist) | |
| 43 COM_INTERFACE_ENTRY(IPersistPropertyBag) | |
| 44 COM_INTERFACE_ENTRY_CHAIN(Base) | |
| 45 END_COM_MAP() | |
| 46 | |
| 47 BEGIN_MSG_MAP(ChromeFrameActivex) | |
| 48 MESSAGE_HANDLER(WM_CREATE, OnCreate) | |
| 49 CHAIN_MSG_MAP(Base) | |
| 50 END_MSG_MAP() | |
| 51 | |
| 52 HRESULT FinalConstruct(); | |
| 53 | |
| 54 virtual HRESULT OnDraw(ATL_DRAWINFO& draw_info); // NOLINT | |
| 55 | |
| 56 // IPersistPropertyBag implementation | |
| 57 STDMETHOD(GetClassID)(CLSID* class_id) { | |
| 58 if (class_id != NULL) | |
| 59 *class_id = GetObjectCLSID(); | |
| 60 return S_OK; | |
| 61 } | |
| 62 | |
| 63 STDMETHOD(InitNew)() { | |
| 64 return S_OK; | |
| 65 } | |
| 66 | |
| 67 STDMETHOD(Load)(IPropertyBag* bag, IErrorLog* error_log); | |
| 68 | |
| 69 STDMETHOD(Save)(IPropertyBag* bag, BOOL clear_dirty, BOOL save_all) { | |
| 70 return E_NOTIMPL; | |
| 71 } | |
| 72 | |
| 73 // Used to setup the document_url_ member needed for completing navigation. | |
| 74 // Create external tab (possibly in incognito mode). | |
| 75 HRESULT IOleObject_SetClientSite(IOleClientSite* client_site); | |
| 76 | |
| 77 // Overridden to perform security checks. | |
| 78 STDMETHOD(put_src)(BSTR src); | |
| 79 | |
| 80 // IChromeFrame | |
| 81 // On a fresh install of ChromeFrame the BHO will not be loaded in existing | |
| 82 // IE tabs/windows. This function instantiates the BHO and registers it | |
| 83 // explicitly. | |
| 84 STDMETHOD(registerBhoIfNeeded)(); | |
| 85 | |
| 86 protected: | |
| 87 // ChromeFrameDelegate overrides | |
| 88 virtual void OnLoadFailed(int error_code, const std::string& url); | |
| 89 virtual void OnAutomationServerLaunchFailed( | |
| 90 AutomationLaunchResult reason, const std::string& server_version); | |
| 91 virtual void OnChannelError(); | |
| 92 | |
| 93 // Separated to static function for unit testing this logic more easily. | |
| 94 static bool ShouldShowVersionMismatchDialog(bool is_privileged, | |
| 95 IOleClientSite* client_site); | |
| 96 | |
| 97 private: | |
| 98 LRESULT OnCreate(UINT message, WPARAM wparam, LPARAM lparam, | |
| 99 BOOL& handled); // NO_LINT | |
| 100 | |
| 101 HRESULT GetContainingDocument(IHTMLDocument2** doc); | |
| 102 HRESULT GetDocumentWindow(IHTMLWindow2** window); | |
| 103 | |
| 104 // Gets the value of the 'id' attribute of the object element. | |
| 105 HRESULT GetObjectScriptId(IHTMLObjectElement* object_elem, BSTR* id); | |
| 106 | |
| 107 // Returns the object element in the HTML page. | |
| 108 // Note that if we're not being hosted inside an HTML | |
| 109 // document, then this call will fail. | |
| 110 HRESULT GetObjectElement(IHTMLObjectElement** element); | |
| 111 | |
| 112 HRESULT CreateScriptBlockForEvent(IHTMLElement2* insert_after, | |
| 113 BSTR instance_id, BSTR script, | |
| 114 BSTR event_name); | |
| 115 | |
| 116 // Utility function that checks the size of the vector and if > 0 creates | |
| 117 // a variant for the string argument and forwards the call to the other | |
| 118 // FireEvent method. | |
| 119 void FireEvent(const EventHandlers& handlers, const std::string& arg); | |
| 120 | |
| 121 // Invokes all registered handlers in a vector of event handlers. | |
| 122 void FireEvent(const EventHandlers& handlers, IDispatch* event); | |
| 123 | |
| 124 // This variant is used for the privatemessage handler only. | |
| 125 void FireEvent(const EventHandlers& handlers, IDispatch* event, | |
| 126 BSTR target); | |
| 127 | |
| 128 // Installs a hook on the top-level window hosting the control. | |
| 129 HRESULT InstallTopLevelHook(IOleClientSite* client_site); | |
| 130 | |
| 131 // A hook attached to the top-level window containing the ActiveX control. | |
| 132 HHOOK chrome_wndproc_hook_; | |
| 133 | |
| 134 // Set to true if the current instance is attaching to an existing Chrome | |
| 135 // tab. This occurs when a window.open request is performed by Chrome. | |
| 136 bool attaching_to_existing_cf_tab_; | |
| 137 }; | |
| 138 | |
| 139 #endif // CHROME_FRAME_CHROME_FRAME_ACTIVEX_H_ | |
| OLD | NEW |