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/common/custom_handlers/protocol_handler.h" | 5 #include "chrome/common/custom_handlers/protocol_handler.h" |
6 | 6 |
7 #include "base/strings/string_util.h" | 7 #include "base/strings/string_util.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "net/base/escape.h" | 9 #include "net/base/escape.h" |
10 | 10 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 return EmptyProtocolHandler(); | 46 return EmptyProtocolHandler(); |
47 } | 47 } |
48 std::string protocol, url; | 48 std::string protocol, url; |
49 value->GetString("protocol", &protocol); | 49 value->GetString("protocol", &protocol); |
50 value->GetString("url", &url); | 50 value->GetString("url", &url); |
51 return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url)); | 51 return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url)); |
52 } | 52 } |
53 | 53 |
54 GURL ProtocolHandler::TranslateUrl(const GURL& url) const { | 54 GURL ProtocolHandler::TranslateUrl(const GURL& url) const { |
55 std::string translatedUrlSpec(url_.spec()); | 55 std::string translatedUrlSpec(url_.spec()); |
56 ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", | 56 base::ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", |
57 net::EscapeQueryParamValue(url.spec(), true)); | 57 net::EscapeQueryParamValue(url.spec(), true)); |
58 return GURL(translatedUrlSpec); | 58 return GURL(translatedUrlSpec); |
59 } | 59 } |
60 | 60 |
61 base::DictionaryValue* ProtocolHandler::Encode() const { | 61 base::DictionaryValue* ProtocolHandler::Encode() const { |
62 base::DictionaryValue* d = new base::DictionaryValue(); | 62 base::DictionaryValue* d = new base::DictionaryValue(); |
63 d->Set("protocol", new base::StringValue(protocol_)); | 63 d->Set("protocol", new base::StringValue(protocol_)); |
64 d->Set("url", new base::StringValue(url_.spec())); | 64 d->Set("url", new base::StringValue(url_.spec())); |
65 return d; | 65 return d; |
66 } | 66 } |
(...skipping 10 matching lines...) Expand all Loading... |
77 return protocol_ == other.protocol_ && url_ == other.url_; | 77 return protocol_ == other.protocol_ && url_ == other.url_; |
78 } | 78 } |
79 | 79 |
80 bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const { | 80 bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const { |
81 return protocol_ == other.protocol_ && url_ == other.url_; | 81 return protocol_ == other.protocol_ && url_ == other.url_; |
82 } | 82 } |
83 | 83 |
84 bool ProtocolHandler::operator<(const ProtocolHandler& other) const { | 84 bool ProtocolHandler::operator<(const ProtocolHandler& other) const { |
85 return url_ < other.url_; | 85 return url_ < other.url_; |
86 } | 86 } |
OLD | NEW |