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

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: address comment Created 5 years, 2 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
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 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 message, message_handled_closure, 224 message, message_handled_closure,
225 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED); 225 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED);
226 return; 226 return;
227 } 227 }
228 228
229 rappor::SampleDomainAndRegistryFromGURL( 229 rappor::SampleDomainAndRegistryFromGURL(
230 g_browser_process->rappor_service(), 230 g_browser_process->rappor_service(),
231 "PushMessaging.MessageReceived.Origin", 231 "PushMessaging.MessageReceived.Origin",
232 app_identifier.origin()); 232 app_identifier.origin());
233 233
234 // The Push API only exposes a single string of data in the push event fired
235 // on the Service Worker. When developers send messages using GCM to the Push
236 // API and want to include a message payload, they must pass a single key-
237 // value pair, where the key is "data" and the value is the string they want
238 // to be passed to their Service Worker. For example, they could send the
239 // following JSON using the HTTPS GCM API:
240 // {
241 // "registration_ids": ["FOO", "BAR"],
242 // "data": {
243 // "data": "BAZ",
244 // },
245 // "delay_while_idle": true,
246 // }
247 // TODO(johnme): Make sure this is clearly documented for developers.
248 std::string data; 234 std::string data;
249 // TODO(peter): Message payloads are disabled pending mandatory encryption. 235 if (AreMessagePayloadsEnabled() && message.decrypted)
250 // https://crbug.com/449184 236 data = message.raw_data;
251 if (AreMessagePayloadsEnabled()) {
252 gcm::MessageData::const_iterator it = message.data.find("data");
253 if (it != message.data.end())
254 data = it->second;
255 }
256 237
257 content::BrowserContext::DeliverPushMessage( 238 content::BrowserContext::DeliverPushMessage(
258 profile_, 239 profile_,
259 app_identifier.origin(), 240 app_identifier.origin(),
260 app_identifier.service_worker_registration_id(), 241 app_identifier.service_worker_registration_id(),
261 data, 242 data,
262 base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback, 243 base::Bind(&PushMessagingServiceImpl::DeliverMessageCallback,
263 weak_factory_.GetWeakPtr(), 244 weak_factory_.GetWeakPtr(),
264 app_identifier.app_id(), app_identifier.origin(), 245 app_identifier.app_id(), app_identifier.origin(),
265 app_identifier.service_worker_registration_id(), message, 246 app_identifier.service_worker_registration_id(), message,
(...skipping 517 matching lines...) Expand 10 before | Expand all | Expand 10 after
783 switches::kEnablePushMessagePayload); 764 switches::kEnablePushMessagePayload);
784 } 765 }
785 766
786 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 767 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
787 gcm::GCMProfileService* gcm_profile_service = 768 gcm::GCMProfileService* gcm_profile_service =
788 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 769 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
789 CHECK(gcm_profile_service); 770 CHECK(gcm_profile_service);
790 CHECK(gcm_profile_service->driver()); 771 CHECK(gcm_profile_service->driver());
791 return gcm_profile_service->driver(); 772 return gcm_profile_service->driver();
792 } 773 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_browsertest.cc ('k') | components/components_tests.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698