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; |
+} |
+ |