Commit d01af7ce authored by jianli's avatar jianli Committed by Commit bot

Add the IDL for chrome.instanceID API.

It is not implemented yet. So all InstanceID***Functions are just placeholders.

BUG=477084
TEST=none

Review URL: https://codereview.chromium.org/1088593004

Cr-Commit-Position: refs/heads/master@{#326909}
parent c6251de7
fgorski@chromium.org
jianli@chromium.org
\ No newline at end of file
// Copyright 2015 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.
#include "chrome/browser/extensions/api/instance_id/instance_id_api.h"
#include "base/logging.h"
#include "extensions/common/extension.h"
namespace extensions {
InstanceIDGetIDFunction::InstanceIDGetIDFunction() {}
InstanceIDGetIDFunction::~InstanceIDGetIDFunction() {}
ExtensionFunction::ResponseAction InstanceIDGetIDFunction::Run() {
NOTIMPLEMENTED();
return RespondLater();
}
InstanceIDGetCreationTimeFunction::InstanceIDGetCreationTimeFunction() {}
InstanceIDGetCreationTimeFunction::~InstanceIDGetCreationTimeFunction() {}
ExtensionFunction::ResponseAction InstanceIDGetCreationTimeFunction::Run() {
NOTIMPLEMENTED();
return RespondLater();
}
InstanceIDGetTokenFunction::InstanceIDGetTokenFunction() {}
InstanceIDGetTokenFunction::~InstanceIDGetTokenFunction() {}
ExtensionFunction::ResponseAction InstanceIDGetTokenFunction::Run() {
NOTIMPLEMENTED();
return RespondLater();
}
InstanceIDDeleteTokenFunction::InstanceIDDeleteTokenFunction() {}
InstanceIDDeleteTokenFunction::~InstanceIDDeleteTokenFunction() {}
ExtensionFunction::ResponseAction InstanceIDDeleteTokenFunction::Run() {
NOTIMPLEMENTED();
return RespondLater();
}
InstanceIDDeleteIDFunction::InstanceIDDeleteIDFunction() {}
InstanceIDDeleteIDFunction::~InstanceIDDeleteIDFunction() {}
ExtensionFunction::ResponseAction InstanceIDDeleteIDFunction::Run() {
NOTIMPLEMENTED();
return RespondLater();
}
} // namespace extensions
// Copyright 2015 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.
#ifndef CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
#define CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
#include "extensions/browser/extension_function.h"
class Profile;
namespace extensions {
class InstanceIDGetIDFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("instanceID.getID", INSTANCEID_GETID);
InstanceIDGetIDFunction();
protected:
~InstanceIDGetIDFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
};
class InstanceIDGetCreationTimeFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("instanceID.getCreationTime",
INSTANCEID_GETCREATIONTIME);
InstanceIDGetCreationTimeFunction();
protected:
~InstanceIDGetCreationTimeFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
};
class InstanceIDGetTokenFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("instanceID.getToken", INSTANCEID_GETTOKEN);
InstanceIDGetTokenFunction();
protected:
~InstanceIDGetTokenFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
};
class InstanceIDDeleteTokenFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("instanceID.DeleteToken", INSTANCEID_DELETETOKEN);
InstanceIDDeleteTokenFunction();
protected:
~InstanceIDDeleteTokenFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
};
class InstanceIDDeleteIDFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("instanceID.deleteID",
INSTANCEID_DELETEID);
InstanceIDDeleteIDFunction();
protected:
~InstanceIDDeleteIDFunction() override;
// ExtensionFunction:
ResponseAction Run() override;
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_INSTANCE_ID_INSTANCE_ID_API_H_
...@@ -305,6 +305,8 @@ ...@@ -305,6 +305,8 @@
'browser/extensions/api/image_writer_private/write_from_url_operation.h', 'browser/extensions/api/image_writer_private/write_from_url_operation.h',
'browser/extensions/api/inline_install_private/inline_install_private_api.cc', 'browser/extensions/api/inline_install_private/inline_install_private_api.cc',
'browser/extensions/api/inline_install_private/inline_install_private_api.h', 'browser/extensions/api/inline_install_private/inline_install_private_api.h',
'browser/extensions/api/instance_id/instance_id_api.cc',
'browser/extensions/api/instance_id/instance_id_api.h',
'browser/extensions/api/launcher_page/launcher_page_api.cc', 'browser/extensions/api/launcher_page/launcher_page_api.cc',
'browser/extensions/api/launcher_page/launcher_page_api.h', 'browser/extensions/api/launcher_page/launcher_page_api.h',
'browser/extensions/api/location/location_api.cc', 'browser/extensions/api/location/location_api.cc',
......
...@@ -507,6 +507,10 @@ ...@@ -507,6 +507,10 @@
"dependencies": ["permission:inputMethodPrivate"], "dependencies": ["permission:inputMethodPrivate"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
}, },
"instanceID": {
"dependencies": ["permission:gcm"],
"contexts": ["blessed_extension"]
},
"launcherPage": { "launcherPage": {
"dependencies": ["manifest:launcher_page"], "dependencies": ["manifest:launcher_page"],
"contexts": ["blessed_extension"] "contexts": ["blessed_extension"]
......
// Copyright 2015 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.
// Use the <code>chrome.instanceID</code> API to access the InstanceID service.
namespace instanceID {
// Parameters for getToken.
dictionary GetTokenParams {
// Identifies the entity that is authorized to access resources associated
// with this Instance ID. It can be another Instance ID or a project ID.
DOMString audience;
// Identifies authorized actions that the authorized entity can take.
// E.g. for sending GCM messages, <code>GCM</code> scope should be used.
DOMString scope;
// Allows including a small number of string key/value pairs that will be
// associated with the token and may be used in processing the request.
object? options;
};
// Parameters for deleteToken.
dictionary DeleteTokenParams {
// The audience that is passed for obtaining a token.
DOMString audience;
// The scope that is passed for obtaining a token.
DOMString scope;
};
// |instanceID| : The Instance ID assigned to the app.
callback GetIDCallback = void(DOMString instanceID);
// |creationTime| : The time when the Instance ID has been generated,
// represented in milliseconds since the epoch.
callback GetCreationTimeCallback = void(long creationTime);
// |token| : The token assigned by the requested service.
callback GetTokenCallback = void(DOMString token);
callback DeleteIDCallback = void();
callback DeleteTokenCallback = void();
interface Functions {
// Retrieves an identifier for the app instance. The instance ID will be
// returned by the <code>callback</code>.
// The same ID will be returned as long as the application identity has not
// been revoked or expired.
// |callback| : Function called when the retrieval completes. It should
// check $(ref:runtime.lastError) for error when instanceID is empty.
static void getID(GetIDCallback callback);
// Retrieves the time when the InstanceID has been generated. The creation
// time will be returned by the <code>callback</code>.
// |callback| : Function called when the retrieval completes. It should
// check $(ref:runtime.lastError) for error when creationTime is zero.
static void getCreationTime(GetCreationTimeCallback callback);
// Return a token that allows the identified audience to access the service
// defined as scope.
// |getTokenParams| : getToken parameters.
// |callback| : Function called when the retrieval completes. It should
// check $(ref:runtime.lastError) for error when token is empty.
static void getToken(GetTokenParams getTokenParams,
GetTokenCallback callback);
// Revokes a granted token.
// |deleteTokenParams| : deleteToken parameters.
// |callback| : Function called when the deletion completes. The token
// was revoked successfully if $(ref:runtime.lastError) is not set.
static void deleteToken(DeleteTokenParams deleteTokenParams,
DeleteTokenCallback callback);
// Resets the app instance identifier and revokes all tokens associated with
// it.
// |callback| : Function called when the deletion completes. The instance
// identifier was revoked successfully if $(ref:runtime.lastError) is
// not set.
static void deleteID(DeleteIDCallback callback);
};
interface Events {
// Fired when all the granted tokens need to be refreshed. The Instance ID
// also needs to be refreshed when updateID is set to true.
// |updateID| : Instance ID also needs to be refreshed.
static void onTokenRefresh(boolean updateID);
};
};
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
'identity_private.idl', 'identity_private.idl',
'image_writer_private.idl', 'image_writer_private.idl',
'inline_install_private.idl', 'inline_install_private.idl',
'instance_id.idl',
'launcher_page.idl', 'launcher_page.idl',
'location.idl', 'location.idl',
'manifest_types.json', 'manifest_types.json',
......
{{+partials.standard_apps_api api:apis.apps.instanceID/}}
{{+partials.standard_extensions_api api:apis.extensions.instanceID/}}
...@@ -1077,6 +1077,11 @@ enum HistogramValue { ...@@ -1077,6 +1077,11 @@ enum HistogramValue {
AUTOFILLPRIVATE_REMOVEENTRY, AUTOFILLPRIVATE_REMOVEENTRY,
AUTOFILLPRIVATE_VALIDATEPHONENUMBERS, AUTOFILLPRIVATE_VALIDATEPHONENUMBERS,
AUTOFILLPRIVATE_MASKCREDITCARD, AUTOFILLPRIVATE_MASKCREDITCARD,
INSTANCEID_GETID,
INSTANCEID_GETCREATIONTIME,
INSTANCEID_GETTOKEN,
INSTANCEID_DELETETOKEN,
INSTANCEID_DELETEID,
// Last entry: Add new entries above and ensure to update // Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms.xml. // tools/metrics/histograms/histograms.xml.
ENUM_BOUNDARY ENUM_BOUNDARY
......
...@@ -51311,6 +51311,11 @@ Therefore, the affected-histogram name has to have at least one dot in it. ...@@ -51311,6 +51311,11 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<int value="1016" label="AUTOFILLPRIVATE_REMOVEENTRY"/> <int value="1016" label="AUTOFILLPRIVATE_REMOVEENTRY"/>
<int value="1017" label="AUTOFILLPRIVATE_VALIDATEPHONENUMBERS"/> <int value="1017" label="AUTOFILLPRIVATE_VALIDATEPHONENUMBERS"/>
<int value="1018" label="AUTOFILLPRIVATE_MASKCREDITCARD"/> <int value="1018" label="AUTOFILLPRIVATE_MASKCREDITCARD"/>
<int value="1019" label="INSTANCEID_GETID"/>
<int value="1020" label="INSTANCEID_GETCREATIONTIME"/>
<int value="1021" label="INSTANCEID_GETTOKEN"/>
<int value="1022" label="INSTANCEID_DELETETOKEN"/>
<int value="1023" label="INSTANCEID_DELETEID"/>
</enum> </enum>
<enum name="ExtensionInstallCause" type="int"> <enum name="ExtensionInstallCause" type="int">
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