OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/active_notification_tracker.h" | 5 #include "content/renderer/active_notification_tracker.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "third_party/WebKit/public/web/WebNotification.h" | 9 #include "third_party/WebKit/public/web/WebNotification.h" |
10 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" | 10 #include "third_party/WebKit/public/web/WebNotificationPermissionCallback.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 reverse_notification_table_.erase(*notification); | 59 reverse_notification_table_.erase(*notification); |
60 } | 60 } |
61 | 61 |
62 void ActiveNotificationTracker::Clear() { | 62 void ActiveNotificationTracker::Clear() { |
63 while (!reverse_notification_table_.empty()) { | 63 while (!reverse_notification_table_.empty()) { |
64 ReverseTable::iterator iter = reverse_notification_table_.begin(); | 64 ReverseTable::iterator iter = reverse_notification_table_.begin(); |
65 UnregisterNotification((*iter).second); | 65 UnregisterNotification((*iter).second); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 void ActiveNotificationTracker::DetachAll() { | |
70 ReverseTable::iterator iter; | |
71 for (iter = reverse_notification_table_.begin(); | |
72 iter != reverse_notification_table_.end(); | |
73 ++iter) { | |
74 WebNotification notification(iter->first); | |
75 notification.detachPresenter(); | |
76 } | |
77 } | |
78 | |
79 WebNotificationPermissionCallback* ActiveNotificationTracker::GetCallback( | 69 WebNotificationPermissionCallback* ActiveNotificationTracker::GetCallback( |
80 int id) { | 70 int id) { |
81 return callback_table_.Lookup(id); | 71 return callback_table_.Lookup(id); |
82 } | 72 } |
83 | 73 |
84 int ActiveNotificationTracker::RegisterPermissionRequest( | 74 int ActiveNotificationTracker::RegisterPermissionRequest( |
85 WebNotificationPermissionCallback* callback) { | 75 WebNotificationPermissionCallback* callback) { |
86 return callback_table_.Add(callback); | 76 return callback_table_.Add(callback); |
87 } | 77 } |
88 | 78 |
89 void ActiveNotificationTracker::OnPermissionRequestComplete(int id) { | 79 void ActiveNotificationTracker::OnPermissionRequestComplete(int id) { |
90 callback_table_.Remove(id); | 80 callback_table_.Remove(id); |
91 } | 81 } |
92 | 82 |
93 } // namespace content | 83 } // namespace content |
OLD | NEW |