OLD | NEW |
---|---|
(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 | |
OLD | NEW |