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 <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" |
11 #include "base/bind_helpers.h" | 11 #include "base/bind_helpers.h" |
12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 14 #include "base/metrics/histogram.h" |
15 #include "base/prefs/pref_service.h" | 15 #include "base/prefs/pref_service.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/permissions/permission_request_id.h" |
17 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" | 19 #include "chrome/browser/push_messaging/push_messaging_app_identifier.h" |
19 #include "chrome/browser/push_messaging/push_messaging_constants.h" | 20 #include "chrome/browser/push_messaging/push_messaging_constants.h" |
20 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" | 21 #include "chrome/browser/push_messaging/push_messaging_permission_context.h" |
21 #include "chrome/browser/push_messaging/push_messaging_permission_context_factor
y.h" | 22 #include "chrome/browser/push_messaging/push_messaging_permission_context_factor
y.h" |
22 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" | 23 #include "chrome/browser/push_messaging/push_messaging_service_factory.h" |
23 #include "chrome/browser/services/gcm/gcm_profile_service.h" | 24 #include "chrome/browser/services/gcm/gcm_profile_service.h" |
24 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" | 25 #include "chrome/browser/services/gcm/gcm_profile_service_factory.h" |
25 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
26 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
27 #include "components/content_settings/core/browser/host_content_settings_map.h" | 28 #include "components/content_settings/core/browser/host_content_settings_map.h" |
28 #include "components/content_settings/core/common/permission_request_id.h" | |
29 #include "components/gcm_driver/gcm_driver.h" | 29 #include "components/gcm_driver/gcm_driver.h" |
30 #include "components/pref_registry/pref_registry_syncable.h" | 30 #include "components/pref_registry/pref_registry_syncable.h" |
31 #include "components/rappor/rappor_utils.h" | 31 #include "components/rappor/rappor_utils.h" |
32 #include "content/public/browser/browser_context.h" | 32 #include "content/public/browser/browser_context.h" |
33 #include "content/public/browser/render_frame_host.h" | 33 #include "content/public/browser/render_frame_host.h" |
34 #include "content/public/browser/service_worker_context.h" | 34 #include "content/public/browser/service_worker_context.h" |
35 #include "content/public/browser/storage_partition.h" | 35 #include "content/public/browser/storage_partition.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
37 #include "content/public/common/child_process_host.h" | 37 #include "content/public/common/child_process_host.h" |
38 #include "content/public/common/content_switches.h" | 38 #include "content/public/common/content_switches.h" |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 if (!render_frame_host) | 342 if (!render_frame_host) |
343 return; | 343 return; |
344 | 344 |
345 content::WebContents* web_contents = | 345 content::WebContents* web_contents = |
346 content::WebContents::FromRenderFrameHost(render_frame_host); | 346 content::WebContents::FromRenderFrameHost(render_frame_host); |
347 if (!web_contents) | 347 if (!web_contents) |
348 return; | 348 return; |
349 | 349 |
350 // TODO(miguelg) need to send this over IPC when bubble support is | 350 // TODO(miguelg) need to send this over IPC when bubble support is |
351 // implemented. | 351 // implemented. |
352 int bridge_id = -1; | 352 int request_id = -1; |
353 | 353 |
354 const PermissionRequestID id(renderer_id, render_frame_id, bridge_id, GURL()); | 354 const PermissionRequestID id( |
| 355 renderer_id, render_frame_id, request_id, GURL()); |
355 | 356 |
356 PushMessagingPermissionContext* permission_context = | 357 PushMessagingPermissionContext* permission_context = |
357 PushMessagingPermissionContextFactory::GetForProfile(profile_); | 358 PushMessagingPermissionContextFactory::GetForProfile(profile_); |
358 DCHECK(permission_context); | 359 DCHECK(permission_context); |
359 | 360 |
360 if (!user_visible) { | 361 if (!user_visible) { |
361 web_contents->GetMainFrame()->AddMessageToConsole( | 362 web_contents->GetMainFrame()->AddMessageToConsole( |
362 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 363 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
363 kSilentPushUnsupportedMessage); | 364 kSilentPushUnsupportedMessage); |
364 | 365 |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 CONTENT_SETTING_ALLOW; | 670 CONTENT_SETTING_ALLOW; |
670 } | 671 } |
671 | 672 |
672 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { | 673 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { |
673 gcm::GCMProfileService* gcm_profile_service = | 674 gcm::GCMProfileService* gcm_profile_service = |
674 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 675 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
675 CHECK(gcm_profile_service); | 676 CHECK(gcm_profile_service); |
676 CHECK(gcm_profile_service->driver()); | 677 CHECK(gcm_profile_service->driver()); |
677 return gcm_profile_service->driver(); | 678 return gcm_profile_service->driver(); |
678 } | 679 } |
OLD | NEW |