| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/extensions/api/gcm/gcm_api.h" | 5 #include "chrome/browser/extensions/api/gcm/gcm_api.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 EXTENSION_FUNCTION_VALIDATE(params.get()); | 122 EXTENSION_FUNCTION_VALIDATE(params.get()); |
| 123 | 123 |
| 124 if (GetExtension()->public_key().empty()) { | 124 if (GetExtension()->public_key().empty()) { |
| 125 CompleteFunctionWithResult(std::string(), | 125 CompleteFunctionWithResult(std::string(), |
| 126 gcm::GCMClient::CERTIFICATE_MISSING); | 126 gcm::GCMClient::CERTIFICATE_MISSING); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 | 129 |
| 130 GCMProfileService()->Register( | 130 GCMProfileService()->Register( |
| 131 GetExtension()->id(), | 131 GetExtension()->id(), |
| 132 params->sender_ids, | 132 params->sender_id, |
| 133 SHA1HashHexString(GetExtension()->public_key()), | 133 SHA1HashHexString(GetExtension()->public_key()), |
| 134 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); | 134 base::Bind(&GcmRegisterFunction::CompleteFunctionWithResult, this)); |
| 135 | 135 |
| 136 return true; | 136 return true; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void GcmRegisterFunction::CompleteFunctionWithResult( | 139 void GcmRegisterFunction::CompleteFunctionWithResult( |
| 140 const std::string& registration_id, | 140 const std::string& registration_id, |
| 141 gcm::GCMClient::Result result) { | 141 gcm::GCMClient::Result result) { |
| 142 SetResult(base::Value::CreateStringValue(registration_id)); | 142 SetResult(base::Value::CreateStringValue(registration_id)); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 scoped_ptr<Event> event(new Event( | 234 scoped_ptr<Event> event(new Event( |
| 235 api::gcm::OnSendError::kEventName, | 235 api::gcm::OnSendError::kEventName, |
| 236 api::gcm::OnSendError::Create(error).Pass(), | 236 api::gcm::OnSendError::Create(error).Pass(), |
| 237 profile_)); | 237 profile_)); |
| 238 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( | 238 ExtensionSystem::Get(profile_)->event_router()->DispatchEventToExtension( |
| 239 app_id, event.Pass()); | 239 app_id, event.Pass()); |
| 240 } | 240 } |
| 241 | 241 |
| 242 } // namespace extensions | 242 } // namespace extensions |
| OLD | NEW |