I have published a native messaging add-on on Mozilla, but the native messaging host (native app) runs only once, if I restart firefox, the native app does not start.
Here is the scenario:
Step 1: I install the native app on Windows 10 using the setup file, the setup also configures the registry key under
HKEY_CURRENT_USER\Software\Mozilla\NativeMessagingHosts
HKEY_LOCAL_MACHINE\Software\Mozilla\NativeMessagingHosts\
Step 2: Start firefox, download and install the public released (signed) add-on from mozilla. The add-on icon shows on Firefox, I click the icon, the add-on popup page shows, click the menu items on the popup, the add-on works as expected, the native app works too, it receives messages from add-on, and sends messages back to the add-on.
All is OK, it seems the native messaging add-on works well. However, after I restart firefox, click the add-on icon, click the menu items on the popup menu, nothing happens. I type about:debugging, in the console window, there is error message "Unchecked lastError value: Error: port is null".
This error only happens while using the signed add-on, using local version un-signed addon, the native messaging host and add-on always run, no such problem.
I want to know, when download and install the addon from Mozilla, except the addon's XPI file, are there other files also downloaded? Maybe these other files run after firefox restarts, and these files or their configuration prevent the native app from running.
Here is the code snippet in background page:
function connectToNativeHost()
{
var nativeHostName = “com.some-company.test”;
port = chrome.runtime.connectNative(nativeHostName);
console.log(port)
port.onMessage.addListener(onNativeMessage);
port.onDisconnect.addListener(onDisconnected);
}
function onDisconnected()
{
console.log(chrome.runtime.lastError);
console.log(‘disconnected from native app.’);
port = null;
}
I test again and again, I find that after firefox restarts, the native app never runs again, firefox does not create a process for the native app.
Thank you for your help!
Related
JetBrains IntelliJ IDEA sometimes loses its own JetBrains IDE Support plugin in Chrome. Upon debugging in IDEA, Chrome complains that:
hmhgeddbohgjknpmjagkdomcpobmllji is blocked
Requests to the server have been blocked by an extension
and stays on this page:
chrome-extension://hmhgeddbohgjknpmjagkdomcpobmllji/loading.html?__QUERY__
Where hmhgeddbohgjknpmjagkdomcpobmllji is JetBrains' plugin ID.
Instead of redirecting to the target page of the form:
http://localhost:63342/__PROJECT__/__PATH__/index.html
Restarting Google Chrome or disabling-and-enabling IDE Support plugin helps. IDEA "finds" Chrome again and Debug workflow works as intended.
Another possible problem is a failed authorization.
To debug a URL like this:
http://localhost:63342/__PROJECT__/__PATH__/index.html
Open it in the browser before starting to debug. It'll give 404 Not Found. Then switch back to IDEA and it will offer you to Copy authorization URL to clipboard:
http://localhost:63342/__PROJECT__/__PATH__/index.html?_ijt=__KEY__
Open this URL.
After this manual authentication is complete, IntelliJ IDEA should be able to debug index.html in Chrome.
IDEA always opens index.html for debugging in the browser window where the latest authentication happened. E.g., in a Chrome Incognito window, instead of a Chrome "normal" window, if you've just authorized IDEA in Incognito.
Going incognito may require an additional setup:
https://intellij-support.jetbrains.com/hc/en-us/community/posts/206201319-launching-chrome-incognito-in-intellij-12
Is it possible to launch a Chrome app without having the Chrome Browser appear?
In other words can the browser run in the background and launch a chrome application?
Yes, if the app creates its own window then just run it from the Chrome app launcher or make the shortcuts on desktop / startmenu / taskbar: open chrome://apps/ page (it can be opened from the new tab page), right-click the app, click Create shortcuts.
To run the app using command line use the app ID (to get it first create a shortcut as described above and simply copy the command line from the shortcut's parameters, or you can copy it from the webstore page of the app), here's a Windows command line using start which automatically finds the installed Chrome executable:
start chrome --app-id=pelimflkpjiicnajdjcmekpioacmahkh
P.S. The app must be installed in the browser.
I developed a app and extension, the extension should add some special headers in order to know if the user has our extension installed and verify some security issues.
Users install our app through our server in a wizard, firstly install the extension and later the app.
Before Google Chrome 45 when a user launch our app the server detect the headers (added by the extension) , validate the user and redirect to a client page. After update
Google Chrome (v45), the headers are ignored and never sent with the request.
Only when uninstall the application the extension works and add all required headers, if install the app again, then the extension stop working.
Debugging into this, I see, if the url of app and the url patterns to modify the headers match, Google Chrome ignore the changes done by the extension.
Is possible modify header of our app using our extension?.. is a bug or is required add some new permissions?
It's a bug; sorry, I could not reply earlier since it's a result of a security fix that was not public before.
This is expected to be fixed at least in Chrome 46, but probably will be ported back to 45 since this prompted much public outrage.
I am developing a chrome packaged app. As part of the app i need to know, when user uninstalled the app. I could not find any method as part of the API,to read such a event when it happens. In extensions we have chrome.management api to do this, but chrome packaged app doesn't have this permission. Any help would be highly appreciated.
Try using chrome.runtime.setUninstallURL, this allows you to set a URL which is loaded as soon as the App is removed from Chrome. It does not require any additional permissions.
If I want to install the Chrome App Launcher and navigate to https://chrome.google.com/webstore/launcher , then click the only button over there, that page will install Chrome App Launcher shortcut to my Windows taskbar without any confirmation from the operating system whatsoever.
If I use a different browser, other than Chrome, I get redirected to the Chrome Webstore, with a message "You will need Google Chrome to install most apps, extensions and themes." showing. I guess, Chrome is able to place a shortcut from within a web page to my Desktop/Taskbar via its inner methods, as it's a general executable and may do "a lot" on its own.
How can I add my (any) shortcut from within a web page rendered in Chrome the same (or another) way the Chrome App Launcher has been installed?
Sorry, the webstore has special powers in chrome which regular web sites don't get. This is how it can also install extensions and apps, see whether you have particular extensions and apps installed, etc. You can see API by which it gets these special privileges here.
This API is made available by chrome just to the webstore.