Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
107 views
in Technique[技术] by (71.8m points)

c++ - Is it possible to embed a HTTP server in a Google Chrome extension?

Do you think it would be possible to embed a HTTP server inside a Google Chrome extension?

I've seen other Google Chrome extensions execute native code and apparrently they do it by using NPAPI, but I have no idea what that is. And it's really freaking me out, as I'm no C++ expert or anything like that. So I feel a little stuck now and that's why I'm asking for help.

Specifically, I want to create an extension for Chrome with features similar to Opera Unite. For those who don't know what I'm talking about: Opera Unite is basically a zero-conf web server bundled with the browser. I don't want to use it for the same things Opera does, but I like the concept.

I was thinking about using something like node.js inside the browser to create a simple web interface to control some stuff in the browser. Think of it as a remote control for the browser. If node.js isn't possible I'd like to use lighthttpd or something similar. The technology really doesn't matter as long as it allows me to receive commands over HTTP.

But how do I take an existing web server and make a NPAPI plugin out of it?

Clarification: I'd like any browser to be able to communicate with my extension. Especially I want mobile devices like Android or the iPhone to be able to remote control the browser. Is there any other way to accomplish that except with a HTTP server?

Another update: I think the easiest way to do this would be to use a relay server on the web like Pusher or some self-created service. But I don't like this approach because it requires constant internet access and because it's a paid service.

Thank you all!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here is another web server implemented with chrome.socket: https://github.com/kzahel/web-server-chrome. The server example linked to in chrome-app-samples is actually really buggy and will lock up if you e.g. hold down Ctrl-R on a page served by it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...