| 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/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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 383 web_contents->GetMainFrame()->AddMessageToConsole( | 383 web_contents->GetMainFrame()->AddMessageToConsole( |
| 384 content::CONSOLE_MESSAGE_LEVEL_ERROR, | 384 content::CONSOLE_MESSAGE_LEVEL_ERROR, |
| 385 kSilentPushUnsupportedMessage); | 385 kSilentPushUnsupportedMessage); |
| 386 | 386 |
| 387 SubscribeEndWithError(callback, | 387 SubscribeEndWithError(callback, |
| 388 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); | 388 content::PUSH_REGISTRATION_STATUS_PERMISSION_DENIED); |
| 389 return; | 389 return; |
| 390 } | 390 } |
| 391 | 391 |
| 392 // Push does not allow permission requests from iframes. | 392 // Push does not allow permission requests from iframes. |
| 393 int request_id = -1; | |
| 394 | |
| 395 profile_->GetPermissionManager()->RequestPermission( | 393 profile_->GetPermissionManager()->RequestPermission( |
| 396 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(), | 394 content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(), |
| 397 request_id, requesting_origin, true /* user_gesture */, | 395 requesting_origin, true /* user_gesture */, |
| 398 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, | 396 base::Bind(&PushMessagingServiceImpl::DidRequestPermission, |
| 399 weak_factory_.GetWeakPtr(), app_identifier, sender_id, | 397 weak_factory_.GetWeakPtr(), app_identifier, sender_id, |
| 400 callback)); | 398 callback)); |
| 401 } | 399 } |
| 402 | 400 |
| 403 void PushMessagingServiceImpl::SubscribeFromWorker( | 401 void PushMessagingServiceImpl::SubscribeFromWorker( |
| 404 const GURL& requesting_origin, | 402 const GURL& requesting_origin, |
| 405 int64 service_worker_registration_id, | 403 int64 service_worker_registration_id, |
| 406 const std::string& sender_id, | 404 const std::string& sender_id, |
| 407 bool user_visible, | 405 bool user_visible, |
| (...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 switches::kEnablePushMessagePayload); | 783 switches::kEnablePushMessagePayload); |
| 786 } | 784 } |
| 787 | 785 |
| 788 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { | 786 gcm::GCMDriver* PushMessagingServiceImpl::GetGCMDriver() const { |
| 789 gcm::GCMProfileService* gcm_profile_service = | 787 gcm::GCMProfileService* gcm_profile_service = |
| 790 gcm::GCMProfileServiceFactory::GetForProfile(profile_); | 788 gcm::GCMProfileServiceFactory::GetForProfile(profile_); |
| 791 CHECK(gcm_profile_service); | 789 CHECK(gcm_profile_service); |
| 792 CHECK(gcm_profile_service->driver()); | 790 CHECK(gcm_profile_service->driver()); |
| 793 return gcm_profile_service->driver(); | 791 return gcm_profile_service->driver(); |
| 794 } | 792 } |
| OLD | NEW |