summaryrefslogtreecommitdiffstats
path: root/extensions/shell/common
diff options
context:
space:
mode:
authorjamescook <jamescook@chromium.org>2014-10-28 16:58:16 -0700
committerCommit bot <commit-bot@chromium.org>2014-10-28 23:58:55 +0000
commit7bbe4c3b794172e2bf202ae988477e4c6ff16de9 (patch)
tree039d65ba90a1550b6596892cf210ff822f654f6b /extensions/shell/common
parentea3f0124fba8809ac33337af6f5a2178e6934573 (diff)
downloadchromium_src-7bbe4c3b794172e2bf202ae988477e4c6ff16de9.zip
chromium_src-7bbe4c3b794172e2bf202ae988477e4c6ff16de9.tar.gz
chromium_src-7bbe4c3b794172e2bf202ae988477e4c6ff16de9.tar.bz2
app_shell: Introduce skeleton for identity API
This is mostly for testing. It takes a refresh token on the command line and uses it to provide access tokens via the chrome.identity.getAuthToken() API. BUG=424653 TEST=app_shell_unittests ShellOAuth2TokenServiceTest and IdentityApiTest Review URL: https://codereview.chromium.org/670473003 Cr-Commit-Position: refs/heads/master@{#301738}
Diffstat (limited to 'extensions/shell/common')
-rw-r--r--extensions/shell/common/api/_api_features.json3
-rw-r--r--extensions/shell/common/api/identity.idl23
-rw-r--r--extensions/shell/common/api/schemas.gypi4
-rw-r--r--extensions/shell/common/api/shell_identity.idl14
-rw-r--r--extensions/shell/common/shell_extensions_client.cc6
-rw-r--r--extensions/shell/common/switches.cc6
-rw-r--r--extensions/shell/common/switches.h2
7 files changed, 38 insertions, 20 deletions
diff --git a/extensions/shell/common/api/_api_features.json b/extensions/shell/common/api/_api_features.json
index b4a1376..779e197 100644
--- a/extensions/shell/common/api/_api_features.json
+++ b/extensions/shell/common/api/_api_features.json
@@ -7,7 +7,8 @@
// feature.h, simple_feature.h, and base_feature_provider.h.
{
- "shell.identity": {
+ // Stub implementation of chrome.identity for app_shell.
+ "identity": {
"channel": "dev",
"contexts": ["blessed_extension"],
"extension_types": ["platform_app"]
diff --git a/extensions/shell/common/api/identity.idl b/extensions/shell/common/api/identity.idl
new file mode 100644
index 0000000..a77509a
--- /dev/null
+++ b/extensions/shell/common/api/identity.idl
@@ -0,0 +1,23 @@
+// Copyright 2014 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.
+
+// Simplified implementation of the <code>chrome.identity</code> for app_shell.
+namespace identity {
+
+ dictionary GetAuthTokenDetails {
+ // Ignored parameter. Exists only for compatibility.
+ boolean? interactive;
+ };
+
+ // Called with the OAuth2 access token on success or undefined on error.
+ callback GetAuthTokenCallback = void (optional DOMString token);
+
+ interface Functions {
+ // Returns an OAuth2 access token for the current app_shell user for scopes
+ // from the manifest. Does not prompt the user.
+ static void getAuthToken(GetAuthTokenDetails options,
+ GetAuthTokenCallback callback);
+ };
+
+};
diff --git a/extensions/shell/common/api/schemas.gypi b/extensions/shell/common/api/schemas.gypi
index 13def4f..0af258d 100644
--- a/extensions/shell/common/api/schemas.gypi
+++ b/extensions/shell/common/api/schemas.gypi
@@ -11,10 +11,10 @@
'non_compiled_schema_files': [
],
'schema_files': [
- 'shell_identity.idl',
+ 'identity.idl',
],
'cc_dir': 'extensions/shell/common/api',
- 'root_namespace': 'extensions::shell_api::%(namespace)s',
+ 'root_namespace': 'extensions::shell::api::%(namespace)s',
'impl_dir_': 'extensions/shell/browser/api',
},
}
diff --git a/extensions/shell/common/api/shell_identity.idl b/extensions/shell/common/api/shell_identity.idl
deleted file mode 100644
index 6772bae..0000000
--- a/extensions/shell/common/api/shell_identity.idl
+++ /dev/null
@@ -1,14 +0,0 @@
-// Copyright 2014 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.shell.identity</code> API to retrieve OAuth2 tokens
-// for user accounts. See also <code>chrome.identity</code>.
-namespace shell.identity {
-
- interface Functions {
- // TODO(jamescook): Implement this with options and a callback.
- static void getAuthToken();
- };
-
-};
diff --git a/extensions/shell/common/shell_extensions_client.cc b/extensions/shell/common/shell_extensions_client.cc
index 4fc57e8..9df2b12 100644
--- a/extensions/shell/common/shell_extensions_client.cc
+++ b/extensions/shell/common/shell_extensions_client.cc
@@ -174,14 +174,14 @@ bool ShellExtensionsClient::IsScriptableURL(const GURL& url,
bool ShellExtensionsClient::IsAPISchemaGenerated(
const std::string& name) const {
return core_api::GeneratedSchemas::IsGenerated(name) ||
- shell_api::GeneratedSchemas::IsGenerated(name);
+ shell::api::GeneratedSchemas::IsGenerated(name);
}
base::StringPiece ShellExtensionsClient::GetAPISchema(
const std::string& name) const {
// Schema for app_shell-only APIs.
- if (shell_api::GeneratedSchemas::IsGenerated(name))
- return shell_api::GeneratedSchemas::Get(name);
+ if (shell::api::GeneratedSchemas::IsGenerated(name))
+ return shell::api::GeneratedSchemas::Get(name);
// Core extensions APIs.
return core_api::GeneratedSchemas::Get(name);
diff --git a/extensions/shell/common/switches.cc b/extensions/shell/common/switches.cc
index 0186422..4b0ccc0 100644
--- a/extensions/shell/common/switches.cc
+++ b/extensions/shell/common/switches.cc
@@ -16,5 +16,11 @@ const char kAppShellHostWindowBounds[] = "app-shell-host-window-bounds";
// SSID of the preferred WiFi network.
const char kAppShellPreferredNetwork[] = "app-shell-preferred-network";
+// Refresh token for identity API calls for the current user. Used for testing.
+const char kAppShellRefreshToken[] = "app-shell-refresh-token";
+
+// User email address of the current user.
+const char kAppShellUser[] = "app-shell-user";
+
} // namespace switches
} // namespace extensions
diff --git a/extensions/shell/common/switches.h b/extensions/shell/common/switches.h
index 6c4911d..30196ae 100644
--- a/extensions/shell/common/switches.h
+++ b/extensions/shell/common/switches.h
@@ -13,6 +13,8 @@ namespace switches {
extern const char kAppShellAppPath[];
extern const char kAppShellHostWindowBounds[];
extern const char kAppShellPreferredNetwork[];
+extern const char kAppShellRefreshToken[];
+extern const char kAppShellUser[];
} // namespace switches
} // namespace extensions