I'm developing a chrome packaged app and chrome extension, both of them communicate with one another, and i want to lunch my packaged app from a chrome extension, is there any way to do it?
Note:
I've tried using the launchApp method of chrome management api, but for some unknown reason the chrome.management is undefined in my chrome extension JS code, although i have specified management permission in my manifest file like so:
"permissions": ["management"]
Does anyone have a idea what is the problem, or there are any other way i can do it ?
Thanks for help:)
There are 2 possible reasons for not being able to use chrome.management.
You have not reloaded your extension properly
You are trying to call this from a content script; you can't do that, since a content script has very restricted access to Chrome API. You need to message a background page to do this for you.
That said, there is a better way to do it if you write both your extension and your app. "management" permission is a big hammer and will generate a warning to the user on installation.
Instead, you can send a cross-extension message to your app. It will wake it up and you can launch your main window from there. See this answer for details.
Related
I searched all over and couldn't find my specific issue here so please excuse me if my search-fu has failed me.
My issue:
I am currently trying to create a kiosk app for my company's chromeboxes. I have the application packaged and published privately on the chrome web store. I get the app to load but once I launch the kiosk app and enter in my company's url I am presented with, "Unsupported Chrome App Origin Detected". The only thing I can find so far about this is to run the flag --disable-web-security. I can only find examples for Windows/Mac/Linux plus that isn't secure. Am I missing something in my Default.cr or manifest.json files? Is this even possible? This is on a vanilla chromebox that isn't part of a Google Apps domain. Do I need to have it added to a Google Apps for Work domain to get this to work? Any help would be appreciated.
Please add your generated chrome extension app id to storefront web.config file. Please have a look at http://docs.citrix.com/en-us/receiver/chrome/1-7/receiver-chrome-deploy.html point 8 at the end on how to do it.
Also please use 1.7 as it supports better Kiosk mode integration.
I'm interested in writing a Packaged App that can access data about chrome, namely the chrome.windows.onCreated and chrome.windows.onRemoved events. If I try to add a listener to either of these, I get an error in the console:
Uncaught TypeError: Cannot read property 'onRemoved' of undefined
Is there any way around this?
The other answers are correct that this isn't directly possible from a packaged app, but there is a solution that meets your needs: You can write an extension as well as a packaged app and have them communicate with chrome.runtime.sendMessage.
The user will have to install both app and extension, but you can make this easy by directing them to the chrome web store from within your application. You can read about this here: Communicating between a Chrome packaged app and a Chrome extension?
Edit: and as pointed out in a comment on that thread, there is a Chrome App Sample that helps demonstrate this in action: https://github.com/GoogleChrome/chrome-app-samples/tree/master/messaging
The chrome.windows API is a Chrome extension API, not a packaged apps API. It is used by extensions to interact with browser windows.
If you can write your application as an extension, it will be able to use that API. Packaged apps, however, don't have the ability to manipulate other windows besides their own.
One simple typo here: It is chrome.windows.onRemoved not chrome.windows.OnRemoved ;)
Note the lowercase o.
I am building a packaged chrome app (It is needed as I want to access chrome.socket). I have a website from which I would like to call my app (if installed or ask the user to install it) by clicking a link. Is this possible ? Not able to find any easy way for this workflow.
The url_handlers might be the best way to achieve this.
You can also use the externally_connectable manifest property to declare that your website can connect to your app, then call chrome.runtime.sendMessage or chrome.runtime.connect from your webpage and handle it in an chrome.runtime.onMessage handler in the app.
Which one is better suited depends on your needs. The url_handlers is an easier way, but it will permanently assign the URL on your link to your app, so you won't be able to use it for anything else if the app is installed. The externally_connectable is a harder way, but it enables a much more elaborate bidirectional communication between your website and the app.
You can even use a combination of the two approaches, if you need: launch the app using the url_handlers feature, then establish a communication channel back to the website once the app is up and running.
Apps can now (as of Chrome 31 I believe) register to handle urls by adding url_handlers in their manifest and detecting the url causing the app to launch in the chrome.app.runtime.onLaunched event. If the app doesn't launch, your hosted web site will be loaded an can present an inline installation with chrome.webstore.install.
I would like to create an extension or app for the Chrome browser which would require access to a user's Google Calender (for creating new appointments).
I am unsure of which technology to better research and use, Chrome extensions or apps. My "app" wouldn't need much of a GUI, so I'm leaning towards extension — but I don't know if this would pose any difficulties for accessing a user's Google Calender to add an event.
Anyone one have any idea which technology is best for this situation, and why? Thanks!
Either, or... Go with an extension if you'd like.
I assume you've looked at the API reference?
https://developers.google.com/google-apps/calendar/
From there, I'd imagine you'd just need OAuth to authenticate the user. Here's the JS library:
https://code.google.com/p/google-api-javascript-client/
There are pros/cons of each types, apps or extensions.
Apps
If you would like to create a client application of Google Calendar which has many rich GUI components, this type will become a better solution.
In addition, Chrome apps can communicate with many hardware devices and other servers. Of course, your Chrome app can become as a server (that is, your app can open a server socket and accept a request from other client apps).
Chrome apps can be executed not depending on your Chrome Web browser. That is, Chrome apps cannot access to a context of your Chrome Web browser.
Probably, you don't want to get the pros above, I guess...
Extensions
If you would like to create a small UI for posting your schedule to Google Calendar, this type will become a better solution.
In addition, Chrome extensions can access to a context of your Chrome Web browser. That is, your extension can get page contents of each tab and inject your CSS and/or JS code. For example, your extension will get a URL of some opened tab and include it in a body of the posted schedule.
Chrome extensions completely depend on your Chrome Web browser. That is, your extension cannot execute independently.
Also, generally, high cost will be needed to develop Chrome apps than Chrome extensions. As the result, you should choose Chrome extensions, I believe.
All of the examples I've seen show apps launching in their own windows. This may be great an all for chromebook/chrome os, but is there still an option to launch in a browser tab?
No, there is no way to do that. Chrome Packaged Apps are not supposed to run inside a browser. You can, however, open URLs in a browser tab using window.open. But you won't have control of that tab after you issue the command.
If you need some sort of integration/control between your Chrome Packaged App and the browser, you can create an extension and make a communication pipe between the extension and the app - as long as both are running, using the chrome.runtime.sendMessage API.
See this sample for a simple code that does exactly that (two apps and one extension exchanging messages directly, without any server component).
chrome.app.window.create will create a new Window for an App.
If you want window manipulation, you should switch to chrome.tabs API and look for an extension instead of an App.
Reference
chrome.tabs
chrome.app.window