Can you still create a Chrome packaged app in the browser with manifest 2.0? - google-chrome

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

Related

Is there a way to launch chrome packaged app from chrome extension

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.

Chrome Packaged App Access Chrome APIs

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.

Interacting with firefox using an external program

I am looking for a way to interact with a web page and enter data to certain fields in it using an external program that interact with Firefox (or Chromium) web browser. The best I could find is the console commands for the browser, but they only let you go to a certain URL and not interact with the pages' content. I have also tried looking for some extension to do the job but I could not find any. Any suggestions?
You could create Chrome extension that communicates with your application via Chrome Native Messaging API: https://developer.chrome.com/extensions/messaging.html#native-messaging
Take a look at Selenium and the tools mentioned at Selenium alternatives?.

Assign tray icon to Google Chrome web application

I need to create a web application which will be stored in the traybar of Windows, this to prevent users from accidentally close my application (without the need of a pre-close alert message).
I thought that Google Chrome's background apps could be the right way to go, mostly because I don't need cross-browser compatibility and I have to choose which browser my users will use to run this web application.
The only problem is that I don't understand if I can achieve what I need with this feature.
I've found only this example of background app in Chrome countdown app
But this app uses the "background page" feature, that is different from what I'm looking for.
How can I let a Chrome app be minimized in the traybar (or even in the taskbar would be ok) instead of be closed?
Try to use node-webkit (chromium + node.js) for it: https://github.com/rogerwang/node-webkit
It allow to create any web-app and it support tray icons: https://github.com/rogerwang/node-webkit/wiki/Tray
You can download my windows example app here: https://mega.co.nz/#!xQMzgbxD!S58G-V23QLNRDFC10xso41-T2V8OZQVsQEH-lr46R3s
If you want exactly chrome, try this NPAPI plugin example: http://minimizetotray.googlecode.com/files/SourceCode.zip from http://habrahabr.ru/post/73003/
Unfortunately, I don't think you will be able to achieve exactly what you're after. You might be able to combine the two solutions below to nearly achieve your requirements. However, I don't think the type of control you are after is available via Google Apps.
Google App Launcher
The Google App Launcher would fulfill the "stored in the traybar of Windows" requirement.
The Chrome App Launcher is the hub of all your Chrome apps and with it
you have quick access to all of your apps from the desktop. When you
install an app from the "For Your Desktop" collection of the Chrome
Web Store, you get the App Launcher. The App Launcher requires you to
sign in to Chrome to enable apps that need access to your Google
account.
Manage apps
When you download a new app that enables App Launcher, the apps from
your Apps bookmark on Chrome New Tab page will also appear in the App
Launcher. Managing apps in the App Launcher is simple.
Add more apps: Click the Chrome Web Store button in your apps list and explore the apps in the store.
...
Background: Extending Your App's Life
You mentioned background apps in your question but I would recommend you explore it further. It essentially provides the "prevent users from accidentally close my application" requirement that you stated. This isn't foolproof (see bold sentence below) but it is about as close to the requirement I think you will be able to achieve.
As of Google Chrome 10, the background feature lets a hosted app run
as soon as the user logs into their computer—before the user launches
Chrome or the app—and to continue running even when Chrome or the app
has no visible windows. However, if the user explicitly quits Chrome,
the browser and app both exit.

Chrome extension or chrome app?

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.