Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <bitset> | 7 #include <bitset> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/barrier_closure.h" | 10 #include "base/barrier_closure.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 27 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
| 28 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 28 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
| 29 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 29 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
| 30 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 31 #include "chrome/common/pref_names.h" | 31 #include "chrome/common/pref_names.h" |
| 32 #include "chrome/grit/generated_resources.h" | 32 #include "chrome/grit/generated_resources.h" |
| 33 #include "components/content_settings/core/browser/host_content_settings_map.h" | 33 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 34 #include "components/content_settings/core/common/permission_request_id.h" | 34 #include "components/content_settings/core/common/permission_request_id.h" |
| 35 #include "components/gcm_driver/gcm_driver.h" | 35 #include "components/gcm_driver/gcm_driver.h" |
| 36 #include "components/pref_registry/pref_registry_syncable.h" | 36 #include "components/pref_registry/pref_registry_syncable.h" |
| 37 #include "components/rappor/rappor_utils.h" | |
| 37 #include "content/public/browser/browser_context.h" | 38 #include "content/public/browser/browser_context.h" |
| 38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/render_frame_host.h" | 40 #include "content/public/browser/render_frame_host.h" |
| 40 #include "content/public/browser/service_worker_context.h" | 41 #include "content/public/browser/service_worker_context.h" |
| 41 #include "content/public/browser/storage_partition.h" | 42 #include "content/public/browser/storage_partition.h" |
| 42 #include "content/public/browser/web_contents.h" | 43 #include "content/public/browser/web_contents.h" |
| 43 #include "content/public/common/child_process_host.h" | 44 #include "content/public/common/child_process_host.h" |
| 44 #include "content/public/common/content_switches.h" | 45 #include "content/public/common/content_switches.h" |
| 45 #include "content/public/common/platform_notification_data.h" | 46 #include "content/public/common/platform_notification_data.h" |
| 46 #include "content/public/common/push_messaging_status.h" | 47 #include "content/public/common/push_messaging_status.h" |
| 47 #include "third_party/skia/include/core/SkBitmap.h" | 48 #include "third_party/skia/include/core/SkBitmap.h" |
| 48 #include "ui/base/l10n/l10n_util.h" | 49 #include "ui/base/l10n/l10n_util.h" |
| 49 | 50 |
| 51 | |
|
johnme
2015/03/18 18:40:39
Nit: no double newline
Miguel Garcia
2015/03/18 18:51:27
Done.
| |
| 50 #if defined(OS_ANDROID) | 52 #if defined(OS_ANDROID) |
| 51 #include "chrome/browser/ui/android/tab_model/tab_model.h" | 53 #include "chrome/browser/ui/android/tab_model/tab_model.h" |
| 52 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" | 54 #include "chrome/browser/ui/android/tab_model/tab_model_list.h" |
| 53 #else | 55 #else |
| 54 #include "chrome/browser/ui/browser.h" | 56 #include "chrome/browser/ui/browser.h" |
| 55 #include "chrome/browser/ui/browser_iterator.h" | 57 #include "chrome/browser/ui/browser_iterator.h" |
| 56 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 58 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 57 #endif | 59 #endif |
| 58 | 60 |
| 59 namespace { | 61 namespace { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 193 } | 195 } |
| 194 // Drop message and unregister if |origin| has lost push permission. | 196 // Drop message and unregister if |origin| has lost push permission. |
| 195 if (!HasPermission(application_id.origin())) { | 197 if (!HasPermission(application_id.origin())) { |
| 196 DeliverMessageCallback(app_id, application_id.origin(), | 198 DeliverMessageCallback(app_id, application_id.origin(), |
| 197 application_id.service_worker_registration_id(), | 199 application_id.service_worker_registration_id(), |
| 198 message, | 200 message, |
| 199 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED); | 201 content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED); |
| 200 return; | 202 return; |
| 201 } | 203 } |
| 202 | 204 |
| 205 rappor::SampleDomainAndRegistryFromGURL(g_browser_process->rappor_service(), | |
| 206 "PushMessaging.MessageReceived.Url", | |
|
johnme
2015/03/18 18:40:39
Presumably this should be .Origin to match the nam
Miguel Garcia
2015/03/18 18:51:27
indeed
| |
| 207 application_id.origin()); | |
| 208 | |
| 203 // The Push API only exposes a single string of data in the push event fired | 209 // The Push API only exposes a single string of data in the push event fired |
| 204 // on the Service Worker. When developers send messages using GCM to the Push | 210 // on the Service Worker. When developers send messages using GCM to the Push |
| 205 // API and want to include a message payload, they must pass a single key- | 211 // API and want to include a message payload, they must pass a single key- |
| 206 // value pair, where the key is "data" and the value is the string they want | 212 // value pair, where the key is "data" and the value is the string they want |
| 207 // to be passed to their Service Worker. For example, they could send the | 213 // to be passed to their Service Worker. For example, they could send the |
| 208 // following JSON using the HTTPS GCM API: | 214 // following JSON using the HTTPS GCM API: |
| 209 // { | 215 // { |
| 210 // "registration_ids": ["FOO", "BAR"], | 216 // "registration_ids": ["FOO", "BAR"], |
| 211 // "data": { | 217 // "data": { |
| 212 // "data": "BAZ", | 218 // "data": "BAZ", |
| (...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 778 CONTENT_SETTING_ALLOW; | 784 CONTENT_SETTING_ALLOW; |
| 779 } | 785 } |
| 780 | 786 |
| 781 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { | 787 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { |
| 782 gcm::GCMProfileService* gcm_profile_service = | 788 gcm::GCMProfileService* gcm_profile_service = |
| 783 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 789 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
| 784 CHECK(gcm_profile_service); | 790 CHECK(gcm_profile_service); |
| 785 CHECK(gcm_profile_service->driver()); | 791 CHECK(gcm_profile_service->driver()); |
| 786 return gcm_profile_service->driver(); | 792 return gcm_profile_service->driver(); |
| 787 } | 793 } |
| OLD | NEW |