diff options
author | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 17:54:02 +0000 |
---|---|---|
committer | rkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-09-15 17:54:02 +0000 |
commit | 93dd01d95619de7632ae75a921fd8e46e8db3916 (patch) | |
tree | dd18c2f392bd5034980a37e5dbdb58eb9c0edc55 /chrome/common | |
parent | d1ba7778c90beb82c227f2504be633e6d625dc19 (diff) | |
download | chromium_src-93dd01d95619de7632ae75a921fd8e46e8db3916.zip chromium_src-93dd01d95619de7632ae75a921fd8e46e8db3916.tar.gz chromium_src-93dd01d95619de7632ae75a921fd8e46e8db3916.tar.bz2 |
Add the power interface extension API.
This CL adds the power interface extension API. The API is experimental and is accessible via the chrome.experimental.power.x interface.
The API proposal is available on the API proposals page at http://dev.chromium.org/developers/design-documents/extensions/proposed-changes/apis-under-development
The implementation of the API uses user preferences to store the keep_awake requests for a user. This makes the API specific to a user and persistent between logins. Currently we're leaving the preference unsync'able to keep them local to the machine the extension is installed on.
R=satorux@chromium.org,derat@chromium.org,aa@chromium.org
BUG=146939
TEST=Ran an extension to call requestKeepAwake and cancelKeepAwake to verify that the system power management changes accordingly.
Review URL: https://chromiumcodereview.appspot.com/10919270
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@157010 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/extensions/api/experimental_power.json | 49 | ||||
-rw-r--r-- | chrome/common/extensions/api/extension_api.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions_api_resources.grd | 1 |
3 files changed, 52 insertions, 0 deletions
diff --git a/chrome/common/extensions/api/experimental_power.json b/chrome/common/extensions/api/experimental_power.json new file mode 100644 index 0000000..8f3ac0b --- /dev/null +++ b/chrome/common/extensions/api/experimental_power.json @@ -0,0 +1,49 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. +[ + { + "namespace": "experimental.power", + "types": [], + "functions": [ + { + "name": "requestKeepAwake", + "type": "function", + "description": "Requests that the machine be kept awake. Requests can be canceled manually with releaseKeepAwake, and are automatically canceled when the machine is restarted, or when the extension is disabled or uninstalled. Calling this multiple times has the same effect as calling it once.", + "parameters": [ + { + "name": "callback", + "type": "function", + "optional": true, + "parameters": [ + { + "name": "success", + "type": "boolean", + "description": "True if the request was successful, false otherwise." + } + ] + } + ] + }, + { + "name": "releaseKeepAwake", + "type": "function", + "description": "Releases a keep awake request. Once there are no keep awake requests active on the system, normal power management will resume.", + "parameters": [ + { + "name": "callback", + "type": "function", + "optional": true, + "parameters": [ + { + "name": "success", + "type": "boolean", + "description": "True if the release was successful, false otherwise." + } + ] + } + ] + } + ] + } +] diff --git a/chrome/common/extensions/api/extension_api.cc b/chrome/common/extensions/api/extension_api.cc index 0361063..56879bd 100644 --- a/chrome/common/extensions/api/extension_api.cc +++ b/chrome/common/extensions/api/extension_api.cc @@ -382,6 +382,8 @@ void ExtensionAPI::InitDefaultConfiguration() { IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD)); RegisterSchema("experimental.offscreenTabs", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_OFFSCREENTABS)); + RegisterSchema("experimental.power", ReadFromResource( + IDR_EXTENSION_API_JSON_EXPERIMENTAL_POWER)); RegisterSchema("experimental.processes", ReadFromResource( IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES)); RegisterSchema("experimental.record", ReadFromResource( diff --git a/chrome/common/extensions_api_resources.grd b/chrome/common/extensions_api_resources.grd index 23c83de..3cdfe8f 100644 --- a/chrome/common/extensions_api_resources.grd +++ b/chrome/common/extensions_api_resources.grd @@ -30,6 +30,7 @@ <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INFOBARS" file="extensions\api\experimental_infobars.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_INPUT_VIRTUALKEYBOARD" file="extensions\api\experimental_input_virtual_keyboard.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_OFFSCREENTABS" file="extensions\api\experimental_offscreen_tabs.json" type="BINDATA" /> + <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_POWER" file="extensions\api\experimental_power.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_PROCESSES" file="extensions\api\experimental_processes.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RECORD" file="extensions\api\experimental_record.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_RLZ" file="extensions\api\experimental_rlz.json" type="BINDATA" /> |