Unable to enable Chrome app in iframe - google-chrome

I'm trying to load the native messaging example app in an external webpage as follows:
test.html
<html>
<head>
</head>
<body>
<iframe src="chrome-extension://knldjmfmopnpolahpmmgbagdohdnhkik/main.html"</iframe>
</body>
</html>
I have added the web_accessible_resources property in the app's manifest:
manifest.json
{
// <some code snipped>
"web_accessible_resources": ["main.html"]
}
However, when I use the app within test.html, I get the following error in the console, coming from a JavaScript file within the app:
Developer Console
Uncaught TypeError: Object # has no method 'connectNative'
main.js:51
The problematic line of code is the following:
main.js
port = chrome.runtime.connectNative(hostName);
Here's a screenshot - the problem happens when I click on the Connect button (which calls the connect function):
Obviously, this works when the app is run standalone. How can I go about loading the app in a webpage?

You can't. With very few exceptions, Chrome avoids proprietary extensions to the open web. You're asking for exactly that: an external web page that has nonstandard abilities simply because it's opened in Chrome rather than another browser. As the web is today, that kind of behavior would lead to a poor developer and user experience. The native-messaging documentation suggests that the functionality you want is available to Chrome extensions and Chrome apps. And as you're finding out, that's indeed the case: it works as an app, but not as a web-standard iframe. This is by design.
You probably want to write a Chrome extension. Your webpage should detect whether the Chrome extension is installed and whether the user's browser is Chrome. If it's not Chrome, it should give an appropriate error message. If it is Chrome but the extension is not installed, it should urge the user to install your extension.

Related

Does Google Chrome Frame break IE8 console output?

This is a question about debugging a project, not about writing the code.
I am on the final stages of developing an HTML5 web app. Fairly last minute, our client tells us it should run on IE8. Since I use the HTML5-canvas in the app, this required the addition of Google Chrome Frame. Once installed and testing, however, IE8's developer console no longer prints any data, and the HTML viewer never loads. Is this a bug? Is there a way to fix it? It will really suck if I need to debug with alerts...
From Google Chrome Frame documentation:
You can use the Web Inspector in GCF just as you would in the Google Chrome browser. To use it, right-click and choose "Inspect Element". Logging is available via the console.log method, and you can set breakpoints and inspect network activity.

Embed web inspector console in a page

Is there any way to embed "console" tab from chrome web inspector in a page?
Unfortunately I do not know of a way to do this in a normal web page in any browser but you could make an Electron app and perhaps show the inspector whenever you want for the user.
If you are looking to embed a JS console emulator on your site, perhaps to show off raw JavaScript, you can use YourJS Console. It also gives you the ability to initialize the console with custom code or a GitHub Gist.

How do you get WebGL Inspector to show up in Chrome?

In Chrome, I have the WebGL Inspector extension installed. The debug option does not show up in the address bar for the page I'm working on (that I'm using WebGL in). It shows up for other pages on the web. What are the requirements for getting it to give me the debug option?
I guess that you are trying to debug a local file (file://). If so, navigate to chrome://settings/extensions, expand the WebGL Inspector item and check "Allow access to file URLs".
Note: (outdated?) "readme.md" says:
You cannot inspect pages on file:// in WebKit (possible with security settings?)
You can also install a web server on your local PC to dispatch your page from a http:// url.

How to use chrome extension methods in my asp.net page?

I have page where RSS icon is present. I want that when user clicks on RSS icon it will check in chrome browser that, whether that RSS reader chrome extension is installed or not
I am trying to achieve this by using chrome extension methods, mentioned here.
I tried something like this but it is not working:
var port = chrome.extension.connect("nlbjncdgjeocebhnmkbbbdekmmmcbfjd");
To use this API you need to be either an extension or a web application having the necessary permissions - normal web pages cannot access it. However, detecting whether an extension is installed in Chrome is still easy:
<script src="chrome-extension://nlbjncdgjeocebhnmkbbbdekmmmcbfjd/manifest.json"
onload="alert('installed')" onerror="alert('not installed')"></script>
This uses the fact that the extension's manifest.json file is located under a predictable URL and that web pages are allowed to load this URL. Of course, this isn't an officially documented approach but rather a loophole and a privacy issue. So be prepared for it to stop working in some future Chrome version. At the moment it works however.

Is there any way to communicate between my .exe application and Firefox?

Is there any way to communicate between my .exe application and Firefox?
Because, I have my own webpage. I'm using FireFox to browse it.
I have an application (in c++) to process a piece of HTML code from my webpage within FireFox. My application can print something directly to printer (raw print).
Since now, I coudn't access firefox's DOM content (page HTML source) from outside firefox; Also, I coudn't print directly to printer (raw print) from firefox.
Now, I'm looking solution for this problem. Here are my possibilities:
1.) My web page I can copy my related text to clipboard.
2.) My web page I can write my related text to Firefox's cookie.
3.) My web page I can write my related text to a file from client's PC.
4.) Any other way to send my related text to my .exe application.
But I don't know how can I do:
How can I copy to clipboard within firefox,
How can I read FireFox's cookie from my .exe application,
How can I create file in client's PC.
Is there any way to communicate between my .exe application (in c++) and Firefox?
You have to write an extension for firefox an use its API. For example see nsIProcess:
"The nsIProcess interface represents an executable process."
Assuming that your page has a true URL outside of FireFox, you could solve your problem by registering a custom protocol handler. E.g. register "X-myprettyprinter". Then, in FireFox, from http://www.example.com/index.html you can redirect to X-myprettyprinter:http%2D%2Dwww.example.com/index.html. FireFox doesn't know how to handle the X-myprettyprinter protocol so it hands off the URL to the OS, which then hands it to your registered application. Bonus: it works for all browsers. Downside: you have to retrieve the URL yourself and render the page again in-process
You could write an addon for firefox that allowed some form of integration with your application.
Here is a tutorial on writing firefox addins.
The best way to do this is to skip the .exe application and just make an ad on for FireFox, Take a look at the FireBug ad-on. It can pull certain codes out of a web page, If you use the API I bet you could do what your .exe program should.