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

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

Issue 10559049: Add ToString method for easy DLOG and debug support (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Only include ToString in debug builds. Created 8 years, 6 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
OLDNEW
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/stringprintf.h"
Peter Kasting 2012/06/22 23:45:48 Nit: This include not needed
Steve McKay 2012/06/27 22:34:38 Done.
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "net/base/escape.h" 10 #include "net/base/escape.h"
10 11
12
11 ProtocolHandler::ProtocolHandler(const std::string& protocol, 13 ProtocolHandler::ProtocolHandler(const std::string& protocol,
12 const GURL& url, 14 const GURL& url,
13 const string16& title) 15 const string16& title)
14 : protocol_(protocol), 16 : protocol_(protocol),
15 url_(url), 17 url_(url),
16 title_(title) { 18 title_(title) {
17 } 19 }
18 20
19 ProtocolHandler ProtocolHandler::CreateProtocolHandler( 21 ProtocolHandler ProtocolHandler::CreateProtocolHandler(
20 const std::string& protocol, 22 const std::string& protocol,
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 } 65 }
64 66
65 DictionaryValue* ProtocolHandler::Encode() const { 67 DictionaryValue* ProtocolHandler::Encode() const {
66 DictionaryValue* d = new DictionaryValue(); 68 DictionaryValue* d = new DictionaryValue();
67 d->Set("protocol", Value::CreateStringValue(protocol_)); 69 d->Set("protocol", Value::CreateStringValue(protocol_));
68 d->Set("url", Value::CreateStringValue(url_.spec())); 70 d->Set("url", Value::CreateStringValue(url_.spec()));
69 d->Set("title", Value::CreateStringValue(title_)); 71 d->Set("title", Value::CreateStringValue(title_));
70 return d; 72 return d;
71 } 73 }
72 74
75 # if !defined(NDEBUG)
Peter Kasting 2012/06/22 23:45:48 Nit: No space after # (2 places)
Steve McKay 2012/06/27 22:34:38 Done.
76 std::string ProtocolHandler::ToString() const {
77 return "{ protocol=" + protocol_ +
78 ", url=" + url_.spec() +
79 ", title=" + UTF16ToASCII(title_) +
80 " }";
81 }
82 # endif
83
73 bool ProtocolHandler::operator==(const ProtocolHandler& other) const { 84 bool ProtocolHandler::operator==(const ProtocolHandler& other) const {
74 return protocol_ == other.protocol_ && 85 return protocol_ == other.protocol_ &&
75 url_ == other.url_ && 86 url_ == other.url_ &&
76 title_ == other.title_; 87 title_ == other.title_;
77 } 88 }
78 89
79 bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const { 90 bool ProtocolHandler::IsEquivalent(const ProtocolHandler& other) const {
80 return protocol_ == other.protocol_ && url_ == other.url_; 91 return protocol_ == other.protocol_ && url_ == other.url_;
81 } 92 }
82 93
83 bool ProtocolHandler::operator<(const ProtocolHandler& other) const { 94 bool ProtocolHandler::operator<(const ProtocolHandler& other) const {
84 return title_ < other.title_; 95 return title_ < other.title_;
85 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698