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

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

Issue 2935333003: Propagate the user gesture bit when requesting push messaging permission. (Closed)
Patch Set: ThreadSafe user gesture check Created 3 years, 6 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/base64url.h" 10 #include "base/base64url.h"
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
444 } 444 }
445 445
446 // Subscribe and GetPermissionStatus methods ----------------------------------- 446 // Subscribe and GetPermissionStatus methods -----------------------------------
447 447
448 void PushMessagingServiceImpl::SubscribeFromDocument( 448 void PushMessagingServiceImpl::SubscribeFromDocument(
449 const GURL& requesting_origin, 449 const GURL& requesting_origin,
450 int64_t service_worker_registration_id, 450 int64_t service_worker_registration_id,
451 int renderer_id, 451 int renderer_id,
452 int render_frame_id, 452 int render_frame_id,
453 const content::PushSubscriptionOptions& options, 453 const content::PushSubscriptionOptions& options,
454 bool user_gesture,
454 const RegisterCallback& callback) { 455 const RegisterCallback& callback) {
455 PushMessagingAppIdentifier app_identifier = 456 PushMessagingAppIdentifier app_identifier =
456 PushMessagingAppIdentifier::Generate(requesting_origin, 457 PushMessagingAppIdentifier::Generate(requesting_origin,
457 service_worker_registration_id); 458 service_worker_registration_id);
458 459
459 if (push_subscription_count_ + pending_push_subscription_count_ >= 460 if (push_subscription_count_ + pending_push_subscription_count_ >=
460 kMaxRegistrations) { 461 kMaxRegistrations) {
461 SubscribeEndWithError(callback, 462 SubscribeEndWithError(callback,
462 content::PUSH_REGISTRATION_STATUS_LIMIT_REACHED); 463 content::PUSH_REGISTRATION_STATUS_LIMIT_REACHED);
463 return; 464 return;
(...skipping 11 matching lines...) Expand all
475 content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage); 476 content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage);
476 477
477 SubscribeEndWithError(callback, 478 SubscribeEndWithError(callback,
478 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); 479 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
479 return; 480 return;
480 } 481 }
481 482
482 // Push does not allow permission requests from iframes. 483 // Push does not allow permission requests from iframes.
483 PermissionManager::Get(profile_)->RequestPermission( 484 PermissionManager::Get(profile_)->RequestPermission(
484 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, web_contents->GetMainFrame(), 485 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, web_contents->GetMainFrame(),
485 requesting_origin, true /* user_gesture */, 486 requesting_origin, user_gesture,
486 base::Bind(&PushMessagingServiceImpl::DoSubscribe, 487 base::Bind(&PushMessagingServiceImpl::DoSubscribe,
487 weak_factory_.GetWeakPtr(), app_identifier, options, 488 weak_factory_.GetWeakPtr(), app_identifier, options,
488 callback)); 489 callback));
489 } 490 }
490 491
491 void PushMessagingServiceImpl::SubscribeFromWorker( 492 void PushMessagingServiceImpl::SubscribeFromWorker(
492 const GURL& requesting_origin, 493 const GURL& requesting_origin,
493 int64_t service_worker_registration_id, 494 int64_t service_worker_registration_id,
494 const content::PushSubscriptionOptions& options, 495 const content::PushSubscriptionOptions& options,
495 const RegisterCallback& register_callback) { 496 const RegisterCallback& register_callback) {
(...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after
1037 } 1038 }
1038 1039
1039 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() 1040 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver()
1040 const { 1041 const {
1041 instance_id::InstanceIDProfileService* instance_id_profile_service = 1042 instance_id::InstanceIDProfileService* instance_id_profile_service =
1042 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); 1043 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_);
1043 CHECK(instance_id_profile_service); 1044 CHECK(instance_id_profile_service);
1044 CHECK(instance_id_profile_service->driver()); 1045 CHECK(instance_id_profile_service->driver());
1045 return instance_id_profile_service->driver(); 1046 return instance_id_profile_service->driver();
1046 } 1047 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_service_impl.h ('k') | content/browser/push_messaging/push_messaging_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698