Extend Javascript API in Chrome/Blink framework

635 views
Skip to first unread message

Chang Shu

unread,
Jul 23, 2013, 10:20:37 AM7/23/13
to blin...@chromium.org
Hi, all,

I am looking for ways to extend Javascript APIs with native objects in the Chrome/Blink architecture. What I have found so far includes:
1. Extend WebCore bindings by adding new IDLs and cpp implementations to WebCore;
2. Bind new JS APIs through NPAPI plugin;
3. Use NaCL for Chrome?
Is there any other approaches?

Thank you!
Chang

Adam Barth

unread,
Jul 23, 2013, 12:45:18 PM7/23/13
to Chang Shu, blink-dev
On Tue, Jul 23, 2013 at 7:20 AM, Chang Shu <csh...@gmail.com> wrote:
I am looking for ways to extend Javascript APIs with native objects in the Chrome/Blink architecture.

Is your work part of the Chromium project, or are you working independently of the project?
 
What I have found so far includes:
1. Extend WebCore bindings by adding new IDLs and cpp implementations to WebCore;
2. Bind new JS APIs through NPAPI plugin;
3. Use NaCL for Chrome?
Is there any other approaches?

Another approach is to use v8::Extension.  The best approach depends on your goals and constraints.

Adam

Chang Shu

unread,
Aug 1, 2013, 1:19:31 PM8/1/13
to blin...@chromium.org, Chang Shu
Hi, Adam,

Would the v8::Extension work if I only plan to touch the browser code but not the Blink code? The WebKit has an injected bundle concept that I can write JS extensions from browser side based on JSC APIs but I am not sure if I can do similar things in Blink architecture.

Thank you,
Chang

Adam Barth

unread,
Aug 1, 2013, 2:12:36 PM8/1/13
to Chang Shu, blink-dev
On Thu, Aug 1, 2013 at 10:19 AM, Chang Shu <csh...@gmail.com> wrote:
Would the v8::Extension work if I only plan to touch the browser code but not the Blink code?

V8 doesn't execute in the browser process, which means you're not able to call V8 APIs there.
 
The WebKit has an injected bundle concept that I can write JS extensions from browser side based on JSC APIs but I am not sure if I can do similar things in Blink architecture.

Rather than structuring the code with bundles, we simply write code for the render process in the Chromium layer.  Typically this code will be in subdirectories of the source tree labelled "renderer" or "common".

Adam

Chang Shu

unread,
Aug 1, 2013, 3:17:01 PM8/1/13
to blin...@chromium.org, Chang Shu
Thanks for the explanation, Adam. I think I understand it now.

Chang

Marcus Bulach

unread,
Aug 2, 2013, 6:01:39 AM8/2/13
to Chang Shu, blink-dev
You may want to check the "benchmark extensions", such as GPU:
https://code.google.com/p/chromium/codesearch#chromium/src/content/renderer/gpu/gpu_benchmarking_extension.cc

It's a v8::Extension in the renderer side of the chromium layer, not blink..
It then goes communicates back and forth with the browser process using IPCs.

Hope that helps!

Thanks,
Marcus

Reply all
Reply to author
Forward
0 new messages