| 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/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "components/gcm_driver/gcm_driver.h" | 10 #include "components/gcm_driver/gcm_driver.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, | 86 void CryptAuthGCMManagerImpl::OnMessage(const std::string& app_id, |
| 87 const gcm::IncomingMessage& message) { | 87 const gcm::IncomingMessage& message) { |
| 88 std::vector<std::string> fields; | 88 std::vector<std::string> fields; |
| 89 for (const auto& kv : message.data) { | 89 for (const auto& kv : message.data) { |
| 90 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); | 90 fields.push_back(std::string(kv.first) + ": " + std::string(kv.second)); |
| 91 } | 91 } |
| 92 | 92 |
| 93 PA_LOG(INFO) << "GCM message received:\n" | 93 PA_LOG(INFO) << "GCM message received:\n" |
| 94 << " sender_id: " << message.sender_id << "\n" | 94 << " sender_id: " << message.sender_id << "\n" |
| 95 << " collapse_key: " << message.collapse_key << "\n" | 95 << " collapse_key: " << message.collapse_key << "\n" |
| 96 << " data:\n " << base::JoinString(fields, "\n "); | 96 << " data:\n " << JoinString(fields, "\n "); |
| 97 | 97 |
| 98 if (message.data.find(kRegistrationTickleTypeKey) == message.data.end()) { | 98 if (message.data.find(kRegistrationTickleTypeKey) == message.data.end()) { |
| 99 PA_LOG(WARNING) << "GCM message does not contain 'registrationTickleType'."; | 99 PA_LOG(WARNING) << "GCM message does not contain 'registrationTickleType'."; |
| 100 } else { | 100 } else { |
| 101 std::string tickle_type = message.data.at(kRegistrationTickleTypeKey); | 101 std::string tickle_type = message.data.at(kRegistrationTickleTypeKey); |
| 102 if (tickle_type == kRegistrationTickleTypeForceEnrollment || | 102 if (tickle_type == kRegistrationTickleTypeForceEnrollment || |
| 103 tickle_type == kRegistrationTickleTypeUpdateEnrollment) { | 103 tickle_type == kRegistrationTickleTypeUpdateEnrollment) { |
| 104 // These tickle types correspond to re-enrollment messages. | 104 // These tickle types correspond to re-enrollment messages. |
| 105 FOR_EACH_OBSERVER(Observer, observers_, OnReenrollMessage()); | 105 FOR_EACH_OBSERVER(Observer, observers_, OnReenrollMessage()); |
| 106 } else if (tickle_type == kRegistrationTickleTypeDevicesSync) { | 106 } else if (tickle_type == kRegistrationTickleTypeDevicesSync) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 137 return; | 137 return; |
| 138 } | 138 } |
| 139 | 139 |
| 140 PA_LOG(INFO) << "GCM registration success, registration_id=" | 140 PA_LOG(INFO) << "GCM registration success, registration_id=" |
| 141 << registration_id; | 141 << registration_id; |
| 142 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); | 142 pref_service_->SetString(prefs::kCryptAuthGCMRegistrationId, registration_id); |
| 143 FOR_EACH_OBSERVER(Observer, observers_, OnGCMRegistrationResult(true)); | 143 FOR_EACH_OBSERVER(Observer, observers_, OnGCMRegistrationResult(true)); |
| 144 } | 144 } |
| 145 | 145 |
| 146 } // namespace proximity_auth | 146 } // namespace proximity_auth |
| OLD | NEW |