System

Overview

The purpose of this API is to allow extensions (e.g. ChromeVox) to handle a number of ChromeOS system events like login, wake-up from sleep and system update.

Use cases

There are two issues on crosbug.com that may require this API to be implemented.
There are two ways to solve these issues.
  1. Add C++ code to make audio notifications on wakeup and when an update is available.
  2. Add APIs to notify extensions about wake-up and available update.

I prefer 2. because handling events in extension’s JS code is more flexible and this kind of API may be useful for purposes other than accessibility.

Could this API be part of the web platform?

This is a client side feature, and doesn’t make much sense to add to HTML5

Do you expect this API to be fairly stable?

I’m not sure if this API is covering the all necessary system events.

What UI does this API expose?

No new UI is needed for this API.

How could this API be abused?

AFAIK, there is no security risk about this API.

How would you implement your desired features if this API didn’t exist?

Hard-coding event handler in C++ on Chromium tree as described above.

Are you willing and able to develop and maintain this API?

Yes.

Draft API spec

All APIs below will be implemented on ChromeOS platform only.
The namespace ‘experimental.system’ is intended to be used to contain system level methods and events.  The term ‘system level’ is to mean that those methods and events are not suitable to be handled by windows, tabs, omnibox or any other specific controls on the screen.  As the word ‘system’ suggests, this namespace is intended to contain Chromium’s core, low-level, OS-like features only.

Types

experimental.system.UpdateStatus

  • A type to represent the update status
  • Members
    • state
      • enumerated string: [“Available”, “Downloading”, “NeedReboot”]
    • progress
      • number: progress of dowload in %.  0 when state == ”Available”, 100 when state == “NeedReboot”

Methods

experimental.system.getUpdateStatus

  • A function to get the update status
  • Arguments
    • A callback function to receive the result (UpdateStatus) which looks like this

function(update_status) {

 // handling the result;

}

Events

experimental.system.onLoggedin

  • An event fired after a user logged in to the system
  • Arguments
    • An event handler function which takes no argument.

experimental.system.onWokeup

  • An event fired after the system wakes up from sleep
  • Arguments
    • An event handler function which takes no argument.


Open questions

Comments