| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/renderer/notification_provider.h" | 5 #include "chrome/renderer/notification_provider.h" |
| 6 | 6 |
| 7 #include "base/string_util.h" | 7 #include "base/string_util.h" |
| 8 #include "base/task.h" | 8 #include "base/task.h" |
| 9 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
| 10 #include "chrome/common/url_constants.h" | 10 #include "chrome/common/url_constants.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 void NotificationProvider::objectDestroyed( | 45 void NotificationProvider::objectDestroyed( |
| 46 const WebNotification& notification) { | 46 const WebNotification& notification) { |
| 47 int id; | 47 int id; |
| 48 bool id_found = manager_.GetId(notification, id); | 48 bool id_found = manager_.GetId(notification, id); |
| 49 // Won't be found if the notification has already been closed by the user. | 49 // Won't be found if the notification has already been closed by the user. |
| 50 if (id_found) | 50 if (id_found) |
| 51 manager_.UnregisterNotification(id); | 51 manager_.UnregisterNotification(id); |
| 52 } | 52 } |
| 53 | 53 |
| 54 WebNotificationPresenter::Permission NotificationProvider::checkPermission( | 54 WebNotificationPresenter::Permission NotificationProvider::checkPermission( |
| 55 const WebURL& url, WebDocument* document) { | 55 const WebURL& url) { |
| 56 int permission; | 56 int permission; |
| 57 Send(new ViewHostMsg_CheckNotificationPermission( | 57 Send(new ViewHostMsg_CheckNotificationPermission( |
| 58 view_->routing_id(), | 58 view_->routing_id(), |
| 59 url, | 59 url, |
| 60 document ? UTF16ToASCII(document->applicationID()) : "", | |
| 61 &permission)); | 60 &permission)); |
| 62 return static_cast<WebNotificationPresenter::Permission>(permission); | 61 return static_cast<WebNotificationPresenter::Permission>(permission); |
| 63 } | 62 } |
| 64 | 63 |
| 65 void NotificationProvider::requestPermission( | 64 void NotificationProvider::requestPermission( |
| 66 const WebString& origin, WebNotificationPermissionCallback* callback) { | 65 const WebString& origin, WebNotificationPermissionCallback* callback) { |
| 67 // We only request permission in response to a user gesture. | 66 // We only request permission in response to a user gesture. |
| 68 if (!view_->webview()->mainFrame()->isProcessingUserGesture()) | 67 if (!view_->webview()->mainFrame()->isProcessingUserGesture()) |
| 69 return; | 68 return; |
| 70 | 69 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 void NotificationProvider::OnPermissionRequestComplete(int id) { | 146 void NotificationProvider::OnPermissionRequestComplete(int id) { |
| 148 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); | 147 WebNotificationPermissionCallback* callback = manager_.GetCallback(id); |
| 149 DCHECK(callback); | 148 DCHECK(callback); |
| 150 callback->permissionRequestComplete(); | 149 callback->permissionRequestComplete(); |
| 151 manager_.OnPermissionRequestComplete(id); | 150 manager_.OnPermissionRequestComplete(id); |
| 152 } | 151 } |
| 153 | 152 |
| 154 bool NotificationProvider::Send(IPC::Message* message) { | 153 bool NotificationProvider::Send(IPC::Message* message) { |
| 155 return RenderThread::current()->Send(message); | 154 return RenderThread::current()->Send(message); |
| 156 } | 155 } |
| OLD | NEW |