| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/browser/sync/notifier/cache_invalidation_packet_handler.h" | 5 #include "chrome/browser/sync/notifier/cache_invalidation_packet_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 VLOG(2) << "Queueing stanza"; | 77 VLOG(2) << "Queueing stanza"; |
| 78 QueueStanza(stanza); | 78 QueueStanza(stanza); |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 VLOG(2) << "Stanza skipped"; | 81 VLOG(2) << "Stanza skipped"; |
| 82 return false; | 82 return false; |
| 83 } | 83 } |
| 84 | 84 |
| 85 private: | 85 private: |
| 86 bool IsValidCacheInvalidationIqPacket(const buzz::XmlElement* stanza) { | 86 bool IsValidCacheInvalidationIqPacket(const buzz::XmlElement* stanza) { |
| 87 // We make sure to compare jids (which are normalized) instead of | 87 // We deliberately minimize the verification we do here: see |
| 88 // just strings -- server may use non-normalized jids in | 88 // http://crbug.com/71285 . |
| 89 // attributes. | 89 return MatchRequestIq(stanza, buzz::STR_SET, kQnData); |
| 90 // | |
| 91 // TODO(akalin): Add unit tests for this. | |
| 92 buzz::Jid to(stanza->Attr(buzz::QN_TO)); | |
| 93 return | |
| 94 (MatchRequestIq(stanza, buzz::STR_SET, kQnData) && | |
| 95 (to == GetClient()->jid())); | |
| 96 } | 90 } |
| 97 | 91 |
| 98 bool GetCacheInvalidationIqPacketData(const buzz::XmlElement* stanza, | 92 bool GetCacheInvalidationIqPacketData(const buzz::XmlElement* stanza, |
| 99 std::string* data) { | 93 std::string* data) { |
| 100 DCHECK(IsValidCacheInvalidationIqPacket(stanza)); | 94 DCHECK(IsValidCacheInvalidationIqPacket(stanza)); |
| 101 const buzz::XmlElement* cache_invalidation_iq_packet = | 95 const buzz::XmlElement* cache_invalidation_iq_packet = |
| 102 stanza->FirstNamed(kQnData); | 96 stanza->FirstNamed(kQnData); |
| 103 if (!cache_invalidation_iq_packet) { | 97 if (!cache_invalidation_iq_packet) { |
| 104 LOG(ERROR) << "Could not find cache invalidation IQ packet element"; | 98 LOG(ERROR) << "Could not find cache invalidation IQ packet element"; |
| 105 return false; | 99 return false; |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 std::string decoded_message; | 242 std::string decoded_message; |
| 249 if (!base::Base64Decode(packet, &decoded_message)) { | 243 if (!base::Base64Decode(packet, &decoded_message)) { |
| 250 LOG(ERROR) << "Could not base64-decode received message: " | 244 LOG(ERROR) << "Could not base64-decode received message: " |
| 251 << packet; | 245 << packet; |
| 252 return; | 246 return; |
| 253 } | 247 } |
| 254 network_endpoint->HandleInboundMessage(decoded_message); | 248 network_endpoint->HandleInboundMessage(decoded_message); |
| 255 } | 249 } |
| 256 | 250 |
| 257 } // namespace sync_notifier | 251 } // namespace sync_notifier |
| OLD | NEW |