summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjianli <jianli@chromium.org>2015-04-24 15:31:28 -0700
committerCommit bot <commit-bot@chromium.org>2015-04-24 22:32:27 +0000
commitd01af7ce4d760cc647964d835505bbe2df7be8b8 (patch)
tree944e0b70ca3e7b93d7f8287552df2c1b615ebbc7
parentc6251de745752206d7a57d2f1674fd706574a436 (diff)
downloadchromium_src-d01af7ce4d760cc647964d835505bbe2df7be8b8.zip
chromium_src-d01af7ce4d760cc647964d835505bbe2df7be8b8.tar.gz
chromium_src-d01af7ce4d760cc647964d835505bbe2df7be8b8.tar.bz2
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}
-rw-r--r--chrome/browser/extensions/api/instance_id/OWNERS2
-rw-r--r--chrome/browser/extensions/api/instance_id/instance_id_api.cc57
-rw-r--r--chrome/browser/extensions/api/instance_id/instance_id_api.h83
-rw-r--r--chrome/chrome_browser_extensions.gypi2
-rw-r--r--chrome/common/extensions/api/_api_features.json4
-rw-r--r--chrome/common/extensions/api/instance_id.idl89
-rw-r--r--chrome/common/extensions/api/schemas.gypi1
-rw-r--r--chrome/common/extensions/docs/templates/public/apps/instanceID.html1
-rw-r--r--chrome/common/extensions/docs/templates/public/extensions/instanceID.html1
-rw-r--r--extensions/browser/extension_function_histogram_value.h5
-rw-r--r--tools/metrics/histograms/histograms.xml5
11 files changed, 250 insertions, 0 deletions
diff --git a/chrome/browser/extensions/api/instance_id/OWNERS b/chrome/browser/extensions/api/instance_id/OWNERS
new file mode 100644
index 0000000..e8e7e8b
--- /dev/null
+++ b/chrome/browser/extensions/api/instance_id/OWNERS
@@ -0,0 +1,2 @@
+fgorski@chromium.org
+jianli@chromium.org \ No newline at end of file
diff --git a/chrome/browser/extensions/api/instance_id/instance_id_api.cc b/chrome/browser/extensions/api/instance_id/instance_id_api.cc
new file mode 100644
index 0000000..fc76fa9
--- /dev/null
+++ b/chrome/browser/extensions/api/instance_id/instance_id_api.cc
@@ -0,0 +1,57 @@
+// 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
diff --git a/chrome/browser/extensions/api/instance_id/instance_id_api.h b/chrome/browser/extensions/api/instance_id/instance_id_api.h
new file mode 100644
index 0000000..c7530eb
--- /dev/null
+++ b/chrome/browser/extensions/api/instance_id/instance_id_api.h
@@ -0,0 +1,83 @@
+// 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_
diff --git a/chrome/chrome_browser_extensions.gypi b/chrome/chrome_browser_extensions.gypi
index ecd4264..65d53ef 100644
--- a/chrome/chrome_browser_extensions.gypi
+++ b/chrome/chrome_browser_extensions.gypi
@@ -305,6 +305,8 @@
'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.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.h',
'browser/extensions/api/location/location_api.cc',
diff --git a/chrome/common/extensions/api/_api_features.json b/chrome/common/extensions/api/_api_features.json
index 518715b..43759a6f 100644
--- a/chrome/common/extensions/api/_api_features.json
+++ b/chrome/common/extensions/api/_api_features.json
@@ -507,6 +507,10 @@
"dependencies": ["permission:inputMethodPrivate"],
"contexts": ["blessed_extension"]
},
+ "instanceID": {
+ "dependencies": ["permission:gcm"],
+ "contexts": ["blessed_extension"]
+ },
"launcherPage": {
"dependencies": ["manifest:launcher_page"],
"contexts": ["blessed_extension"]
diff --git a/chrome/common/extensions/api/instance_id.idl b/chrome/common/extensions/api/instance_id.idl
new file mode 100644
index 0000000..8ed0e7a
--- /dev/null
+++ b/chrome/common/extensions/api/instance_id.idl
@@ -0,0 +1,89 @@
+// 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);
+ };
+};
diff --git a/chrome/common/extensions/api/schemas.gypi b/chrome/common/extensions/api/schemas.gypi
index fddbb07..e36f2d2 100644
--- a/chrome/common/extensions/api/schemas.gypi
+++ b/chrome/common/extensions/api/schemas.gypi
@@ -52,6 +52,7 @@
'identity_private.idl',
'image_writer_private.idl',
'inline_install_private.idl',
+ 'instance_id.idl',
'launcher_page.idl',
'location.idl',
'manifest_types.json',
diff --git a/chrome/common/extensions/docs/templates/public/apps/instanceID.html b/chrome/common/extensions/docs/templates/public/apps/instanceID.html
new file mode 100644
index 0000000..8bc884c
--- /dev/null
+++ b/chrome/common/extensions/docs/templates/public/apps/instanceID.html
@@ -0,0 +1 @@
+{{+partials.standard_apps_api api:apis.apps.instanceID/}}
diff --git a/chrome/common/extensions/docs/templates/public/extensions/instanceID.html b/chrome/common/extensions/docs/templates/public/extensions/instanceID.html
new file mode 100644
index 0000000..ed90fc4
--- /dev/null
+++ b/chrome/common/extensions/docs/templates/public/extensions/instanceID.html
@@ -0,0 +1 @@
+{{+partials.standard_extensions_api api:apis.extensions.instanceID/}}
diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h
index 542ce70..e5fe08b 100644
--- a/extensions/browser/extension_function_histogram_value.h
+++ b/extensions/browser/extension_function_histogram_value.h
@@ -1077,6 +1077,11 @@ enum HistogramValue {
AUTOFILLPRIVATE_REMOVEENTRY,
AUTOFILLPRIVATE_VALIDATEPHONENUMBERS,
AUTOFILLPRIVATE_MASKCREDITCARD,
+ INSTANCEID_GETID,
+ INSTANCEID_GETCREATIONTIME,
+ INSTANCEID_GETTOKEN,
+ INSTANCEID_DELETETOKEN,
+ INSTANCEID_DELETEID,
// Last entry: Add new entries above and ensure to update
// tools/metrics/histograms/histograms.xml.
ENUM_BOUNDARY
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 1180b38..4034abf 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -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="1017" label="AUTOFILLPRIVATE_VALIDATEPHONENUMBERS"/>
<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 name="ExtensionInstallCause" type="int">