OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome_frame/com_message_event.h" | 5 #include "chrome_frame/com_message_event.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 | 11 |
12 ComMessageEvent::ComMessageEvent() { | 12 ComMessageEvent::ComMessageEvent() { |
13 } | 13 } |
14 | 14 |
15 ComMessageEvent::~ComMessageEvent() { | 15 ComMessageEvent::~ComMessageEvent() { |
16 } | 16 } |
17 | 17 |
18 bool ComMessageEvent::Initialize(IOleContainer* container, | 18 bool ComMessageEvent::Initialize(IOleContainer* container, |
19 const std::string& message, | 19 const std::string& message, |
20 const std::string& origin, | 20 const std::string& origin, |
21 const std::string& event_type) { | 21 const std::string& event_type) { |
22 DLOG_IF(WARNING, !container) << __FUNCTION__ << " no container"; | 22 DLOG_IF(WARNING, !container) << __FUNCTION__ << " no container"; |
23 message_ = message; | 23 message_ = message; |
24 origin_ = origin; | 24 origin_ = origin; |
25 type_ = event_type; | 25 type_ = event_type; |
26 | 26 |
27 // May remain NULL if container not IE | 27 // May remain NULL if container not IE |
28 ScopedComPtr<IHTMLEventObj> basic_event; | 28 base::win::ScopedComPtr<IHTMLEventObj> basic_event; |
29 ScopedComPtr<IHTMLDocument2> doc; | 29 base::win::ScopedComPtr<IHTMLDocument2> doc; |
30 | 30 |
31 // Fetching doc may fail in non-IE containers | 31 // Fetching doc may fail in non-IE containers |
32 // and container might be NULL in some applications. | 32 // and container might be NULL in some applications. |
33 if (container) | 33 if (container) |
34 container->QueryInterface(doc.Receive()); | 34 container->QueryInterface(doc.Receive()); |
35 if (doc) { | 35 if (doc) { |
36 ScopedComPtr<IHTMLDocument4> doc4; | 36 base::win::ScopedComPtr<IHTMLDocument4> doc4; |
37 doc4.QueryFrom(doc); | 37 doc4.QueryFrom(doc); |
38 DCHECK(doc4); // supported by IE5.5 and higher | 38 DCHECK(doc4); // supported by IE5.5 and higher |
39 if (doc4) { | 39 if (doc4) { |
40 // IHTMLEventObj5 is only supported in IE8 and later, so we provide our | 40 // IHTMLEventObj5 is only supported in IE8 and later, so we provide our |
41 // own (minimalistic) implementation of it. | 41 // own (minimalistic) implementation of it. |
42 doc4->createEventObject(NULL, basic_event.Receive()); | 42 doc4->createEventObject(NULL, basic_event.Receive()); |
43 DCHECK(basic_event); | 43 DCHECK(basic_event); |
44 } | 44 } |
45 } | 45 } |
46 | 46 |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 HRESULT hr; | 152 HRESULT hr; |
153 if (flags & DISPATCH_PROPERTYGET) { | 153 if (flags & DISPATCH_PROPERTYGET) { |
154 result->vt = VT_BSTR; | 154 result->vt = VT_BSTR; |
155 result->bstrVal = ::SysAllocString(value); | 155 result->bstrVal = ::SysAllocString(value); |
156 hr = S_OK; | 156 hr = S_OK; |
157 } else { | 157 } else { |
158 hr = DISP_E_TYPEMISMATCH; | 158 hr = DISP_E_TYPEMISMATCH; |
159 } | 159 } |
160 return hr; | 160 return hr; |
161 } | 161 } |
OLD | NEW |