| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" | 5 #include "chrome/browser/extensions/extension_web_socket_proxy_private_api.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/values.h" | 10 #include "base/values.h" |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 } | 121 } |
| 122 #else | 122 #else |
| 123 Finalize(); | 123 Finalize(); |
| 124 #endif | 124 #endif |
| 125 | 125 |
| 126 return true; | 126 return true; |
| 127 } | 127 } |
| 128 | 128 |
| 129 void WebSocketProxyPrivate::OnHostResolution(int result) { | 129 void WebSocketProxyPrivate::OnHostResolution(int result) { |
| 130 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
| 131 if (result == 0 && addr_.head() != NULL) { | 131 if (result == 0 && !addr_.empty()) { |
| 132 std::string ip = net::NetAddressToString(addr_.head()); | 132 std::string ip = addr_.front().ToStringWithoutPort(); |
| 133 if (!ip.empty() && ip.find(':') != std::string::npos && ip[0] != '[') | 133 if (!ip.empty() && ip.find(':') != std::string::npos && ip[0] != '[') |
| 134 ip = '[' + ip + ']'; | 134 ip = '[' + ip + ']'; |
| 135 map_["addr"] = ip; | 135 map_["addr"] = ip; |
| 136 } | 136 } |
| 137 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, | 137 content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| 138 base::Bind(&WebSocketProxyPrivate::Finalize, this)); | 138 base::Bind(&WebSocketProxyPrivate::Finalize, this)); |
| 139 #endif | 139 #endif |
| 140 } | 140 } |
| 141 | 141 |
| 142 WebSocketProxyPrivateGetURLForTCPFunction:: | 142 WebSocketProxyPrivateGetURLForTCPFunction:: |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 void WebSocketProxyPrivateGetPassportForTCPFunction::CustomFinalize() { | 196 void WebSocketProxyPrivateGetPassportForTCPFunction::CustomFinalize() { |
| 197 #if defined(OS_CHROMEOS) | 197 #if defined(OS_CHROMEOS) |
| 198 std::string passport = | 198 std::string passport = |
| 199 browser::InternalAuthGeneration::GeneratePassport( | 199 browser::InternalAuthGeneration::GeneratePassport( |
| 200 "web_socket_proxy", map_) + std::string(":"); | 200 "web_socket_proxy", map_) + std::string(":"); |
| 201 if (ContainsKey(map_, "addr")) | 201 if (ContainsKey(map_, "addr")) |
| 202 passport += map_["addr"]; | 202 passport += map_["addr"]; |
| 203 result_.reset(Value::CreateStringValue(passport)); | 203 result_.reset(Value::CreateStringValue(passport)); |
| 204 #endif | 204 #endif |
| 205 } | 205 } |
| OLD | NEW |