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

Side by Side Diff: content/renderer/push_messaging/push_messaging_dispatcher.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: Created 5 years, 7 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
« no previous file with comments | « content/renderer/manifest/manifest_parser_unittest.cc ('k') | no next file » | 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 "content/renderer/push_messaging/push_messaging_dispatcher.h" 5 #include "content/renderer/push_messaging/push_messaging_dispatcher.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/child/service_worker/web_service_worker_registration_impl.h" 8 #include "content/child/service_worker/web_service_worker_registration_impl.h"
9 #include "content/common/push_messaging_messages.h" 9 #include "content/common/push_messaging_messages.h"
10 #include "content/renderer/manifest/manifest_manager.h" 10 #include "content/renderer/manifest/manifest_manager.h"
11 #include "content/renderer/render_frame_impl.h" 11 #include "content/renderer/render_frame_impl.h"
12 #include "ipc/ipc_message.h" 12 #include "ipc/ipc_message.h"
13 #include "third_party/WebKit/public/platform/WebServiceWorkerRegistration.h" 13 #include "third_party/WebKit/public/platform/WebServiceWorkerRegistration.h"
14 #include "third_party/WebKit/public/platform/WebString.h" 14 #include "third_party/WebKit/public/platform/WebString.h"
15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError .h" 15 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError .h"
16 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc ription.h" 16 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc ription.h"
17 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc riptionOptions.h" 17 #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushSubsc riptionOptions.h"
18 #include "third_party/WebKit/public/web/WebConsoleMessage.h" 18 #include "third_party/WebKit/public/web/WebConsoleMessage.h"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h" 19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 using blink::WebString; 22 using blink::WebString;
23 23
24 namespace content { 24 namespace content {
25 25
26 const char kManifestDeprecationWarning[] =
27 "The 'gcm_user_visible_only' manifest key is deprecated and will be "
28 "removed in Chrome 45, around August 2015. Use pushManager.subscribe({"
29 "userVisibleOnly: true}) instead. See https://goo.gl/RHFwWx for more "
30 "details.";
31
32 PushMessagingDispatcher::PushMessagingDispatcher(RenderFrame* render_frame) 26 PushMessagingDispatcher::PushMessagingDispatcher(RenderFrame* render_frame)
33 : RenderFrameObserver(render_frame) { 27 : RenderFrameObserver(render_frame) {
34 } 28 }
35 29
36 PushMessagingDispatcher::~PushMessagingDispatcher() {} 30 PushMessagingDispatcher::~PushMessagingDispatcher() {}
37 31
38 bool PushMessagingDispatcher::OnMessageReceived(const IPC::Message& message) { 32 bool PushMessagingDispatcher::OnMessageReceived(const IPC::Message& message) {
39 bool handled = true; 33 bool handled = true;
40 IPC_BEGIN_MESSAGE_MAP(PushMessagingDispatcher, message) 34 IPC_BEGIN_MESSAGE_MAP(PushMessagingDispatcher, message)
41 IPC_MESSAGE_HANDLER(PushMessagingMsg_SubscribeFromDocumentSuccess, 35 IPC_MESSAGE_HANDLER(PushMessagingMsg_SubscribeFromDocumentSuccess,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 std::string sender_id = 69 std::string sender_id =
76 manifest.gcm_sender_id.is_null() 70 manifest.gcm_sender_id.is_null()
77 ? std::string() 71 ? std::string()
78 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()); 72 : base::UTF16ToUTF8(manifest.gcm_sender_id.string());
79 if (sender_id.empty()) { 73 if (sender_id.empty()) {
80 OnSubscribeFromDocumentError(request_id, 74 OnSubscribeFromDocumentError(request_id,
81 PUSH_REGISTRATION_STATUS_NO_SENDER_ID); 75 PUSH_REGISTRATION_STATUS_NO_SENDER_ID);
82 return; 76 return;
83 } 77 }
84 78
85 // Support for the "gcm_user_visible_only" Manifest key has been deprecated
86 // in favor of the userVisibleOnly subscription option, and will be removed
87 // in a future Chrome release. Inform developers of this deprecation.
88 if (manifest.gcm_user_visible_only && !options.userVisibleOnly) {
89 blink::WebConsoleMessage message(
90 blink::WebConsoleMessage::LevelWarning,
91 blink::WebString::fromUTF8(kManifestDeprecationWarning));
92
93 render_frame()->GetWebFrame()->addMessageToConsole(message);
johnme 2015/05/28 12:35:12 Please continue logging a warning, since developer
Peter Beverloo 2015/05/29 14:15:31 I agree with the warning, but we shouldn't have it
94 }
95
96 const bool user_visible = manifest.gcm_user_visible_only ||
97 options.userVisibleOnly;
98
99 Send(new PushMessagingHostMsg_SubscribeFromDocument( 79 Send(new PushMessagingHostMsg_SubscribeFromDocument(
100 routing_id(), request_id, 80 routing_id(), request_id,
101 manifest.gcm_sender_id.is_null() 81 manifest.gcm_sender_id.is_null()
102 ? std::string() 82 ? std::string()
103 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()), 83 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()),
104 user_visible, service_worker_registration_id)); 84 options.userVisibleOnly, service_worker_registration_id));
105 } 85 }
106 86
107 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( 87 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess(
108 int32_t request_id, 88 int32_t request_id,
109 const GURL& endpoint, 89 const GURL& endpoint,
110 const std::string& subscription_id) { 90 const std::string& subscription_id) {
111 blink::WebPushSubscriptionCallbacks* callbacks = 91 blink::WebPushSubscriptionCallbacks* callbacks =
112 subscription_callbacks_.Lookup(request_id); 92 subscription_callbacks_.Lookup(request_id);
113 DCHECK(callbacks); 93 DCHECK(callbacks);
114 94
(...skipping 15 matching lines...) Expand all
130 110
131 scoped_ptr<blink::WebPushError> error(new blink::WebPushError( 111 scoped_ptr<blink::WebPushError> error(new blink::WebPushError(
132 blink::WebPushError::ErrorTypeAbort, 112 blink::WebPushError::ErrorTypeAbort,
133 WebString::fromUTF8(PushRegistrationStatusToString(status)))); 113 WebString::fromUTF8(PushRegistrationStatusToString(status))));
134 callbacks->onError(error.release()); 114 callbacks->onError(error.release());
135 115
136 subscription_callbacks_.Remove(request_id); 116 subscription_callbacks_.Remove(request_id);
137 } 117 }
138 118
139 } // namespace content 119 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/manifest/manifest_parser_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698