| Index: content/renderer/push_messaging/push_messaging_dispatcher.cc | 
| diff --git a/content/renderer/push_messaging/push_messaging_dispatcher.cc b/content/renderer/push_messaging/push_messaging_dispatcher.cc | 
| index d10704326e5bef8cc6626fbf62476646b96c8eaa..ef35db5961171ebbe01d7363f7a2ac3ebc76e4d4 100644 | 
| --- a/content/renderer/push_messaging/push_messaging_dispatcher.cc | 
| +++ b/content/renderer/push_messaging/push_messaging_dispatcher.cc | 
| @@ -44,46 +44,63 @@ void PushMessagingDispatcher::subscribe( | 
| blink::WebPushSubscriptionCallbacks* callbacks) { | 
| DCHECK(service_worker_registration); | 
| DCHECK(callbacks); | 
| -  RenderFrameImpl::FromRoutingID(routing_id()) | 
| -      ->manifest_manager() | 
| -      ->GetManifest(base::Bind( | 
| -          &PushMessagingDispatcher::DoSubscribe, base::Unretained(this), | 
| -          service_worker_registration, options, callbacks)); | 
| +  // If a developer provided an application server key in |options|, skip | 
| +  // fetching the manifest. | 
| +  if (options.applicationServerKey.isEmpty()) { | 
| +    RenderFrameImpl::FromRoutingID(routing_id()) | 
| +        ->manifest_manager() | 
| +        ->GetManifest(base::Bind( | 
| +            &PushMessagingDispatcher::DidGetManifest, base::Unretained(this), | 
| +            service_worker_registration, options, callbacks)); | 
| +  } else { | 
| +    PushSubscriptionOptions content_options; | 
| +    content_options.user_visible_only = options.userVisibleOnly; | 
| +    content_options.sender_info = options.applicationServerKey.utf8(); | 
| +    DoSubscribe(service_worker_registration, content_options, callbacks); | 
| +  } | 
| } | 
|  | 
| -void PushMessagingDispatcher::DoSubscribe( | 
| +void PushMessagingDispatcher::DidGetManifest( | 
| blink::WebServiceWorkerRegistration* service_worker_registration, | 
| const blink::WebPushSubscriptionOptions& options, | 
| blink::WebPushSubscriptionCallbacks* callbacks, | 
| const Manifest& manifest) { | 
| int request_id = subscription_callbacks_.Add(callbacks); | 
| -  int64_t service_worker_registration_id = | 
| -      static_cast<WebServiceWorkerRegistrationImpl*>( | 
| -          service_worker_registration) | 
| -          ->registration_id(); | 
| - | 
| +  // Get the sender_info from the manifest since it wasn't provided by | 
| +  // the caller. | 
| if (manifest.IsEmpty()) { | 
| OnSubscribeFromDocumentError( | 
| request_id, PUSH_REGISTRATION_STATUS_MANIFEST_EMPTY_OR_MISSING); | 
| return; | 
| } | 
|  | 
| -  std::string sender_id = | 
| -      manifest.gcm_sender_id.is_null() | 
| -          ? std::string() | 
| -          : base::UTF16ToUTF8(manifest.gcm_sender_id.string()); | 
| -  if (sender_id.empty()) { | 
| +  PushSubscriptionOptions content_options; | 
| +  content_options.user_visible_only = options.userVisibleOnly; | 
| +  if (!manifest.gcm_sender_id.is_null()) { | 
| +    content_options.sender_info = | 
| +        base::UTF16ToUTF8(manifest.gcm_sender_id.string()); | 
| +  } | 
| + | 
| +  DoSubscribe(service_worker_registration, content_options, callbacks); | 
| +} | 
| + | 
| +void PushMessagingDispatcher::DoSubscribe( | 
| +    blink::WebServiceWorkerRegistration* service_worker_registration, | 
| +    const PushSubscriptionOptions& options, | 
| +    blink::WebPushSubscriptionCallbacks* callbacks) { | 
| +  int request_id = subscription_callbacks_.Add(callbacks); | 
| +  int64_t service_worker_registration_id = | 
| +      static_cast<WebServiceWorkerRegistrationImpl*>( | 
| +          service_worker_registration) | 
| +          ->registration_id(); | 
| + | 
| +  if (options.sender_info.empty()) { | 
| OnSubscribeFromDocumentError(request_id, | 
| PUSH_REGISTRATION_STATUS_NO_SENDER_ID); | 
| return; | 
| } | 
| - | 
| Send(new PushMessagingHostMsg_SubscribeFromDocument( | 
| -      routing_id(), request_id, | 
| -      manifest.gcm_sender_id.is_null() | 
| -          ? std::string() | 
| -          : base::UTF16ToUTF8(manifest.gcm_sender_id.string()), | 
| -      options.userVisibleOnly, service_worker_registration_id)); | 
| +      routing_id(), request_id, options, service_worker_registration_id)); | 
| } | 
|  | 
| void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( | 
|  |