OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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/string_util.h" | 7 #include "base/string_util.h" |
8 #include "base/utf_string_conversions.h" | 8 #include "base/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 string16 title; | 46 string16 title; |
47 value->GetString("protocol", &protocol); | 47 value->GetString("protocol", &protocol); |
48 value->GetString("url", &url); | 48 value->GetString("url", &url); |
49 value->GetString("title", &title); | 49 value->GetString("title", &title); |
50 return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url), title); | 50 return ProtocolHandler::CreateProtocolHandler(protocol, GURL(url), title); |
51 } | 51 } |
52 | 52 |
53 GURL ProtocolHandler::TranslateUrl(const GURL& url) const { | 53 GURL ProtocolHandler::TranslateUrl(const GURL& url) const { |
54 std::string translatedUrlSpec(url_.spec()); | 54 std::string translatedUrlSpec(url_.spec()); |
55 ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", | 55 ReplaceSubstringsAfterOffset(&translatedUrlSpec, 0, "%s", |
56 EscapeQueryParamValue(url.spec(), true)); | 56 net::EscapeQueryParamValue(url.spec(), true)); |
57 return GURL(translatedUrlSpec); | 57 return GURL(translatedUrlSpec); |
58 } | 58 } |
59 | 59 |
60 DictionaryValue* ProtocolHandler::Encode() const { | 60 DictionaryValue* ProtocolHandler::Encode() const { |
61 DictionaryValue* d = new DictionaryValue(); | 61 DictionaryValue* d = new DictionaryValue(); |
62 d->Set("protocol", Value::CreateStringValue(protocol_)); | 62 d->Set("protocol", Value::CreateStringValue(protocol_)); |
63 d->Set("url", Value::CreateStringValue(url_.spec())); | 63 d->Set("url", Value::CreateStringValue(url_.spec())); |
64 d->Set("title", Value::CreateStringValue(title_)); | 64 d->Set("title", Value::CreateStringValue(title_)); |
65 return d; | 65 return d; |
66 } | 66 } |
67 | 67 |
68 bool ProtocolHandler::operator==(const ProtocolHandler& other) const { | 68 bool ProtocolHandler::operator==(const ProtocolHandler& other) const { |
69 return protocol_ == other.protocol_ && | 69 return protocol_ == other.protocol_ && |
70 url_ == other.url_ && | 70 url_ == other.url_ && |
71 title_ == other.title_; | 71 title_ == other.title_; |
72 } | 72 } |
73 | 73 |
74 bool ProtocolHandler::operator<(const ProtocolHandler& other) const { | 74 bool ProtocolHandler::operator<(const ProtocolHandler& other) const { |
75 return title_ < other.title_; | 75 return title_ < other.title_; |
76 } | 76 } |
OLD | NEW |