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

Side by Side Diff: content/renderer/push_messaging/push_messaging_dispatcher.cc

Issue 1145163002: Include a deprecation warning when people only use "gcm_user_visible_only". (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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 | « no previous file | 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"
19 #include "third_party/WebKit/public/web/WebLocalFrame.h"
18 #include "url/gurl.h" 20 #include "url/gurl.h"
19 21
20 using blink::WebString; 22 using blink::WebString;
21 23
22 namespace content { 24 namespace content {
23 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
24 PushMessagingDispatcher::PushMessagingDispatcher(RenderFrame* render_frame) 32 PushMessagingDispatcher::PushMessagingDispatcher(RenderFrame* render_frame)
25 : RenderFrameObserver(render_frame) { 33 : RenderFrameObserver(render_frame) {
26 } 34 }
27 35
28 PushMessagingDispatcher::~PushMessagingDispatcher() {} 36 PushMessagingDispatcher::~PushMessagingDispatcher() {}
29 37
30 bool PushMessagingDispatcher::OnMessageReceived(const IPC::Message& message) { 38 bool PushMessagingDispatcher::OnMessageReceived(const IPC::Message& message) {
31 bool handled = true; 39 bool handled = true;
32 IPC_BEGIN_MESSAGE_MAP(PushMessagingDispatcher, message) 40 IPC_BEGIN_MESSAGE_MAP(PushMessagingDispatcher, message)
33 IPC_MESSAGE_HANDLER(PushMessagingMsg_RegisterFromDocumentSuccess, 41 IPC_MESSAGE_HANDLER(PushMessagingMsg_RegisterFromDocumentSuccess,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 std::string sender_id = 75 std::string sender_id =
68 manifest.gcm_sender_id.is_null() 76 manifest.gcm_sender_id.is_null()
69 ? std::string() 77 ? std::string()
70 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()); 78 : base::UTF16ToUTF8(manifest.gcm_sender_id.string());
71 if (sender_id.empty()) { 79 if (sender_id.empty()) {
72 OnRegisterFromDocumentError(request_id, 80 OnRegisterFromDocumentError(request_id,
73 PUSH_REGISTRATION_STATUS_NO_SENDER_ID); 81 PUSH_REGISTRATION_STATUS_NO_SENDER_ID);
74 return; 82 return;
75 } 83 }
76 84
77 // TODO(peter): Display a deprecation warning if gcm_user_visible_only is 85 // Support for the "gcm_user_visible_only" Manifest key has been deprecated
78 // set to true. See https://crbug.com/471534 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);
94 }
95
79 const bool user_visible = manifest.gcm_user_visible_only || 96 const bool user_visible = manifest.gcm_user_visible_only ||
80 options.userVisibleOnly; 97 options.userVisibleOnly;
81 98
82 Send(new PushMessagingHostMsg_RegisterFromDocument( 99 Send(new PushMessagingHostMsg_RegisterFromDocument(
83 routing_id(), request_id, 100 routing_id(), request_id,
84 manifest.gcm_sender_id.is_null() 101 manifest.gcm_sender_id.is_null()
85 ? std::string() 102 ? std::string()
86 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()), 103 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()),
87 user_visible, service_worker_registration_id)); 104 user_visible, service_worker_registration_id));
88 } 105 }
(...skipping 24 matching lines...) Expand all
113 130
114 scoped_ptr<blink::WebPushError> error(new blink::WebPushError( 131 scoped_ptr<blink::WebPushError> error(new blink::WebPushError(
115 blink::WebPushError::ErrorTypeAbort, 132 blink::WebPushError::ErrorTypeAbort,
116 WebString::fromUTF8(PushRegistrationStatusToString(status)))); 133 WebString::fromUTF8(PushRegistrationStatusToString(status))));
117 callbacks->onError(error.release()); 134 callbacks->onError(error.release());
118 135
119 subscription_callbacks_.Remove(request_id); 136 subscription_callbacks_.Remove(request_id);
120 } 137 }
121 138
122 } // namespace content 139 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698