Is there a solution to get desktop active application name from a chrome extension? - google-chrome-extension

I would need the list of currently opened desktop apps (+ files opened in it) from a Chrome Extension, or at least the active application name (With current focus on the desktop).
Use case : Imagine a chrome extension that would get the list of tabs with URLS (I solved it with Chrome.tabs) and in addition would give the name of the current active app when Chrome loose the focus (idle) : exemple => powerpoint.app / documentname.ppt.
I'm looking for any option, ideally without having to implement a Desktop App that would exchange messages with the Extension. But if this is the only way, any example/experience to do so with Electron (http://electron.atom.io/) or Node-WebKit?

This may be possible in an electron app, but I don't think so as Electron is more multiplatform-oriented and this is a platform-oriented feature. You only will have access to methods that the developers chose to expose to you, and I doubt that they exposed a way to have this kind of information. (I have very little knowledge in the tech since I used it only once, so I might be wrong).
The only solution I see is the one you talked about in your question, a real desktop app messaging with the chrome extension.

Related

Chrome Extension Native Messaging with same extension installed across multiple chrome profiles

This feels like a shot in the dark but...
Should a single Native Messaging host be able to communicate with the same extension installed on multiple chrome profiles?
I'm working on an extension which is installed to both my personal and work profiles. But it seems that the Native Messaging host only sends messages to the most recently connected instance of the extension.
I don't believe this is addressed in the Native Messaging documentation and I've run out of search ideas, thanks in advance for any help!
When nativeMessaging API is used it starts an instance of native app each time a connection is created by the extension so such an instance can communicate with its "parent" extension only. Consequently, there should be no problem.
In case you want to use chrome.runtime.onConnectNative to do the reverse (to connect from a native app to an extension which will work even when Chrome is closed) see crbug.com/967262 for more info or create a new issue there asking for details. Judging by the bits I see this feature is available only on ChromeOS and it's even disabled by default.

Chrome extension to change Desktop wallpaper

I'm diving into the world of Chrome Extension development, primarily because there is a very small feature that is missing in Chrome that I miss dearly. The context-menu option to "Set as background/wallpaper" like that found in Firefox. Sounds trivial, but it's convenient.
I have most of the "basic" stuff worked out with the manifest file, am able to install it, even managed to get it to show up as a context menu item.
The problem obviously is that I am wanting to mess with a user's OS-level settings which is extremely difficult because of security issues (fully understand this).
I found an extension that allowed this in older versions of Chrome, and it looked like the developer used some type of .dll and C++ to accomplish this.
I'm not really sure how to make this work.
Since that Chrome doesn't allow these kind of manipulations (such as your PC's settings), you will need to create a native application that will run beside your extension. When the user chooses the image from your extension and selects "use as wallpaper", you will use the native messaging API to send a message to your desktop application, that will set the wallpaper (and do whatever else you can't do within a chrome extension) for you.
You can use the chrome.wallpaper app api to set the wallpaper after using the messaging api to send the image from your extension.

Can a Chrome extension launch new Chrome windows under different user profiles?

Is there an API for a Chrome extension to launch and control new Chrome windows under different user profiles?
My understanding is that while an extension may be run under multiple user profiles simultaneously, these instances are isolated; they cannot communicate directly and an extension in one profile cannot access the windows/tabs/processes/etc of another profile. Is this the case?
It seems like the best way to launch and control Chrome windows under multiple profiles is to use an approach based on the Remote Debugger API such as the ChromeDriver project.
For context, I'm interested in writing a tool to manage and launch predefined "bundles" of multiple Chrome windows, each with different URLs and screen positions, and each under a different profiles. The attached screenshot shows an example desired state: three browsers, each in a separate profile, each at a different URL, with different devtools states, organized in a specific screen layout. It is conceptually similar to tmuxinator.
If I wanted to provide a Chrome-based UI for designing and managing these presaved layouts, it seems that I would need to provide a native shim that invokes new Chromes via chromedriver, and communicate with them via native messaging. Is there a more direct API that I am missing?
It seems that the proposed Profile Extension API would do exactly what I'm interested in, but I don't see any discussion on the apps-dev#chromium.org list.
If chrome allowed this it would be a huge security hole.
Chrome extensions are installed per user account so they shouldnt be able to see anything from other accounts.

Global(system) hotkeys for chrome extension

Is it possible to create system hotkeys/shortcuts for Google Chrome Extension? I mean hotkeys that also works when Chrome doesn't have focus.
Yes, but it won't be trivial. To get truly global hotkeys you will have to use native messaging. You will need to create some application to run in the background and capture keypresses and then you can send those keypresses back to Chrome through stdout. This approach will require you to create an additional installer for your extension to install the native messaging app onto the user's system...before you could bundle your app along with the extension (using NPAPI) but that has recently been phased out. I have seen some discussion in the Chromium group about adding bundling support for native messaging apps, but nothing has been added (yet).
Another much easier option is to use the Chrome commands API which will enable you to use hotkeys across all Chrome windows (but not globally...). Just something to consider if "true" global hotkeys are not an absolute requirement since this approach is (much) less complex.
Global media keys will be added to Chrome soon, however. There is a good discussion about this feature to read here.
It's now part of Chrome: chrome://extensions/shortcuts

Tabs/Windows in Chrome apps

It appears that chrome apps are unable to render as tabs in the browser... I happen to like the chrome tabbing interface and it would be a shame to have to try and re-implement it in html/css/js. Is there really no way to do tab management at the chrome application level? Must all new windows be shell/panel level windows?
I can imagine scenarios for applications where they would want to contribute extension related features to the browser... why are you making it more confusing for users (who now have to install an app and an extension) in order to get the full feature set?
Is there really no room for middle-ground here?
Chrome apps are separate from the browser. This is a very deliberate approach, which is unlikely to change.
For apps to be seen as apps, as opposed to websites, which are always available regardless of connectivity, they need to be seen as separate to a browser. We have found having apps launched and run outside the browser very important for users to conceptualize them as apps.
There are also security reasons to keep apps out of the browser. They have access to APIs that websites and extensions do not have access to, but to make this possible they are also individually sandboxed and have no access to the browser.
Extensions and apps can communicate via messages. It is less than ideal that a user may need to install both an app and an extension; we have been looking at some form of bundling to make this simpler.

Resources