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

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

Issue 2555833002: Remove enable_notifications build flag and define (Closed)
Patch Set: Merge Created 4 years 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
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_service_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 PushMessagingServiceImpl* push_service = 180 PushMessagingServiceImpl* push_service =
181 PushMessagingServiceFactory::GetForProfile(profile); 181 PushMessagingServiceFactory::GetForProfile(profile);
182 push_service->IncreasePushSubscriptionCount(count, false /* is_pending */); 182 push_service->IncreasePushSubscriptionCount(count, false /* is_pending */);
183 } 183 }
184 184
185 PushMessagingServiceImpl::PushMessagingServiceImpl(Profile* profile) 185 PushMessagingServiceImpl::PushMessagingServiceImpl(Profile* profile)
186 : profile_(profile), 186 : profile_(profile),
187 push_subscription_count_(0), 187 push_subscription_count_(0),
188 pending_push_subscription_count_(0), 188 pending_push_subscription_count_(0),
189 #if defined(ENABLE_NOTIFICATIONS)
190 notification_manager_(profile), 189 notification_manager_(profile),
191 #endif
192 push_messaging_service_observer_(PushMessagingServiceObserver::Create()), 190 push_messaging_service_observer_(PushMessagingServiceObserver::Create()),
193 weak_factory_(this) { 191 weak_factory_(this) {
194 DCHECK(profile); 192 DCHECK(profile);
195 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this); 193 HostContentSettingsMapFactory::GetForProfile(profile_)->AddObserver(this);
196 } 194 }
197 195
198 PushMessagingServiceImpl::~PushMessagingServiceImpl() { 196 PushMessagingServiceImpl::~PushMessagingServiceImpl() {
199 HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this); 197 HostContentSettingsMapFactory::GetForProfile(profile_)->RemoveObserver(this);
200 } 198 }
201 199
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 // Service Worker corresponding to app_id (and/or on an internals page). 365 // Service Worker corresponding to app_id (and/or on an internals page).
368 // See https://crbug.com/508516 for options. 366 // See https://crbug.com/508516 for options.
369 switch (status) { 367 switch (status) {
370 // Call EnforceUserVisibleOnlyRequirements if the message was delivered to 368 // Call EnforceUserVisibleOnlyRequirements if the message was delivered to
371 // the Service Worker JavaScript, even if the website's event handler failed 369 // the Service Worker JavaScript, even if the website's event handler failed
372 // (to prevent sites deliberately failing in order to avoid having to show 370 // (to prevent sites deliberately failing in order to avoid having to show
373 // notifications). 371 // notifications).
374 case content::PUSH_DELIVERY_STATUS_SUCCESS: 372 case content::PUSH_DELIVERY_STATUS_SUCCESS:
375 case content::PUSH_DELIVERY_STATUS_EVENT_WAITUNTIL_REJECTED: 373 case content::PUSH_DELIVERY_STATUS_EVENT_WAITUNTIL_REJECTED:
376 case content::PUSH_DELIVERY_STATUS_TIMEOUT: 374 case content::PUSH_DELIVERY_STATUS_TIMEOUT:
377 #if defined(ENABLE_NOTIFICATIONS)
378 // Only enforce the user visible requirements if this is currently running 375 // Only enforce the user visible requirements if this is currently running
379 // as the delivery callback for the last in-flight message, and silent 376 // as the delivery callback for the last in-flight message, and silent
380 // push has not been enabled through a command line flag. 377 // push has not been enabled through a command line flag.
381 if (in_flight_message_deliveries_.count(app_id) == 1 && 378 if (in_flight_message_deliveries_.count(app_id) == 1 &&
382 !base::CommandLine::ForCurrentProcess()->HasSwitch( 379 !base::CommandLine::ForCurrentProcess()->HasSwitch(
383 switches::kAllowSilentPush)) { 380 switches::kAllowSilentPush)) {
384 notification_manager_.EnforceUserVisibleOnlyRequirements( 381 notification_manager_.EnforceUserVisibleOnlyRequirements(
385 requesting_origin, service_worker_registration_id, 382 requesting_origin, service_worker_registration_id,
386 completion_closure_runner.Release()); 383 completion_closure_runner.Release());
387 } 384 }
388 #endif
389 break; 385 break;
390 case content::PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR: 386 case content::PUSH_DELIVERY_STATUS_SERVICE_WORKER_ERROR:
391 // Do nothing, and hope the error is transient. 387 // Do nothing, and hope the error is transient.
392 break; 388 break;
393 case content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID: 389 case content::PUSH_DELIVERY_STATUS_UNKNOWN_APP_ID:
394 unsubscribe_reason = 390 unsubscribe_reason =
395 content::PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID; 391 content::PUSH_UNREGISTRATION_REASON_DELIVERY_UNKNOWN_APP_ID;
396 break; 392 break;
397 case content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED: 393 case content::PUSH_DELIVERY_STATUS_PERMISSION_DENIED:
398 unsubscribe_reason = 394 unsubscribe_reason =
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 } 969 }
974 970
975 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver() 971 instance_id::InstanceIDDriver* PushMessagingServiceImpl::GetInstanceIDDriver()
976 const { 972 const {
977 instance_id::InstanceIDProfileService* instance_id_profile_service = 973 instance_id::InstanceIDProfileService* instance_id_profile_service =
978 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_); 974 instance_id::InstanceIDProfileServiceFactory::GetForProfile(profile_);
979 CHECK(instance_id_profile_service); 975 CHECK(instance_id_profile_service);
980 CHECK(instance_id_profile_service->driver()); 976 CHECK(instance_id_profile_service->driver());
981 return instance_id_profile_service->driver(); 977 return instance_id_profile_service->driver();
982 } 978 }
OLDNEW
« no previous file with comments | « chrome/browser/push_messaging/push_messaging_service_impl.h ('k') | chrome/test/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698