| 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/services/gcm/push_messaging_service_impl.h" | 5 #include "chrome/browser/services/gcm/push_messaging_service_impl.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 GURL PushMessagingServiceImpl::PushEndpoint() { | 222 GURL PushMessagingServiceImpl::PushEndpoint() { |
| 223 return GURL(std::string(kPushMessagingEndpoint)); | 223 return GURL(std::string(kPushMessagingEndpoint)); |
| 224 } | 224 } |
| 225 | 225 |
| 226 void PushMessagingServiceImpl::RegisterFromDocument( | 226 void PushMessagingServiceImpl::RegisterFromDocument( |
| 227 const GURL& requesting_origin, | 227 const GURL& requesting_origin, |
| 228 int64 service_worker_registration_id, | 228 int64 service_worker_registration_id, |
| 229 const std::string& sender_id, | 229 const std::string& sender_id, |
| 230 int renderer_id, | 230 int renderer_id, |
| 231 int render_frame_id, | 231 int render_frame_id, |
| 232 bool user_gesture, | 232 bool user_visible_only, |
| 233 const content::PushMessagingService::RegisterCallback& callback) { | 233 const content::PushMessagingService::RegisterCallback& callback) { |
| 234 if (!gcm_profile_service_->driver()) { | 234 if (!gcm_profile_service_->driver()) { |
| 235 NOTREACHED() << "There is no GCMDriver. Has GCMProfileService shut down?"; | 235 NOTREACHED() << "There is no GCMDriver. Has GCMProfileService shut down?"; |
| 236 return; | 236 return; |
| 237 } | 237 } |
| 238 | 238 |
| 239 PushMessagingApplicationId application_id = PushMessagingApplicationId( | 239 PushMessagingApplicationId application_id = PushMessagingApplicationId( |
| 240 requesting_origin, service_worker_registration_id); | 240 requesting_origin, service_worker_registration_id); |
| 241 DCHECK(application_id.IsValid()); | 241 DCHECK(application_id.IsValid()); |
| 242 | 242 |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 gcm::PushMessagingPermissionContext* permission_context = | 275 gcm::PushMessagingPermissionContext* permission_context = |
| 276 gcm::PushMessagingPermissionContextFactory::GetForProfile(profile_); | 276 gcm::PushMessagingPermissionContextFactory::GetForProfile(profile_); |
| 277 | 277 |
| 278 if (permission_context == NULL) { | 278 if (permission_context == NULL) { |
| 279 RegisterEnd(callback, | 279 RegisterEnd(callback, |
| 280 std::string(), | 280 std::string(), |
| 281 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 281 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); |
| 282 return; | 282 return; |
| 283 } | 283 } |
| 284 | 284 |
| 285 // TODO(miguelg): Consider the value of |user_visible_only| when making |
| 286 // the permission request. |
| 287 // TODO(mlamouri): Move requesting Push permission over to using Mojo, and |
| 288 // re-introduce the ability of |user_gesture| when bubbles require this. |
| 285 permission_context->RequestPermission( | 289 permission_context->RequestPermission( |
| 286 web_contents, id, embedding_origin, user_gesture, | 290 web_contents, id, embedding_origin, true /* user_gesture */, |
| 287 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, | 291 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, |
| 288 weak_factory_.GetWeakPtr(), application_id, sender_id, | 292 weak_factory_.GetWeakPtr(), application_id, sender_id, |
| 289 callback)); | 293 callback)); |
| 290 } | 294 } |
| 291 | 295 |
| 292 void PushMessagingServiceImpl::RegisterFromWorker( | 296 void PushMessagingServiceImpl::RegisterFromWorker( |
| 293 const GURL& requesting_origin, | 297 const GURL& requesting_origin, |
| 294 int64 service_worker_registration_id, | 298 int64 service_worker_registration_id, |
| 295 const std::string& sender_id, | 299 const std::string& sender_id, |
| 296 const content::PushMessagingService::RegisterCallback& register_callback) { | 300 const content::PushMessagingService::RegisterCallback& register_callback) { |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 } | 441 } |
| 438 | 442 |
| 439 void PushMessagingServiceImpl::AddAppHandlerIfNecessary() { | 443 void PushMessagingServiceImpl::AddAppHandlerIfNecessary() { |
| 440 if (gcm_profile_service_->driver()->GetAppHandler( | 444 if (gcm_profile_service_->driver()->GetAppHandler( |
| 441 kPushMessagingApplicationIdPrefix) != this) | 445 kPushMessagingApplicationIdPrefix) != this) |
| 442 gcm_profile_service_->driver()->AddAppHandler( | 446 gcm_profile_service_->driver()->AddAppHandler( |
| 443 kPushMessagingApplicationIdPrefix, this); | 447 kPushMessagingApplicationIdPrefix, this); |
| 444 } | 448 } |
| 445 | 449 |
| 446 } // namespace gcm | 450 } // namespace gcm |
| OLD | NEW |