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 "jingle/notifier/listener/notification_defines.h" | 5 #include "jingle/notifier/listener/notification_defines.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 Notification::~Notification() {} | 58 Notification::~Notification() {} |
59 | 59 |
60 bool Notification::Equals(const Notification& other) const { | 60 bool Notification::Equals(const Notification& other) const { |
61 return | 61 return |
62 channel == other.channel && | 62 channel == other.channel && |
63 data == other.data && | 63 data == other.data && |
64 RecipientListsEqual(recipients, other.recipients); | 64 RecipientListsEqual(recipients, other.recipients); |
65 } | 65 } |
66 | 66 |
67 std::string Notification::ToString() const { | 67 std::string Notification::ToString() const { |
68 // |channel| or |data| could hold binary data, so use GetDoubleQuotedJson() | 68 // |channel| or |data| could hold binary data, so convert all non-ASCII |
69 // to escape them. | 69 // characters to escape sequences. |
70 const std::string& printable_channel = base::GetDoubleQuotedJson(channel); | 70 const std::string& printable_channel = |
71 const std::string& printable_data = base::GetDoubleQuotedJson(data); | 71 base::EscapeBytesAsInvalidJSONString(channel, true /* put_in_quotes */); |
| 72 const std::string& printable_data = |
| 73 base::EscapeBytesAsInvalidJSONString(data, true /* put_in_quotes */); |
72 return | 74 return |
73 "{ channel: " + printable_channel + ", data: " + printable_data + " }"; | 75 "{ channel: " + printable_channel + ", data: " + printable_data + " }"; |
74 } | 76 } |
75 | 77 |
76 } // namespace notifier | 78 } // namespace notifier |
OLD | NEW |