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

Unified Diff: chrome/browser/extensions/extension_web_proxy_private_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: c 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
« no previous file with comments | « chrome/browser/extensions/extension_web_proxy_private_api.h ('k') | chrome/browser/internal_auth.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_web_proxy_private_api.cc
diff --git a/chrome/browser/extensions/extension_web_proxy_private_api.cc b/chrome/browser/extensions/extension_web_proxy_private_api.cc
new file mode 100644
index 0000000000000000000000000000000000000000..937024223b1a609b5111032c0c05f704361e8a16
--- /dev/null
+++ b/chrome/browser/extensions/extension_web_proxy_private_api.cc
@@ -0,0 +1,46 @@
+// 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_web_proxy_private_api.h"
+
+#include "base/logging.h"
+#include "base/values.h"
+#include "base/string_number_conversions.h"
+#include "chrome/browser/internal_auth.h"
+
+namespace {
+
+// Elaborate this check for future needs.
Aaron Boodman 2011/04/06 03:49:00 The convention is: TODO(<yourusername>): .... But
Denis Lagno 2011/04/06 18:09:24 Intention was to express the notion that this func
+bool CheckCredentials(
+ const std::string& extension_id,
Aaron Boodman 2011/04/06 03:49:00 This wrapping is not necessary (the params would f
Denis Lagno 2011/04/06 18:09:24 Done.
+ const std::string& hostname,
+ int port) {
+ int kLowestUnprivelegedPort = 1024;
Aaron Boodman 2011/04/06 03:49:00 const int ...
Denis Lagno 2011/04/06 18:09:24 Done.
+ int kSecureShellPort = 22;
+ return !extension_id.empty() && !hostname.empty() &&
Aaron Boodman 2011/04/06 03:49:00 Kinda weird to pass in extension_id and hostname a
Denis Lagno 2011/04/06 18:09:24 as I said above, this function is just placeholder
+ (port == kSecureShellPort ||
+ (port >= kLowestUnprivelegedPort && port < (1 << 16)));
+}
+
+} // namespace
+
+bool WebProxyGetTokenFunction::RunImpl() {
+ std::string hostname;
+ EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &hostname));
+ int port;
Aaron Boodman 2011/04/06 03:49:00 Always initialize primitives.
Denis Lagno 2011/04/06 18:09:24 Done.
+ EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port));
+ std::string id = extension_id();
zel 2011/04/05 14:59:25 const std::string&
Denis Lagno 2011/04/06 18:09:24 Done.
+
+ if (CheckCredentials(id, hostname, port)) {
+ std::map<std::string, std::string> map;
+ map["Hostname"] = hostname;
+ map["Port"] = base::IntToString(port);
+ map["ExtensionId"] = id;
+ StringValue* token = Value::CreateStringValue(
+ browser::InternalAuthGeneration::GenerateToken("WebProxy", map));
+ result_.reset(token);
+ }
+ return true;
+}
+
« no previous file with comments | « chrome/browser/extensions/extension_web_proxy_private_api.h ('k') | chrome/browser/internal_auth.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698