| 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/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h" | 5 #include "components/proximity_auth/cryptauth/cryptauth_gcm_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "components/gcm_driver/gcm_driver.h" | 9 #include "components/gcm_driver/gcm_driver.h" |
| 10 #include "components/prefs/pref_service.h" | 10 #include "components/prefs/pref_service.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 observers_.AddObserver(observer); | 76 observers_.AddObserver(observer); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void CryptAuthGCMManagerImpl::RemoveObserver(Observer* observer) { | 79 void CryptAuthGCMManagerImpl::RemoveObserver(Observer* observer) { |
| 80 observers_.RemoveObserver(observer); | 80 observers_.RemoveObserver(observer); |
| 81 } | 81 } |
| 82 | 82 |
| 83 void CryptAuthGCMManagerImpl::ShutdownHandler() { | 83 void CryptAuthGCMManagerImpl::ShutdownHandler() { |
| 84 } | 84 } |
| 85 | 85 |
| 86 void CryptAuthGCMManagerImpl::OnStoreReset() { |
| 87 // We will automatically re-register to GCM and re-enroll the new registration |
| 88 // ID to Cryptauth during the next scheduled sync. |
| 89 pref_service_->ClearPref(prefs::kCryptAuthGCMRegistrationId); |
| 90 } |
| 91 |
| 86 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, | 92 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, |
| 87 const gcm::IncomingMessage& message) { | 93 const gcm::IncomingMessage& message) { |
| 88 std::vector<std::string> fields; | 94 std::vector<std::string> fields; |
| 89 for (const auto& kv : message.data) { | 95 for (const auto& kv : message.data) { |
| 90 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); | 96 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); |
| 91 } | 97 } |
| 92 | 98 |
| 93 PA_LOG(INFO) << "GCM message received:\n" | 99 PA_LOG(INFO) << "GCM message received:\n" |
| 94 << " sender_id: " << message.sender_id << "\n" | 100 << " sender_id: " << message.sender_id << "\n" |
| 95 << " collapse_key: " << message.collapse_key << "\n" | 101 << " collapse_key: " << message.collapse_key << "\n" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 } | 147 } |
| 142 | 148 |
| 143 PA_LOG(INFO) << "GCM registration success, registration_id=" | 149 PA_LOG(INFO) << "GCM registration success, registration_id=" |
| 144 << registration_id; | 150 << registration_id; |
| 145 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); | 151 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); |
| 146 for (auto& observer : observers_) | 152 for (auto& observer : observers_) |
| 147 observer.OnGCMRegistrationResult(true); | 153 observer.OnGCMRegistrationResult(true); |
| 148 } | 154 } |
| 149 | 155 |
| 150 } // namespace proximity_auth | 156 } // namespace proximity_auth |
| OLD | NEW |