| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/np_event_listener.h" | 5 #include "chrome_frame/np_event_listener.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #include "chrome_frame/scoped_ns_ptr_win.h" | 9 #include "chrome_frame/scoped_ns_ptr_win.h" |
| 10 #include "chrome_frame/ns_associate_iid_win.h" | 10 #include "chrome_frame/ns_associate_iid_win.h" |
| 11 #include "third_party/xulrunner-sdk/win/include/string/nsEmbedString.h" | 11 #include "third_party/xulrunner-sdk/win/include/string/nsEmbedString.h" |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 } | 109 } |
| 110 | 110 |
| 111 bool DomEventListener::GetObjectElement(NPP instance, nsIDOMElement** element) { | 111 bool DomEventListener::GetObjectElement(NPP instance, nsIDOMElement** element) { |
| 112 DCHECK(element); | 112 DCHECK(element); |
| 113 | 113 |
| 114 ScopedNsPtr<nsIDOMElement> elem; | 114 ScopedNsPtr<nsIDOMElement> elem; |
| 115 // Fetching the dom element works in Firefox, but is not implemented | 115 // Fetching the dom element works in Firefox, but is not implemented |
| 116 // in webkit. | 116 // in webkit. |
| 117 npapi::GetValue(instance, NPNVDOMElement, elem.Receive()); | 117 npapi::GetValue(instance, NPNVDOMElement, elem.Receive()); |
| 118 if (!elem.get()) { | 118 if (!elem.get()) { |
| 119 DLOG(INFO) << "Failed to get NPNVDOMElement"; | 119 DVLOG(1) << "Failed to get NPNVDOMElement"; |
| 120 return false; | 120 return false; |
| 121 } | 121 } |
| 122 | 122 |
| 123 nsEmbedString tag; | 123 nsEmbedString tag; |
| 124 nsresult res = elem->GetTagName(tag); | 124 nsresult res = elem->GetTagName(tag); |
| 125 if (NS_SUCCEEDED(res)) { | 125 if (NS_SUCCEEDED(res)) { |
| 126 if (LowerCaseEqualsASCII(tag.get(), tag.get() + tag.Length(), "embed")) { | 126 if (LowerCaseEqualsASCII(tag.get(), tag.get() + tag.Length(), "embed")) { |
| 127 ScopedNsPtr<nsIDOMNode> parent; | 127 ScopedNsPtr<nsIDOMNode> parent; |
| 128 elem->GetParentNode(parent.Receive()); | 128 elem->GetParentNode(parent.Receive()); |
| 129 if (parent) { | 129 if (parent) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 | 170 |
| 171 if (lstrcmpiA(tag.c_str(), "embed") == 0) { | 171 if (lstrcmpiA(tag.c_str(), "embed") == 0) { |
| 172 // We've got the <embed> element but we really want | 172 // We've got the <embed> element but we really want |
| 173 // the <object> element. | 173 // the <object> element. |
| 174 if (npapi::GetProperty(instance, object, ids[PARENT_ELEMENT], &var)) { | 174 if (npapi::GetProperty(instance, object, ids[PARENT_ELEMENT], &var)) { |
| 175 DCHECK(NPVARIANT_IS_OBJECT(var)); | 175 DCHECK(NPVARIANT_IS_OBJECT(var)); |
| 176 npapi::ReleaseObject(object); | 176 npapi::ReleaseObject(object); |
| 177 object = NPVARIANT_TO_OBJECT(var); | 177 object = NPVARIANT_TO_OBJECT(var); |
| 178 } | 178 } |
| 179 } else { | 179 } else { |
| 180 DLOG(INFO) << __FUNCTION__ << " got " << tag; | 180 DVLOG(1) << __FUNCTION__ << " got " << tag; |
| 181 } | 181 } |
| 182 } else { | 182 } else { |
| 183 DLOG(INFO) << __FUNCTION__ << " failed to get the element's tag"; | 183 DVLOG(1) << __FUNCTION__ << " failed to get the element's tag"; |
| 184 } | 184 } |
| 185 } else { | 185 } else { |
| 186 DLOG(WARNING) << __FUNCTION__ << " failed to get NPNVPluginElementNPObject"; | 186 DLOG(WARNING) << __FUNCTION__ << " failed to get NPNVPluginElementNPObject"; |
| 187 } | 187 } |
| 188 | 188 |
| 189 return object; | 189 return object; |
| 190 } | 190 } |
| 191 | 191 |
| 192 // Implementation of NpEventListener | 192 // Implementation of NpEventListener |
| 193 bool NPObjectEventListener::Subscribe(NPP instance, | 193 bool NPObjectEventListener::Subscribe(NPP instance, |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 NPIdentifier* ids = GetCachedStringIds(); | 279 NPIdentifier* ids = GetCachedStringIds(); |
| 280 ScopedNpVariant result; | 280 ScopedNpVariant result; |
| 281 bool ret = npapi::GetProperty(npo->npp(), event, ids[TYPE], &result); | 281 bool ret = npapi::GetProperty(npo->npp(), event, ids[TYPE], &result); |
| 282 DCHECK(ret) << "getproperty(type)"; | 282 DCHECK(ret) << "getproperty(type)"; |
| 283 if (ret) { | 283 if (ret) { |
| 284 DCHECK(NPVARIANT_IS_STRING(result)); | 284 DCHECK(NPVARIANT_IS_STRING(result)); |
| 285 // Opera doesn't zero terminate its utf8 strings. | 285 // Opera doesn't zero terminate its utf8 strings. |
| 286 const NPString& type = NPVARIANT_TO_STRING(result); | 286 const NPString& type = NPVARIANT_TO_STRING(result); |
| 287 std::string zero_terminated(type.UTF8Characters, type.UTF8Length); | 287 std::string zero_terminated(type.UTF8Characters, type.UTF8Length); |
| 288 DLOG(INFO) << "handleEvent: " << zero_terminated; | 288 DVLOG(1) << "handleEvent: " << zero_terminated; |
| 289 delegate_->OnEvent(zero_terminated.c_str()); | 289 delegate_->OnEvent(zero_terminated.c_str()); |
| 290 } | 290 } |
| 291 } | 291 } |
| 292 | 292 |
| 293 NPClass* NPObjectEventListener::PluginClass() { | 293 NPClass* NPObjectEventListener::PluginClass() { |
| 294 static NPClass _np_class = { | 294 static NPClass _np_class = { |
| 295 NP_CLASS_STRUCT_VERSION, | 295 NP_CLASS_STRUCT_VERSION, |
| 296 reinterpret_cast<NPAllocateFunctionPtr>(AllocateObject), | 296 reinterpret_cast<NPAllocateFunctionPtr>(AllocateObject), |
| 297 reinterpret_cast<NPDeallocateFunctionPtr>(DeallocateObject), | 297 reinterpret_cast<NPDeallocateFunctionPtr>(DeallocateObject), |
| 298 NULL, // invalidate | 298 NULL, // invalidate |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 COMPILE_ASSERT(arraysize(identifier_names) == arraysize(_identifiers), | 357 COMPILE_ASSERT(arraysize(identifier_names) == arraysize(_identifiers), |
| 358 mismatched_array_size); | 358 mismatched_array_size); |
| 359 npapi::GetStringIdentifiers(identifier_names, IDENTIFIER_COUNT, | 359 npapi::GetStringIdentifiers(identifier_names, IDENTIFIER_COUNT, |
| 360 _identifiers); | 360 _identifiers); |
| 361 for (int i = 0; i < IDENTIFIER_COUNT; ++i) { | 361 for (int i = 0; i < IDENTIFIER_COUNT; ++i) { |
| 362 DCHECK(_identifiers[i] != 0); | 362 DCHECK(_identifiers[i] != 0); |
| 363 } | 363 } |
| 364 } | 364 } |
| 365 return _identifiers; | 365 return _identifiers; |
| 366 } | 366 } |
| OLD | NEW |