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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/extensions/extension_web_proxy_private_api.h"
6
7 #include "base/logging.h"
8 #include "base/values.h"
9 #include "base/string_number_conversions.h"
10 #include "chrome/browser/internal_auth.h"
11
12 namespace {
13
14 // 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
15 bool CheckCredentials(
16 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.
17 const std::string& hostname,
18 int port) {
19 int kLowestUnprivelegedPort = 1024;
Aaron Boodman 2011/04/06 03:49:00 const int ...
Denis Lagno 2011/04/06 18:09:24 Done.
20 int kSecureShellPort = 22;
21 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
22 (port == kSecureShellPort ||
23 (port >= kLowestUnprivelegedPort && port < (1 << 16)));
24 }
25
26 } // namespace
27
28 bool WebProxyGetTokenFunction::RunImpl() {
29 std::string hostname;
30 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &hostname));
31 int port;
Aaron Boodman 2011/04/06 03:49:00 Always initialize primitives.
Denis Lagno 2011/04/06 18:09:24 Done.
32 EXTENSION_FUNCTION_VALIDATE(args_->GetInteger(1, &port));
33 std::string id = extension_id();
zel 2011/04/05 14:59:25 const std::string&
Denis Lagno 2011/04/06 18:09:24 Done.
34
35 if (CheckCredentials(id, hostname, port)) {
36 std::map<std::string, std::string> map;
37 map["Hostname"] = hostname;
38 map["Port"] = base::IntToString(port);
39 map["ExtensionId"] = id;
40 StringValue* token = Value::CreateStringValue(
41 browser::InternalAuthGeneration::GenerateToken("WebProxy", map));
42 result_.reset(token);
43 }
44 return true;
45 }
46
OLDNEW
« 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