OLD | NEW |
---|---|
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains definitions for CppBoundClass | 5 // This file contains definitions for CppBoundClass |
6 | 6 |
7 // Here's the control flow of a JS method getting forwarded to a class. | 7 // Here's the control flow of a JS method getting forwarded to a class. |
8 // - Something calls our NPObject with a function like "Invoke". | 8 // - Something calls our NPObject with a function like "Invoke". |
9 // - CppNPObject's static invoke() function forwards it to its attached | 9 // - CppNPObject's static invoke() function forwards it to its attached |
10 // CppBoundClass's Invoke() method. | 10 // CppBoundClass's Invoke() method. |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
312 CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); | 312 CppNPObject* obj = reinterpret_cast<CppNPObject*>(np_obj); |
313 obj->bound_class = this; | 313 obj->bound_class = this; |
314 self_variant_.Set(np_obj); | 314 self_variant_.Set(np_obj); |
315 WebBindings::releaseObject(np_obj); // CppVariant takes the reference. | 315 WebBindings::releaseObject(np_obj); // CppVariant takes the reference. |
316 } | 316 } |
317 DCHECK(self_variant_.isObject()); | 317 DCHECK(self_variant_.isObject()); |
318 return &self_variant_; | 318 return &self_variant_; |
319 } | 319 } |
320 | 320 |
321 void CppBoundClass::BindToJavascript(WebFrame* frame, | 321 void CppBoundClass::BindToJavascript(WebFrame* frame, |
322 const std::wstring& classname) { | 322 const std::string& classname) { |
323 #if WEBKIT_USING_JSC | 323 #if WEBKIT_USING_JSC |
324 #error "This is not going to work anymore...but it's not clear what the solution is...or if it's still necessary." | 324 #error "This is not going to work anymore...but it's not clear what the solution is...or if it's still necessary." |
325 JSC::JSLock lock(false); | 325 JSC::JSLock lock(false); |
326 #endif | 326 #endif |
327 | 327 |
328 // BindToWindowObject will take its own reference to the NPObject, and clean | 328 // BindToWindowObject will take its own reference to the NPObject, and clean |
329 // up after itself. It will also (indirectly) register the object with V8, | 329 // up after itself. It will also (indirectly) register the object with V8, |
330 // so we must remember this so we can unregister it when we're destroyed. | 330 // so we must remember this so we can unregister it when we're destroyed. |
331 frame->bindToWindowObject(WideToUTF16Hack(classname), | 331 frame->bindToWindowObject(ASCIIToUTF16(classname), |
viettrungluu
2010/12/03 02:00:16
I was going to say that maybe we should be using U
| |
332 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 332 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
333 bound_to_frame_ = true; | 333 bound_to_frame_ = true; |
334 } | 334 } |
OLD | NEW |