diff options
5 files changed, 24 insertions, 3 deletions
diff --git a/chrome/common/desktop_notifications/active_notification_tracker.cc b/chrome/common/desktop_notifications/active_notification_tracker.cc index d3d50cd..bcb6e2b 100644 --- a/chrome/common/desktop_notifications/active_notification_tracker.cc +++ b/chrome/common/desktop_notifications/active_notification_tracker.cc @@ -51,6 +51,14 @@ void ActiveNotificationTracker::UnregisterNotification(int id) { reverse_notification_table_.erase(*notification); } +void ActiveNotificationTracker::Clear() { + ReverseTable::iterator iter = reverse_notification_table_.begin(); + while (iter != reverse_notification_table_.end()) { + UnregisterNotification((*iter).second); + ++iter; + } +} + WebNotificationPermissionCallback* ActiveNotificationTracker::GetCallback( int id) { DCHECK(MessageLoop::current()->type() == MessageLoop::TYPE_DEFAULT); diff --git a/chrome/common/desktop_notifications/active_notification_tracker.h b/chrome/common/desktop_notifications/active_notification_tracker.h index b25c42e..1676f32 100644 --- a/chrome/common/desktop_notifications/active_notification_tracker.h +++ b/chrome/common/desktop_notifications/active_notification_tracker.h @@ -35,6 +35,9 @@ class ActiveNotificationTracker { void OnPermissionRequestComplete(int id); WebKit::WebNotificationPermissionCallback* GetCallback(int id); + // Clears out all active notifications. Useful on page navigation. + void Clear(); + private: typedef std::map<WebKit::WebNotification, int> ReverseTable; @@ -47,4 +50,3 @@ class ActiveNotificationTracker { }; #endif // CHROME_COMMON_DESKTOP_NOTIFICATIONS_ACTIVE_NOTIFICATION_TRACKER_H_ - diff --git a/chrome/renderer/notification_provider.cc b/chrome/renderer/notification_provider.cc index 30ca716..4489951 100644 --- a/chrome/renderer/notification_provider.cc +++ b/chrome/renderer/notification_provider.cc @@ -79,6 +79,10 @@ bool NotificationProvider::OnMessageReceived(const IPC::Message& message) { return handled; } +void NotificationProvider::OnNavigate() { + // manager_.Clear(); +} + bool NotificationProvider::ShowHTML(const WebNotification& notification, int id) { // Disallow HTML notifications from non-HTTP schemes. @@ -126,9 +130,10 @@ void NotificationProvider::OnClose(int id, bool by_user) { bool found = manager_.GetNotification(id, ¬ification); // |found| may be false if the WebNotification went out of scope in // the page before the associated toast was closed by the user. - if (found) + if (found) { notification.dispatchCloseEvent(by_user); - manager_.UnregisterNotification(id); + manager_.UnregisterNotification(id); + } } void NotificationProvider::OnPermissionRequestComplete(int id) { diff --git a/chrome/renderer/notification_provider.h b/chrome/renderer/notification_provider.h index d02ee15..7c5ca71 100644 --- a/chrome/renderer/notification_provider.h +++ b/chrome/renderer/notification_provider.h @@ -36,6 +36,9 @@ class NotificationProvider : public WebKit::WebNotificationPresenter { // IPC message handler called from RenderView. bool OnMessageReceived(const IPC::Message& message); + // Called when the RenderView navigates. + void OnNavigate(); + private: // Internal methods used to show notifications. bool ShowHTML(const WebKit::WebNotification& notification, int id); diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index 9b6c758..e56673ed 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -807,6 +807,9 @@ void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { if (devtools_agent_.get()) devtools_agent_->OnNavigate(); + if (notification_provider_.get()) + notification_provider_->OnNavigate(); + child_process_logging::SetActiveURL(params.url); AboutHandler::MaybeHandle(params.url); |