Convert chrome.experimental.alarms API to use IDL.

BUG=81758
TEST=no

Review URL: https://chromiumcodereview.appspot.com/10066024

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@132492 0039d316-1c4b-4281-b951-d872f2087c98
parent 78e2fe93
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "chrome/browser/bookmarks/bookmark_extension_api.h" #include "chrome/browser/bookmarks/bookmark_extension_api.h"
#include "chrome/browser/bookmarks/bookmark_manager_extension_api.h" #include "chrome/browser/bookmarks/bookmark_manager_extension_api.h"
#include "chrome/browser/download/download_extension_api.h" #include "chrome/browser/download/download_extension_api.h"
#include "chrome/browser/extensions/api/alarms/alarms_api.h"
#include "chrome/browser/extensions/api/app/app_api.h" #include "chrome/browser/extensions/api/app/app_api.h"
#include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h" #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
#include "chrome/browser/extensions/api/declarative/declarative_api.h" #include "chrome/browser/extensions/api/declarative/declarative_api.h"
...@@ -89,13 +88,6 @@ void ExtensionFunctionRegistry::ResetFunctions() { ...@@ -89,13 +88,6 @@ void ExtensionFunctionRegistry::ResetFunctions() {
// Register all functions here. // Register all functions here.
// Alarms
RegisterFunction<extensions::AlarmsCreateFunction>();
RegisterFunction<extensions::AlarmsGetFunction>();
RegisterFunction<extensions::AlarmsGetAllFunction>();
RegisterFunction<extensions::AlarmsClearFunction>();
RegisterFunction<extensions::AlarmsClearAllFunction>();
// Windows // Windows
RegisterFunction<GetWindowFunction>(); RegisterFunction<GetWindowFunction>();
RegisterFunction<GetCurrentWindowFunction>(); RegisterFunction<GetCurrentWindowFunction>();
......
...@@ -19,13 +19,13 @@ ...@@ -19,13 +19,13 @@
'chromium_code': 1, 'chromium_code': 1,
'json_schema_files': [ 'json_schema_files': [
'browserAction.json', 'browserAction.json',
'experimental.alarms.json',
'experimental.declarative.json', 'experimental.declarative.json',
'permissions.json', 'permissions.json',
'tabs.json', 'tabs.json',
'windows.json', 'windows.json',
], ],
'idl_schema_files': [ 'idl_schema_files': [
'experimental.alarms.idl',
'experimental.bluetooth.idl', 'experimental.bluetooth.idl',
'experimental.dns.idl', 'experimental.dns.idl',
'experimental.serial.idl', 'experimental.serial.idl',
......
// 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.
// File-level comment to appease parser. Eventually this will not be necessary.
// TODO(mpcomplete): We need documentation before we can release this.
namespace experimental.alarms {
dictionary Alarm {
// Name of this alarm.
DOMString name;
// Original length of time in seconds after which the onAlarm event should
// fire.
// TODO: need minimum=0
long delayInSeconds;
// True if the alarm repeatedly fires at regular intervals, false if it
// only fires once.
boolean repeating;
};
// TODO(mpcomplete): rename to CreateInfo when http://crbug.com/123073 is
// fixed.
dictionary AlarmCreateInfo {
// Length of time in seconds after which the onAlarm event should fire.
// Note that granularity is not guaranteed: this value is more of a hint to
// the browser. For performance reasons, alarms may be delayed an arbitrary
// amount of time before firing.
// TODO: need minimum=0
long delayInSeconds;
// True if the alarm should repeatedly fire at regular intervals. Defaults
// to false.
boolean? repeating;
};
callback AlarmCallback = void (Alarm alarm);
callback AlarmListCallback = void (Alarm[] alarms);
interface Functions {
// Creates an alarm. After the delay is expired, the onAlarm event is
// fired. If there is another alarm with the same name (or no name if none
// is specified), it will be cancelled and replaced by this alarm.
// |name|: Optional name to identify this alarm. Defaults to the empty string.
static void create(optional DOMString name, AlarmCreateInfo alarmInfo);
// Retrieves details about the specified alarm.
// |name|: The name of the alarm to get. Defaults to the empty string.
static void get(optional DOMString name, AlarmCallback callback);
// Gets an array of all the alarms.
static void getAll(AlarmListCallback callback);
// Clears the alarm with the given name.
// |name|: The name of the alarm to clear. Defaults to the empty string.
static void clear(optional DOMString name);
// Clears all alarms.
static void clearAll();
};
interface Events {
// Fired when an alarm has expired. Useful for transient background pages.
// |name|: The name of the alarm that has expired.
static void onAlarm(optional DOMString name);
};
};
// 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.alarms",
"types": [
{
"id": "Alarm",
"type": "object",
"properties": {
"name": {"type": "string",
"description": "Name of this alarm."},
"delayInSeconds": {"type": "integer", "minimum": "0",
"description": "Original length of time in seconds after which the onAlarm event should fire."},
"repeating": {"type": "boolean",
"description": "True if the alarm repeatedly fires at regular intervals, false if it only fires once."}
}
}
],
"functions": [
{
"name": "create",
"type": "function",
"description": "Creates an alarm. After the delay is expired, the onAlarm event is fired. If there is another alarm with the same name (or no name if none is specified), it will be cancelled and replaced by this alarm.",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "Optional name to identify this alarm. Defaults to the empty string."
},
{
"type": "object",
"name": "alarmInfo",
"properties": {
"delayInSeconds": {"type": "integer", "minimum": "0",
"description": "Length of time in seconds after which the onAlarm event should fire. Note that granularity is not guaranteed: this value is more of a hint to the browser. For performance reasons, alarms may be delayed an arbitrary amount of time before firing."},
"repeating": {"type": "boolean", "optional": true,
"description": "True if the alarm should repeatedly fire at regular intervals. Defaults to false."}
}
}
]
},
{
"name": "get",
"type": "function",
"description": "Retrieves details about the specified alarm.",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "The name of the alarm to get. Defaults to the empty string."
},
{
"type": "function",
"name": "callback",
"parameters": [
{ "name": "alarm", "$ref": "Alarm" }
]
}
]
},
{
"name": "getAll",
"type": "function",
"description": "Gets an array of all the alarms.",
"parameters": [
{
"type": "function",
"name": "callback",
"parameters": [
{ "name": "alarms", "type": "array", "items": { "$ref": "Alarm" } }
]
}
]
},
{
"name": "clear",
"type": "function",
"description": "Clears the alarm with the given name.",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "The name of the alarm to clear. Defaults to the empty string."
}
]
},
{
"name": "clearAll",
"type": "function",
"description": "Clears all alarms.",
"parameters": []
}
],
"events": [
{
"name": "onAlarm",
"type": "function",
"description": "Fired when an alarm has expired. Useful for transient background pages.",
"parameters": [
{
"type": "string",
"name": "name",
"optional": true,
"description": "The name of the alarm that has expired."
}
]
}
]
}
]
...@@ -275,8 +275,6 @@ void ExtensionAPI::InitDefaultConfiguration() { ...@@ -275,8 +275,6 @@ void ExtensionAPI::InitDefaultConfiguration() {
IDR_EXTENSION_API_JSON_DEVTOOLS)); IDR_EXTENSION_API_JSON_DEVTOOLS));
RegisterSchema("experimental.accessibility", ReadFromResource( RegisterSchema("experimental.accessibility", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY)); IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY));
RegisterSchema("experimental.alarms", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_ALARMS));
RegisterSchema("experimental.app", ReadFromResource( RegisterSchema("experimental.app", ReadFromResource(
IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP)); IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP));
RegisterSchema("experimental.bookmarkManager", ReadFromResource( RegisterSchema("experimental.bookmarkManager", ReadFromResource(
......
...@@ -31,7 +31,6 @@ var MODULE_SCHEMAS = [ ...@@ -31,7 +31,6 @@ var MODULE_SCHEMAS = [
'../api/debugger.json', '../api/debugger.json',
'../api/devtools.json', '../api/devtools.json',
'../api/experimental.accessibility.json', '../api/experimental.accessibility.json',
'../api/experimental.alarms.json',
'../api/experimental.app.json', '../api/experimental.app.json',
'../api/experimental.bookmarkManager.json', '../api/experimental.bookmarkManager.json',
'../api/experimental.downloads.json', '../api/experimental.downloads.json',
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
<include name="IDR_EXTENSION_API_JSON_DEVTOOLS" file="extensions\api\devtools.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_DEVTOOLS" file="extensions\api\devtools.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental.accessibility.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ACCESSIBILITY" file="extensions\api\experimental.accessibility.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental.app.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_APP" file="extensions\api\experimental.app.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_ALARMS" file="extensions\api\experimental.alarms.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER" file="extensions\api\experimental.bookmarkManager.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_BOOKMARKMANAGER" file="extensions\api\experimental.bookmarkManager.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DECLARATIVE" file="extensions\api\experimental.declarative.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DECLARATIVE" file="extensions\api\experimental.declarative.json" type="BINDATA" />
<include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DOWNLOADS" file="extensions\api\experimental.downloads.json" type="BINDATA" /> <include name="IDR_EXTENSION_API_JSON_EXPERIMENTAL_DOWNLOADS" file="extensions\api\experimental.downloads.json" type="BINDATA" />
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment