Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(638)

Side by Side Diff: chrome/browser/push_messaging/push_messaging_service_impl.cc

Issue 1243563002: Teach the GCM Driver how to decrypt incoming messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gcm-push-keys
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_encryption_provider.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/push_messaging/push_messaging_service_impl.h" 5 #include "chrome/browser/push_messaging/push_messaging_service_impl.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/barrier_closure.h" 9 #include "base/barrier_closure.h"
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 message, message_handled_closure, 187 message, message_handled_closure,
188 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED); 188 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED);
189 return; 189 return;
190 } 190 }
191 191
192 rappor::SampleDomainAndRegistryFromGURL( 192 rappor::SampleDomainAndRegistryFromGURL(
193 g_browser_process->rappor_service(), 193 g_browser_process->rappor_service(),
194 "PushMessaging.MessageReceived.Origin", 194 "PushMessaging.MessageReceived.Origin",
195 app_identifier.origin()); 195 app_identifier.origin());
196 196
197 // The Push API only exposes a single string of data in the push event fired
198 // on the Service Worker. When developers send messages using GCM to the Push
199 // API and want to include a message payload, they must pass a single key-
200 // value pair, where the key is "data" and the value is the string they want
201 // to be passed to their Service Worker. For example, they could send the
202 // following JSON using the HTTPS GCM API:
203 // {
204 // "registration_ids": ["FOO", "BAR"],
205 // "data": {
206 // "data": "BAZ",
207 // },
208 // "delay_while_idle": true,
209 // }
210 // TODO(johnme): Make sure this is clearly documented for developers.
211 std::string data; 197 std::string data;
212 // TODO(peter): Message payloads are disabled pending mandatory encryption. 198 if (AreMessagePayloadsEnabled() && message.raw_data.size())
213 // https://crbug.com/449184 199 data = message.raw_data.size();
johnme 2015/07/21 13:52:20 Remove the .size()
Peter Beverloo 2015/08/03 18:55:34 Done.
214 if (AreMessagePayloadsEnabled()) {
215 gcm::MessageData::const_iterator it = message.data.find("data");
216 if (it != message.data.end())
217 data = it->second;
218 }
219 200
220 content::BrowserContext::DeliverPushMessage( 201 content::BrowserContext::DeliverPushMessage(
221 profile_, 202 profile_,
222 app_identifier.origin(), 203 app_identifier.origin(),
223 app_identifier.service_worker_registration_id(), 204 app_identifier.service_worker_registration_id(),
224 data, 205 data,
225 base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback, 206 base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback,
226 weak_factory_.GetWeakPtr(), 207 weak_factory_.GetWeakPtr(),
227 app_identifier.app_id(), app_identifier.origin(), 208 app_identifier.app_id(), app_identifier.origin(),
228 app_identifier.service_worker_registration_id(), message, 209 app_identifier.service_worker_registration_id(), message,
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 switches::kEnablePushMessagePayload); 711 switches::kEnablePushMessagePayload);
731 } 712 }
732 713
733 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 714 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
734 gcm::GCMProfileService* gcm_profile_service = 715 gcm::GCMProfileService* gcm_profile_service =
735 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 716 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
736 CHECK(gcm_profile_service); 717 CHECK(gcm_profile_service);
737 CHECK(gcm_profile_service->driver()); 718 CHECK(gcm_profile_service->driver());
738 return gcm_profile_service->driver(); 719 return gcm_profile_service->driver();
739 } 720 }
OLDNEW
« no previous file with comments | « no previous file | components/gcm_driver/crypto/gcm_encryption_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698