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

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

Issue 1726323002: Have Permission{Manager,Service} use Origin. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Clarify and test Origin.empty_. Created 4 years, 9 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 27 matching lines...) Expand all
38 #include "content/public/browser/browser_context.h" 38 #include "content/public/browser/browser_context.h"
39 #include "content/public/browser/permission_type.h" 39 #include "content/public/browser/permission_type.h"
40 #include "content/public/browser/render_frame_host.h" 40 #include "content/public/browser/render_frame_host.h"
41 #include "content/public/browser/service_worker_context.h" 41 #include "content/public/browser/service_worker_context.h"
42 #include "content/public/browser/storage_partition.h" 42 #include "content/public/browser/storage_partition.h"
43 #include "content/public/browser/web_contents.h" 43 #include "content/public/browser/web_contents.h"
44 #include "content/public/common/child_process_host.h" 44 #include "content/public/common/child_process_host.h"
45 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
46 #include "content/public/common/push_messaging_status.h" 46 #include "content/public/common/push_messaging_status.h"
47 #include "ui/base/l10n/l10n_util.h" 47 #include "ui/base/l10n/l10n_util.h"
48 #include "url/origin.h"
48 49
49 #if BUILDFLAG(ENABLE_BACKGROUND) 50 #if BUILDFLAG(ENABLE_BACKGROUND)
50 #include "chrome/browser/background/background_mode_manager.h" 51 #include "chrome/browser/background/background_mode_manager.h"
51 #endif 52 #endif
52 53
53 namespace { 54 namespace {
54 const int kMaxRegistrations = 1000000; 55 const int kMaxRegistrations = 1000000;
55 56
56 // Chrome does not yet support silent push messages, and requires websites to 57 // Chrome does not yet support silent push messages, and requires websites to
57 // indicate that they will only send user-visible messages. 58 // indicate that they will only send user-visible messages.
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage); 373 content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage);
373 374
374 SubscribeEndWithError(callback, 375 SubscribeEndWithError(callback,
375 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); 376 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
376 return; 377 return;
377 } 378 }
378 379
379 // Push does not allow permission requests from iframes. 380 // Push does not allow permission requests from iframes.
380 profile_->GetPermissionManager()->RequestPermission( 381 profile_->GetPermissionManager()->RequestPermission(
381 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(), 382 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(),
382 requesting_origin, 383 url::Origin(requesting_origin),
383 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, 384 base::Bind(&PushMessagingServiceImpl::DidRequestPermission,
384 weak_factory_.GetWeakPtr(), app_identifier, sender_id, 385 weak_factory_.GetWeakPtr(), app_identifier, sender_id,
385 callback)); 386 callback));
386 } 387 }
387 388
388 void PushMessagingServiceImpl::SubscribeFromWorker( 389 void PushMessagingServiceImpl::SubscribeFromWorker(
389 const GURL& requesting_origin, 390 const GURL& requesting_origin,
390 int64_t service_worker_registration_id, 391 int64_t service_worker_registration_id,
391 const std::string& sender_id, 392 const std::string& sender_id,
392 bool user_visible, 393 bool user_visible,
(...skipping 29 matching lines...) Expand all
422 423
423 blink::WebPushPermissionStatus PushMessagingServiceImpl::GetPermissionStatus( 424 blink::WebPushPermissionStatus PushMessagingServiceImpl::GetPermissionStatus(
424 const GURL& origin, 425 const GURL& origin,
425 bool user_visible) { 426 bool user_visible) {
426 if (!user_visible) 427 if (!user_visible)
427 return blink::WebPushPermissionStatusDenied; 428 return blink::WebPushPermissionStatusDenied;
428 429
429 // Because the Push API is tied to Service Workers, many usages of the API 430 // Because the Push API is tied to Service Workers, many usages of the API
430 // won't have an embedding origin at all. Only consider the requesting 431 // won't have an embedding origin at all. Only consider the requesting
431 // |origin| when checking whether permission to use the API has been granted. 432 // |origin| when checking whether permission to use the API has been granted.
433 url::Origin actual_origin(origin);
432 return ToPushPermission(profile_->GetPermissionManager()->GetPermissionStatus( 434 return ToPushPermission(profile_->GetPermissionManager()->GetPermissionStatus(
433 content::PermissionType::PUSH_MESSAGING, origin, origin)); 435 content::PermissionType::PUSH_MESSAGING, actual_origin, actual_origin));
434 } 436 }
435 437
436 bool PushMessagingServiceImpl::SupportNonVisibleMessages() { 438 bool PushMessagingServiceImpl::SupportNonVisibleMessages() {
437 return false; 439 return false;
438 } 440 }
439 441
440 void PushMessagingServiceImpl::SubscribeEnd( 442 void PushMessagingServiceImpl::SubscribeEnd(
441 const content::PushMessagingService::RegisterCallback& callback, 443 const content::PushMessagingService::RegisterCallback& callback,
442 const std::string& subscription_id, 444 const std::string& subscription_id,
443 const std::vector<uint8_t>& p256dh, 445 const std::vector<uint8_t>& p256dh,
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 blink::WebPushPermissionStatusGranted; 757 blink::WebPushPermissionStatusGranted;
756 } 758 }
757 759
758 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 760 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
759 gcm::GCMProfileService* gcm_profile_service = 761 gcm::GCMProfileService* gcm_profile_service =
760 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 762 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
761 CHECK(gcm_profile_service); 763 CHECK(gcm_profile_service);
762 CHECK(gcm_profile_service->driver()); 764 CHECK(gcm_profile_service->driver());
763 return gcm_profile_service->driver(); 765 return gcm_profile_service->driver();
764 } 766 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698