Index: chrome/browser/chromeos/web_socket_proxy.cc |
diff --git a/chrome/browser/chromeos/web_socket_proxy.cc b/chrome/browser/chromeos/web_socket_proxy.cc |
index 8a52746c7d3fcaa0cb9c173f599039735c7ca6b5..4e030520b8265e2be11665edc1157347bb435df6 100644 |
--- a/chrome/browser/chromeos/web_socket_proxy.cc |
+++ b/chrome/browser/chromeos/web_socket_proxy.cc |
@@ -30,13 +30,10 @@ |
#include "base/memory/scoped_ptr.h" |
#include "base/string_number_conversions.h" |
#include "base/string_util.h" |
+#include "chrome/browser/internal_auth.h" |
#include "content/browser/browser_thread.h" |
#include "content/common/notification_service.h" |
#include "content/common/notification_type.h" |
-// TODO(dilmah): enable this once webSocketProxyPrivate.getToken is wired. |
-#if 0 |
-#include "chrome/browser/internal_auth.h" |
-#endif |
#include "third_party/libevent/evdns.h" |
#include "third_party/libevent/event.h" |
@@ -105,10 +102,10 @@ bool FetchDecimalDigits(const std::string& s, uint32* result) { |
return got_something; |
} |
-// Parses "token:hostname:port:" string. Returns true on success. |
-bool FetchTokenNamePort( |
+// Parses "passport:hostname:port:" string. Returns true on success. |
+bool FetchPassportNamePort( |
uint8* begin, uint8* end, |
- std::string* token, std::string* name, uint32* port) { |
+ std::string* passport, std::string* name, uint32* port) { |
std::string input(begin, end); |
if (input[input.size() - 1] != ':') |
return false; |
@@ -134,14 +131,17 @@ bool FetchTokenNamePort( |
pos = input.find_first_of(':'); |
if (pos == std::string::npos) |
return false; |
- token->assign(input, 0, pos); |
+ passport->assign(input, 0, pos); |
name->assign(input, pos + 1, std::string::npos); |
return !name->empty(); |
} |
std::string FetchExtensionIdFromOrigin(const std::string origin) { |
// Origin of extension looks like "chrome-extension://EXTENSION_ID". |
- return origin.substr(origin.find_last_of('/')); |
+ size_t pos = origin.find_last_of('/'); |
+ if (pos != std::string::npos) |
+ pos += 1; |
+ return origin.substr(pos); |
} |
inline size_t strlen(const uint8* s) { |
@@ -828,20 +828,19 @@ Conn::Status Conn::ConsumeDestframe(struct evbuffer* evb) { |
return STATUS_INCOMPLETE; |
} |
- std::string token; |
- if (!FetchTokenNamePort(buf + 1, term_pos, &token, &destname_, &destport_)) |
+ std::string passport; |
+ if (!FetchPassportNamePort( |
+ buf + 1, term_pos, &passport, &destname_, &destport_)) { |
return STATUS_ABORT; |
- // TODO(dilmah): enable this once webSocketProxyPrivate.getToken is wired. |
-#if 0 |
+ } |
std::map<std::string, std::string> map; |
map["hostname"] = destname_; |
map["port"] = base::IntToString(destport_); |
map["extension_id"] = FetchExtensionIdFromOrigin(header_fields_["origin"]); |
- if (!browser::InternalAuthVerification::VerifyToken( |
- "web_socket_proxy", token, map)) { |
+ if (!browser::InternalAuthVerification::VerifyPassport( |
+ passport, "web_socket_proxy", map)) { |
return STATUS_ABORT; |
} |
-#endif |
evbuffer_drain(evb, term_pos - buf + 1); |
return STATUS_OK; |