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

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

Issue 1158923002: Remove support for the "gcm_user_visible_only" manifest key. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a message Created 5 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/bind.h" 10 #include "base/bind.h"
(...skipping 23 matching lines...) Expand all
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"
39 #include "content/public/common/push_messaging_status.h" 39 #include "content/public/common/push_messaging_status.h"
40 40
41 namespace { 41 namespace {
42 const int kMaxRegistrations = 1000000; 42 const int kMaxRegistrations = 1000000;
43 43
44 // Chrome does not yet support silent push messages, and requires websites to
45 // indicate that they will only send user-visible messages.
46 const char kSilentPushUnsupportedMessage[] =
47 "Chrome currently only supports the Push API for subscriptions that will "
48 "result in user-visible messages. You can indicate this by calling "
49 "pushManager.subscribe({userVisibleOnly: true}) instead. See "
50 "https://goo.gl/yqv4Q4 for more details.";
51
44 void RecordDeliveryStatus(content::PushDeliveryStatus status) { 52 void RecordDeliveryStatus(content::PushDeliveryStatus status) {
45 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus", 53 UMA_HISTOGRAM_ENUMERATION("PushMessaging.DeliveryStatus",
46 status, 54 status,
47 content::PUSH_DELIVERY_STATUS_LAST + 1); 55 content::PUSH_DELIVERY_STATUS_LAST + 1);
48 } 56 }
49 57
50 blink::WebPushPermissionStatus ToPushPermission(ContentSetting setting) { 58 blink::WebPushPermissionStatus ToPushPermission(ContentSetting setting) {
51 switch (setting) { 59 switch (setting) {
52 case CONTENT_SETTING_ALLOW: 60 case CONTENT_SETTING_ALLOW:
53 return blink::WebPushPermissionStatusGranted; 61 return blink::WebPushPermissionStatusGranted;
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 332
325 // TODO(miguelg) need to send this over IPC when bubble support is 333 // TODO(miguelg) need to send this over IPC when bubble support is
326 // implemented. 334 // implemented.
327 int bridge_id = -1; 335 int bridge_id = -1;
328 336
329 const PermissionRequestID id( 337 const PermissionRequestID id(
330 renderer_id, web_contents->GetRoutingID(), bridge_id, GURL()); 338 renderer_id, web_contents->GetRoutingID(), bridge_id, GURL());
331 339
332 PushMessagingPermissionContext* permission_context = 340 PushMessagingPermissionContext* permission_context =
333 PushMessagingPermissionContextFactory::GetForProfile(profile_); 341 PushMessagingPermissionContextFactory::GetForProfile(profile_);
342 DCHECK(permission_context);
334 343
335 if (permission_context == NULL || !user_visible) { 344 if (!user_visible) {
345 web_contents->GetMainFrame()->AddMessageToConsole(
346 content::CONSOLE_MESSAGE_LEVEL_ERROR,
347 kSilentPushUnsupportedMessage);
348
336 SubscribeEnd(callback, 349 SubscribeEnd(callback,
337 std::string(), 350 std::string(),
338 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); 351 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED);
339 return; 352 return;
340 } 353 }
341 354
342 // TODO(miguelg): Consider the value of |user_visible| when making the 355 // TODO(miguelg): Consider the value of |user_visible| when making the
343 // permission request. 356 // permission request.
344 // TODO(mlamouri): Move requesting Push permission over to using Mojo, and 357 // TODO(mlamouri): Move requesting Push permission over to using Mojo, and
345 // re-introduce the ability of |user_gesture| when bubbles require this. 358 // re-introduce the ability of |user_gesture| when bubbles require this.
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 CONTENT_SETTING_ALLOW; 653 CONTENT_SETTING_ALLOW;
641 } 654 }
642 655
643 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { 656 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const {
644 gcm::GCMProfileService* gcm_profile_service = 657 gcm::GCMProfileService* gcm_profile_service =
645 gcm::GCMProfileServiceFactory::GetForProfile(profile_); 658 gcm::GCMProfileServiceFactory::GetForProfile(profile_);
646 CHECK(gcm_profile_service); 659 CHECK(gcm_profile_service);
647 CHECK(gcm_profile_service->driver()); 660 CHECK(gcm_profile_service->driver());
648 return gcm_profile_service->driver(); 661 return gcm_profile_service->driver();
649 } 662 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698