الثلاثاء، 15 أكتوبر 2013

Connecting Chrome apps and extensions with native applications

القسم
We recently announced the deprecation of NPAPI plug-in support in Chrome. One of the main use cases for NPAPI plugins in Chrome apps and extensions was to connect with native applications installed on the same computer. For example, a native password management application that a user has already installed on the system may want to connect with a Chrome extension to synchronize passwords. To support such use cases without the need for NPAPI, we�ve recently added the Native Messaging API.



To use this API, native applications must register a native messaging host that Chrome apps and extensions can connect to. This is done by installing a special manifest file that defines a name and path to the native messaging host binary, as well as set of app and extension IDs that can connect to it. Once a native messaging host manifest is installed, Chrome apps and extensions can connect to it using simple API:

var port = chrome.extension.connectNative(          "org.chromium.native_messaging_example");

The parameter passed to chrome.extension.connectNative() is the name used to identify the native messaging host. When a native messaging port is created Chrome starts the host in a separate process and communicates with it over the standard input and output streams. The app or extension can send and receive messages from the native application using this simple API:

// Register handler for incoming messages. 
port.onMessage.addListener(function(msg) { 
   console.log("Received " + msg); 
 });

 // Send a message. 
port.postMessage({text: "Hello!"})

It's also possible to send one-off messages without creating a port:

chrome.extension.sendNativeMessage( 
   "org.chromium.native_messaging_example", 
   {messageField: "field value"}, 
   function(response) {
      console.log("Received response" + response); 
   });

For details on how to create and register a native messaging host please refer to the API documentation and check out our sample application, which also includes a simple native messaging host.

The Native Messaging API is available on Windows, OS X and Linux starting from Chrome 29. To learn about other NPAPI alternatives, check out the NPAPI deprecation Chromium wiki page.

Posted by Sergey Ulanov, Software Engineer and Message Dispatcher

الخميس، 3 أكتوبر 2013

Chrome 31 Beta: Android Application Shortcuts, requestAutocomplete(), and PNaCl

القسم
The developer updates in today�s Chrome Beta enable a seamless Android web app experience, smoother web payment flows, and portable native code in desktop Chrome. Unless otherwise noted, changes apply to desktop versions of Chrome and Chrome for Android.

Application shortcuts in Chrome for Android

Application shortcuts allow users to add website shortcuts to their Android home screen. Sites launched in this way will open in a normal Chrome for Android window, unless they include the mobile-web-app-capable meta tag. Those sites will instead open in a special fullscreen Chrome for Android window that doesn't display tabs, buttons, menus, or the Omnibox. Try adding a shortcut to weight.aerotwist.com to see this in action:



UPDATE, November 13th: Application shortcuts will now be launching in Chrome 32, not 31.

Payment requestAutocomplete() on Chrome for Android, Windows, Chrome OS

requestAutocomplete() makes it easier for users to fill out online forms by offering web developers programmatic access to the browser�s autocomplete information (with the user�s explicit permission).

For this first release, we�ve made it work for web payments. On sites with requestAutocomplete(), users will be able to either use their existing payment data stored with the browser or enter new details through a browser-provided interface. As a developer, you can continue processing payments with your existing payment processor.


This feature will be rolling out to Beta users in Android, Windows, and Chrome OS in the coming days. A Mac version will be included in a future release.

PNaCl on desktop versions of Chrome

Over the last few years, web applications have benefited tremendously from more powerful processors and faster browsers. For developers looking to improve performance even further, Portable Native Client (PNaCl) now offers the ability to execute native code in the browser. Developers can compile C/C++ code--even complex existing code bases--into a single executable that runs across all desktop versions of Chrome and Chrome OS, no user installation required. PNaCl combines the portability of the web with the performance of native code. For more information, check out gonacl.com.

New Chrome Apps APIs

With URL handlers for apps, Chrome App developers can now specify URLs to be handled by a Chrome App. For example, a document link on a website could open a document editor Chrome App. This gives users more seamless entry points into their favorite Chrome Apps.

Directory access for Apps allows Chrome Apps to access and write to user-approved folders. This feature can be used to share files between a Chrome App and a native app. For example, a Chrome App code editor could modify files managed by a native Git client. Check out the demo to see it in action.

Other new features in this release
Visit chromestatus.com for a complete overview of Chrome�s developer features, and circle +Google Chrome Developers for more frequent updates. We hope you enjoy this Beta release as much as we�ve enjoyed working on it!

Posted by Dan Alcantara, Software Engineer and Screen Real Estate Agent