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

Unified Diff: chrome/browser/extensions/extension_internal_auth_api.cc

Issue 6683060: Private API for extensions like ssh-client that need access to TCP. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sigh-nedness Created 9 years, 9 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/extension_internal_auth_api.cc
diff --git a/chrome/browser/extensions/extension_internal_auth_api.cc b/chrome/browser/extensions/extension_internal_auth_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..7633ed34fe2cd61ac53ca9d27732ac9390cd9f30
--- /dev/null
+++ b/chrome/browser/extensions/extension_internal_auth_api.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2011 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/extension_internal_auth_api.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "chrome/browser/internal_auth.h"
+
+namespace {
+
+// Checks credentials and in case of positive check fills var=value map.
+bool CheckCredentials(
+ const std::string& extension_id,
+ const std::vector<std::string>& arg_list,
+ std::map<std::string, std::string>* out) {
+ DCHECK(out);
+ out->clear();
+
+ char k90ttyExtensionId[] = "cigbjabahnfnnmplhmjeolnhobhfjggp";
+ if (extension_id != k90ttyExtensionId)
+ return false;
+
+ std::map<std::string, std::string> map;
+ if (!browser::ConvertArgListToVarValueMap(arg_list, &map))
+ return false;
+ if (map.size() != 2 ||
+ map["port"] != "22" ||
+ map["hostname"].empty()) {
+ return false;
+ }
+ out->swap(map);
+ return true;
+}
+
+} // namespace
+
+bool InternalAuthGetTokenFunction::RunImpl() {
+ std::vector<std::string> arg_list;
zel 2011/03/29 05:31:34 why string array here? aren't you just passing hos
Denis Lagno 2011/04/04 18:18:02 Done.
+ for (size_t i = 0; i < args_->GetSize(); ++i) {
+ arg_list.push_back(std::string());
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(i, &arg_list.back()));
+ }
+
+ std::map<std::string, std::string> map;
+ std::string id = extension_id();
+ if (CheckCredentials(id, arg_list, &map)) {
+ StringValue* token = Value::CreateStringValue(
+ browser::InternalAuthGeneration::GenerateToken(id, map));
+ result_.reset(token);
+ }
+ return true;
+}
+

Powered by Google App Engine
This is Rietveld 408576698