OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 DCHECK(self_variant_.isObject()); | 314 DCHECK(self_variant_.isObject()); |
315 return &self_variant_; | 315 return &self_variant_; |
316 } | 316 } |
317 | 317 |
318 void CppBoundClass::BindToJavascript(WebFrame* frame, | 318 void CppBoundClass::BindToJavascript(WebFrame* frame, |
319 const std::string& classname) { | 319 const std::string& classname) { |
320 // BindToWindowObject will take its own reference to the NPObject, and clean | 320 // BindToWindowObject will take its own reference to the NPObject, and clean |
321 // up after itself. It will also (indirectly) register the object with V8, | 321 // up after itself. It will also (indirectly) register the object with V8, |
322 // against an owner pointer we supply, so we must register that as an owner, | 322 // against an owner pointer we supply, so we must register that as an owner, |
323 // and unregister when we teardown. | 323 // and unregister when we teardown. |
324 frame->bindToWindowObject(ASCIIToUTF16(classname), | 324 frame->bindToWindowObject(base::ASCIIToUTF16(classname), |
325 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); | 325 NPVARIANT_TO_OBJECT(*GetAsCppVariant())); |
326 bound_to_frame_ = true; | 326 bound_to_frame_ = true; |
327 } | 327 } |
328 | 328 |
329 } // namespace webkit_glue | 329 } // namespace webkit_glue |
OLD | NEW |