Chromium Code Reviews| 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_internal_auth_api.h" | |
| 6 | |
| 7 #include "base/logging.h" | |
| 8 #include "base/values.h" | |
| 9 #include "chrome/browser/internal_auth.h" | |
| 10 | |
| 11 namespace { | |
| 12 | |
| 13 // Checks credentials and in case of positive check fills var=value map. | |
| 14 bool CheckCredentials( | |
| 15 const std::string& extension_id, | |
| 16 const std::vector<std::string>& arg_list, | |
| 17 std::map<std::string, std::string>* out) { | |
| 18 DCHECK(out); | |
| 19 out->clear(); | |
| 20 | |
| 21 char k90ttyExtensionId[] = "cigbjabahnfnnmplhmjeolnhobhfjggp"; | |
|
Aaron Boodman
2011/03/29 18:38:34
Why is this hard-coded? The convention is to just
Denis Lagno
2011/04/04 18:18:02
I removed it. However it may reappear in future -
| |
| 22 if (extension_id != k90ttyExtensionId) | |
| 23 return false; | |
| 24 | |
| 25 std::map<std::string, std::string> map; | |
| 26 if (!browser::ConvertArgListToVarValueMap(arg_list, &map)) | |
|
Aaron Boodman
2011/03/29 18:38:34
Where is this defined? I don't see it in the curre
Denis Lagno
2011/04/04 18:18:02
It was declared in chrome/browser/internal_auth.h
| |
| 27 return false; | |
| 28 if (map.size() != 2 || | |
| 29 map["port"] != "22" || | |
| 30 map["hostname"].empty()) { | |
| 31 return false; | |
| 32 } | |
| 33 out->swap(map); | |
| 34 return true; | |
| 35 } | |
| 36 | |
| 37 } // namespace | |
| 38 | |
| 39 bool InternalAuthGetTokenFunction::RunImpl() { | |
| 40 std::vector<std::string> arg_list; | |
| 41 for (size_t i = 0; i < args_->GetSize(); ++i) { | |
| 42 arg_list.push_back(std::string()); | |
| 43 EXTENSION_FUNCTION_VALIDATE(args_->GetString(i, &arg_list.back())); | |
| 44 } | |
| 45 | |
| 46 std::map<std::string, std::string> map; | |
| 47 std::string id = extension_id(); | |
| 48 if (CheckCredentials(id, arg_list, &map)) { | |
| 49 StringValue* token = Value::CreateStringValue( | |
| 50 browser::InternalAuthGeneration::GenerateToken(id, map)); | |
| 51 result_.reset(token); | |
| 52 } | |
| 53 return true; | |
| 54 } | |
| 55 | |
| OLD | NEW |