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 #ifndef CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ | 5 #ifndef CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ |
6 #define CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ | 6 #define CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ |
7 | 7 |
| 8 #include <memory> |
8 #include <string> | 9 #include <string> |
9 | 10 |
10 #include "base/values.h" | 11 #include "base/values.h" |
11 #include "url/gurl.h" | 12 #include "url/gurl.h" |
12 | 13 |
13 // A single tuple of (protocol, url) that indicates how URLs of the | 14 // A single tuple of (protocol, url) that indicates how URLs of the |
14 // given protocol should be rewritten to be handled. | 15 // given protocol should be rewritten to be handled. |
15 | 16 |
16 class ProtocolHandler { | 17 class ProtocolHandler { |
17 public: | 18 public: |
(...skipping 16 matching lines...) Expand all Loading... |
34 static const ProtocolHandler& EmptyProtocolHandler(); | 35 static const ProtocolHandler& EmptyProtocolHandler(); |
35 | 36 |
36 // Interpolates the given URL into the URL template of this handler. | 37 // Interpolates the given URL into the URL template of this handler. |
37 GURL TranslateUrl(const GURL& url) const; | 38 GURL TranslateUrl(const GURL& url) const; |
38 | 39 |
39 // Returns true if the handlers are considered equivalent when determining | 40 // Returns true if the handlers are considered equivalent when determining |
40 // if both handlers can be registered, or if a handler has previously been | 41 // if both handlers can be registered, or if a handler has previously been |
41 // ignored. | 42 // ignored. |
42 bool IsEquivalent(const ProtocolHandler& other) const; | 43 bool IsEquivalent(const ProtocolHandler& other) const; |
43 | 44 |
44 // Encodes this protocol handler as a DictionaryValue. The caller is | 45 // Encodes this protocol handler as a DictionaryValue. |
45 // responsible for deleting the returned value. | 46 std::unique_ptr<base::DictionaryValue> Encode() const; |
46 base::DictionaryValue* Encode() const; | |
47 | 47 |
48 const std::string& protocol() const { return protocol_; } | 48 const std::string& protocol() const { return protocol_; } |
49 const GURL& url() const { return url_;} | 49 const GURL& url() const { return url_;} |
50 | 50 |
51 bool IsEmpty() const { | 51 bool IsEmpty() const { |
52 return protocol_.empty(); | 52 return protocol_.empty(); |
53 } | 53 } |
54 | 54 |
55 #if !defined(NDEBUG) | 55 #if !defined(NDEBUG) |
56 // Returns a string representation suitable for use in debugging. | 56 // Returns a string representation suitable for use in debugging. |
57 std::string ToString() const; | 57 std::string ToString() const; |
58 #endif | 58 #endif |
59 | 59 |
60 | 60 |
61 bool operator==(const ProtocolHandler& other) const; | 61 bool operator==(const ProtocolHandler& other) const; |
62 bool operator<(const ProtocolHandler& other) const; | 62 bool operator<(const ProtocolHandler& other) const; |
63 | 63 |
64 private: | 64 private: |
65 ProtocolHandler(const std::string& protocol, | 65 ProtocolHandler(const std::string& protocol, |
66 const GURL& url); | 66 const GURL& url); |
67 ProtocolHandler(); | 67 ProtocolHandler(); |
68 | 68 |
69 std::string protocol_; | 69 std::string protocol_; |
70 GURL url_; | 70 GURL url_; |
71 }; | 71 }; |
72 | 72 |
73 #endif // CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ | 73 #endif // CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ |
OLD | NEW |