Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1023)

Unified Diff: chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.cc

Issue 214863002: Extension API enterprise.platformKeys. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: json -> idl, use ChromeUIThreadExtFun, split key.js, ... Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.cc
diff --git a/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.cc b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..2ae18ed252fd5d85a4e4cbe320850032f9f96673
--- /dev/null
+++ b/chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.cc
@@ -0,0 +1,144 @@
+// 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.
+
+#include "chrome/browser/extensions/api/enterprise_platform_keys/enterprise_platform_keys_api.h"
+
+#include "base/logging.h"
+#include "chrome/browser/extensions/api/enterprise_platform_keys/token_method_nss.h"
+#include "chrome/common/extensions/api/enterprise_platform_keys.h"
+#include "chrome/common/extensions/api/enterprise_platform_keys_internal.h"
+
+namespace {
+const char kErrorInvalidToken[] = "Token is invalid.";
+}
+
+namespace extensions {
+
+namespace enterprise_platform_keys {
+
+namespace impl = nss;
not at google - send to devlin 2014/05/07 00:00:12 is there a way to have correctly namespaced things
pneubeck (no reviews) 2014/05/07 21:44:19 Done.
+
+namespace api_epk = api::enterprise_platform_keys;
+namespace api_epki = api::enterprise_platform_keys_internal;
+
+const char kTokenIdUser[] = "user";
+
+TokenMethodExtensionFunction::TokenMethodExtensionFunction() {
+}
+
+TokenMethodExtensionFunction::~TokenMethodExtensionFunction() {
+}
+
+void TokenMethodExtensionFunction::RespondWithoutResult() {
+ Respond(NoArguments());
+}
+
+void TokenMethodExtensionFunction::RespondWithResults(
+ scoped_ptr<base::ListValue> results) {
+ Respond(MultipleArguments(results.release()));
+}
+
+void TokenMethodExtensionFunction::RespondWithError(
+ const std::string& error_message) {
+ Respond(Error(error_message));
not at google - send to devlin 2014/05/07 00:00:12 the fact that you need to make these alias is an i
pneubeck (no reviews) 2014/05/07 21:44:19 These functions constitute the interface that the
+}
+
+bool TokenMethodExtensionFunction::ValidateToken(const std::string& token_id) {
+ // For now, the user token is the only valid one.
+ if (token_id != kTokenIdUser) {
+ SetError(kErrorInvalidToken);
+ return false;
+ }
+ return true;
+}
+
+Generate::Generate() {
+}
+Generate::~Generate() {
+}
+
+ExtensionFunction::ResponseAction Generate::Run() {
+ scoped_ptr<api_epki::GenerateKey::Params> params(
+ api_epki::GenerateKey::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(params &&
+ ValidateToken(params->token_id));
+ impl::Generate(this, params.Pass());
+ return RespondLater();
+}
+
+Sign::Sign() {
+}
+
+Sign::~Sign() {
+}
+
+ExtensionFunction::ResponseAction Sign::Run() {
+ scoped_ptr<api_epki::Sign::Params> params(
+ api_epki::Sign::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(params &&
+ ValidateToken(params->token_id));
+ impl::Sign(this, params.Pass());
+ return RespondLater();
+}
+
+GetCerts::GetCerts() {
+}
+
+GetCerts::~GetCerts() {
+}
+
+ExtensionFunction::ResponseAction GetCerts::Run() {
+ scoped_ptr<api_epk::GetCertificates::Params> params(
+ api_epk::GetCertificates::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(params &&
+ ValidateToken(params->token_id));
+ impl::GetCerts(this, params.Pass());
+ return RespondLater();
+}
+
+ImportCert::ImportCert() {
+}
+
+ImportCert::~ImportCert() {
+}
+
+ExtensionFunction::ResponseAction ImportCert::Run() {
+ scoped_ptr<api_epk::ImportCertificate::Params> params(
+ api_epk::ImportCertificate::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(params &&
+ ValidateToken(params->token_id));
+ impl::Import(this, params.Pass());
+ return RespondLater();
+}
+
+RemoveCert::RemoveCert() {
+}
+
+RemoveCert::~RemoveCert() {
+}
+
+ExtensionFunction::ResponseAction RemoveCert::Run() {
+ scoped_ptr<api_epk::RemoveCertificate::Params> params(
+ api_epk::RemoveCertificate::Params::Create(*args_));
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(params &&
+ ValidateToken(params->token_id));
+ impl::Remove(this, params.Pass());
+ return RespondLater();
+}
+
+GetTokens::~GetTokens() {
+}
+
+ExtensionFunction::ResponseAction GetTokens::Run() {
+ EXTENSION_FUNCTION_VALIDATE_TYPESAFE(args_->empty());
+
+ std::vector<std::string> token_ids;
+ token_ids.push_back(kTokenIdUser);
+ return RespondNow(MultipleArguments(
+ api_epki::GetTokens::Results::Create(token_ids).release()));
+}
+
+} // namespace enterprise_platform_keys
+
+} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698