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