OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/gcm_driver/crypto/gcm_encryption_provider.h" | 5 #include "components/gcm_driver/crypto/gcm_encryption_provider.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 75 |
76 void GCMEncryptionProvider::GetEncryptionInfo( | 76 void GCMEncryptionProvider::GetEncryptionInfo( |
77 const std::string& app_id, | 77 const std::string& app_id, |
78 const EncryptionInfoCallback& callback) { | 78 const EncryptionInfoCallback& callback) { |
79 DCHECK(key_store_); | 79 DCHECK(key_store_); |
80 key_store_->GetKeys( | 80 key_store_->GetKeys( |
81 app_id, base::Bind(&GCMEncryptionProvider::DidGetEncryptionInfo, | 81 app_id, base::Bind(&GCMEncryptionProvider::DidGetEncryptionInfo, |
82 weak_ptr_factory_.GetWeakPtr(), app_id, callback)); | 82 weak_ptr_factory_.GetWeakPtr(), app_id, callback)); |
83 } | 83 } |
84 | 84 |
| 85 void GCMEncryptionProvider::RemoveEncryptionInfo( |
| 86 const std::string& app_id, |
| 87 const base::Closure& callback) { |
| 88 DCHECK(key_store_); |
| 89 key_store_->RemoveKeys(app_id, callback); |
| 90 } |
| 91 |
85 bool GCMEncryptionProvider::IsEncryptedMessage(const IncomingMessage& message) | 92 bool GCMEncryptionProvider::IsEncryptedMessage(const IncomingMessage& message) |
86 const { | 93 const { |
87 // The Web Push protocol requires the encryption and crypto-key properties to | 94 // The Web Push protocol requires the encryption and crypto-key properties to |
88 // be set, and the raw_data field to be populated with the payload. | 95 // be set, and the raw_data field to be populated with the payload. |
89 if (message.data.find(kEncryptionProperty) == message.data.end() || | 96 if (message.data.find(kEncryptionProperty) == message.data.end() || |
90 message.data.find(kCryptoKeyProperty) == message.data.end()) | 97 message.data.find(kCryptoKeyProperty) == message.data.end()) |
91 return false; | 98 return false; |
92 | 99 |
93 return message.raw_data.size() > 0; | 100 return message.raw_data.size() > 0; |
94 } | 101 } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 decrypted_message.decrypted = true; | 227 decrypted_message.decrypted = true; |
221 | 228 |
222 // There must be no data associated with the decrypted message at this point, | 229 // There must be no data associated with the decrypted message at this point, |
223 // to make sure that we don't end up in an infinite decryption loop. | 230 // to make sure that we don't end up in an infinite decryption loop. |
224 DCHECK_EQ(0u, decrypted_message.data.size()); | 231 DCHECK_EQ(0u, decrypted_message.data.size()); |
225 | 232 |
226 success_callback.Run(decrypted_message); | 233 success_callback.Run(decrypted_message); |
227 } | 234 } |
228 | 235 |
229 } // namespace gcm | 236 } // namespace gcm |
OLD | NEW |