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

Side by Side Diff: content/renderer/notification_provider.cc

Issue 687183004: Remove the OnError method from notification delegates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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/notification_provider.h ('k') | ui/message_center/notification.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/notification_provider.h" 5 #include "content/renderer/notification_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "content/common/desktop_notification_messages.h" 10 #include "content/common/desktop_notification_messages.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 routing_id(), 111 routing_id(),
112 GURL(origin.toString()), 112 GURL(origin.toString()),
113 &permission)); 113 &permission));
114 return static_cast<WebNotificationPresenter::Permission>(permission); 114 return static_cast<WebNotificationPresenter::Permission>(permission);
115 } 115 }
116 116
117 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { 117 bool NotificationProvider::OnMessageReceived(const IPC::Message& message) {
118 bool handled = true; 118 bool handled = true;
119 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message) 119 IPC_BEGIN_MESSAGE_MAP(NotificationProvider, message)
120 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay); 120 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostDisplay, OnDisplay);
121 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostError, OnError);
122 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose); 121 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClose, OnClose);
123 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick); 122 IPC_MESSAGE_HANDLER(DesktopNotificationMsg_PostClick, OnClick);
124 IPC_MESSAGE_UNHANDLED(handled = false) 123 IPC_MESSAGE_UNHANDLED(handled = false)
125 IPC_END_MESSAGE_MAP() 124 IPC_END_MESSAGE_MAP()
126 125
127 if (message.type() == FrameMsg_Navigate::ID) 126 if (message.type() == FrameMsg_Navigate::ID)
128 OnNavigate(); // Don't want to swallow the message. 127 OnNavigate(); // Don't want to swallow the message.
129 128
130 return handled; 129 return handled;
131 } 130 }
132 131
133 void NotificationProvider::OnDisplay(int id) { 132 void NotificationProvider::OnDisplay(int id) {
134 WebNotification notification; 133 WebNotification notification;
135 bool found = manager_.GetNotification(id, &notification); 134 bool found = manager_.GetNotification(id, &notification);
136 // |found| may be false if the WebNotification went out of scope in 135 // |found| may be false if the WebNotification went out of scope in
137 // the page before it was actually displayed to the user. 136 // the page before it was actually displayed to the user.
138 if (found) 137 if (found)
139 notification.dispatchDisplayEvent(); 138 notification.dispatchDisplayEvent();
140 } 139 }
141 140
142 void NotificationProvider::OnError(int id) {
143 WebNotification notification;
144 bool found = manager_.GetNotification(id, &notification);
145 // |found| may be false if the WebNotification went out of scope in
146 // the page before the error occurred.
147 if (found)
148 notification.dispatchErrorEvent(WebString());
149 }
150
151 void NotificationProvider::OnClose(int id, bool by_user) { 141 void NotificationProvider::OnClose(int id, bool by_user) {
152 WebNotification notification; 142 WebNotification notification;
153 bool found = manager_.GetNotification(id, &notification); 143 bool found = manager_.GetNotification(id, &notification);
154 // |found| may be false if the WebNotification went out of scope in 144 // |found| may be false if the WebNotification went out of scope in
155 // the page before the associated toast was closed by the user. 145 // the page before the associated toast was closed by the user.
156 if (found) { 146 if (found) {
157 notification.dispatchCloseEvent(by_user); 147 notification.dispatchCloseEvent(by_user);
158 manager_.UnregisterNotification(id); 148 manager_.UnregisterNotification(id);
159 } 149 }
160 } 150 }
161 151
162 void NotificationProvider::OnClick(int id) { 152 void NotificationProvider::OnClick(int id) {
163 WebNotification notification; 153 WebNotification notification;
164 bool found = manager_.GetNotification(id, &notification); 154 bool found = manager_.GetNotification(id, &notification);
165 // |found| may be false if the WebNotification went out of scope in 155 // |found| may be false if the WebNotification went out of scope in
166 // the page before the associated toast was clicked on. 156 // the page before the associated toast was clicked on.
167 if (found) 157 if (found)
168 notification.dispatchClickEvent(); 158 notification.dispatchClickEvent();
169 } 159 }
170 160
171 void NotificationProvider::OnNavigate() { 161 void NotificationProvider::OnNavigate() {
172 manager_.Clear(); 162 manager_.Clear();
173 } 163 }
174 164
175 } // namespace content 165 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/notification_provider.h ('k') | ui/message_center/notification.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698