OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 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_COM_MESSAGE_EVENT_H_ |
| 6 #define CHROME_FRAME_COM_MESSAGE_EVENT_H_ |
| 7 |
| 8 #include <atlbase.h> |
| 9 #include <atlcom.h> |
| 10 #include <mshtml.h> // IHTMLEventObj |
| 11 #include "base/basictypes.h" |
| 12 #include "base/scoped_comptr_win.h" |
| 13 |
| 14 // Implements a MessageEvent compliant event object by providing MessageEvent |
| 15 // specific properties itself and inherited properties from a browser provided |
| 16 // event implementation. |
| 17 // NOTE: The messagePort and source properties will always be NULL. |
| 18 // See the HTML 5 spec for further details on a MessageEvent object: |
| 19 // http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#messag
eevent |
| 20 class ComMessageEvent |
| 21 : public CComObjectRootEx<CComSingleThreadModel>, |
| 22 public IDispatch { |
| 23 public: |
| 24 ComMessageEvent(); |
| 25 ~ComMessageEvent(); |
| 26 |
| 27 BEGIN_COM_MAP(ComMessageEvent) |
| 28 COM_INTERFACE_ENTRY(IDispatch) |
| 29 END_COM_MAP() |
| 30 |
| 31 // The dispids we support. These are based on HTML5 and not IHTMLEventObj5 |
| 32 // (there are a couple of differences). |
| 33 // http://dev.w3.org/html5/spec/Overview.html#messageevent |
| 34 // vs http://msdn.microsoft.com/en-us/library/cc288548(VS.85).aspx |
| 35 typedef enum { |
| 36 DISPID_MESSAGE_EVENT_DATA = 201, |
| 37 DISPID_MESSAGE_EVENT_ORIGIN, |
| 38 DISPID_MESSAGE_EVENT_LAST_EVENT_ID, |
| 39 DISPID_MESSAGE_EVENT_SOURCE, |
| 40 DISPID_MESSAGE_EVENT_MESSAGE_PORT, |
| 41 DISPID_MESSAGE_EVENT_TYPE |
| 42 } MessageEventDispIds; |
| 43 |
| 44 // Utility function for checking Invoke flags and assigning a BSTR to the |
| 45 // result variable. |
| 46 HRESULT GetStringProperty(WORD flags, const wchar_t* value, VARIANT* result); |
| 47 |
| 48 STDMETHOD(GetTypeInfoCount)(UINT* info); |
| 49 STDMETHOD(GetTypeInfo)(UINT which_info, LCID lcid, ITypeInfo** type_info); |
| 50 STDMETHOD(GetIDsOfNames)(REFIID iid, LPOLESTR* names, UINT count_names, |
| 51 LCID lcid, DISPID* dispids); |
| 52 STDMETHOD(Invoke)(DISPID dispid, REFIID iid, LCID lcid, WORD flags, |
| 53 DISPPARAMS* params, VARIANT* result, EXCEPINFO* excepinfo, |
| 54 UINT* arg_err); |
| 55 |
| 56 // Initializes this object. The container pointer is used to find the |
| 57 // container's IHTMLEventObj implementation if available. |
| 58 bool Initialize(IOleContainer* container, const std::string& message, |
| 59 const std::string& origin, const std::string& event_type); |
| 60 |
| 61 protected: |
| 62 // HTML Event object to which we delegate property and method |
| 63 // calls that we do not directly support. This may not be initialized |
| 64 // if our container does not require the properties/methods exposed by |
| 65 // the basic event object. |
| 66 ScopedComPtr<IHTMLEventObj> basic_event_; |
| 67 std::string message_; |
| 68 std::string origin_; |
| 69 std::string type_; |
| 70 |
| 71 private: |
| 72 DISALLOW_COPY_AND_ASSIGN(ComMessageEvent); |
| 73 }; |
| 74 |
| 75 #endif // CHROME_FRAME_COM_MESSAGE_EVENT_H_ |
OLD | NEW |