Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(210)

Side by Side Diff: chrome/common/custom_handlers/protocol_handler.h

Issue 267103002: Ignore title parameter for navigator.registerProtocolHandler. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <string> 8 #include <string>
9 9
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 12
13 // A single tuple of (protocol, url, title) that indicates how URLs of the 13 // A single tuple of (protocol, url) that indicates how URLs of the
14 // given protocol should be rewritten to be handled. 14 // given protocol should be rewritten to be handled.
15 15
16 class ProtocolHandler { 16 class ProtocolHandler {
17 public: 17 public:
18 static ProtocolHandler CreateProtocolHandler(const std::string& protocol, 18 static ProtocolHandler CreateProtocolHandler(const std::string& protocol,
19 const GURL& url, 19 const GURL& url);
20 const base::string16& title);
21 20
22 // Creates a ProtocolHandler with fields from the dictionary. Returns an 21 // Creates a ProtocolHandler with fields from the dictionary. Returns an
23 // empty ProtocolHandler if the input is invalid. 22 // empty ProtocolHandler if the input is invalid.
24 static ProtocolHandler CreateProtocolHandler( 23 static ProtocolHandler CreateProtocolHandler(
25 const base::DictionaryValue* value); 24 const base::DictionaryValue* value);
26 25
27 // Returns true if the dictionary value has all the necessary fields to 26 // Returns true if the dictionary value has all the necessary fields to
28 // define a ProtocolHandler. 27 // define a ProtocolHandler.
29 static bool IsValidDict(const base::DictionaryValue* value); 28 static bool IsValidDict(const base::DictionaryValue* value);
30 29
(...skipping 10 matching lines...) Expand all
41 // if both handlers can be registered, or if a handler has previously been 40 // if both handlers can be registered, or if a handler has previously been
42 // ignored. 41 // ignored.
43 bool IsEquivalent(const ProtocolHandler& other) const; 42 bool IsEquivalent(const ProtocolHandler& other) const;
44 43
45 // Encodes this protocol handler as a DictionaryValue. The caller is 44 // Encodes this protocol handler as a DictionaryValue. The caller is
46 // responsible for deleting the returned value. 45 // responsible for deleting the returned value.
47 base::DictionaryValue* Encode() const; 46 base::DictionaryValue* Encode() const;
48 47
49 const std::string& protocol() const { return protocol_; } 48 const std::string& protocol() const { return protocol_; }
50 const GURL& url() const { return url_;} 49 const GURL& url() const { return url_;}
51 const base::string16& title() const { return title_; }
52 50
53 bool IsEmpty() const { 51 bool IsEmpty() const {
54 return protocol_.empty(); 52 return protocol_.empty();
55 } 53 }
56 54
57 #if !defined(NDEBUG) 55 #if !defined(NDEBUG)
58 // Returns a string representation suitable for use in debugging. 56 // Returns a string representation suitable for use in debugging.
59 std::string ToString() const; 57 std::string ToString() const;
60 #endif 58 #endif
61 59
62 60
63 bool operator==(const ProtocolHandler& other) const; 61 bool operator==(const ProtocolHandler& other) const;
64 bool operator<(const ProtocolHandler& other) const; 62 bool operator<(const ProtocolHandler& other) const;
65 63
66 private: 64 private:
67 ProtocolHandler(const std::string& protocol, 65 ProtocolHandler(const std::string& protocol,
68 const GURL& url, 66 const GURL& url);
69 const base::string16& title);
70 ProtocolHandler(); 67 ProtocolHandler();
71 68
72 std::string protocol_; 69 std::string protocol_;
73 GURL url_; 70 GURL url_;
74 base::string16 title_;
75 }; 71 };
76 72
77 #endif // CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_ 73 #endif // CHROME_COMMON_CUSTOM_HANDLERS_PROTOCOL_HANDLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/options/handler_options_handler.cc ('k') | chrome/common/custom_handlers/protocol_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698