Add initial support for application Event object

An application event is an event send to application and will be handled by main
document. An system event is event sent by the system and can wake up a
terminated application. They're different from normal DOM event which originated
from the DOM element. The application event API will provides an interface to
add/remove listeners which will be called when such event happens. Please note
that only when a system event adds hanlers from main document it can launch
a terminated application.

Currently the application Event object support is an implementation of
chrome.events.Event API(https://developer.chrome.com/apps/events.html) subset.
Event.addListener, Event.removeListener, Event.hasListener and
Event.hasListeners APIs are supported.
Check if it is the main document
fix build issue
Event manager side change
need run message loop when install.