summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 22:14:39 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-04-08 22:14:39 +0000
commitd19ee3444d4c8042a97bd653e57c775206a04bed (patch)
tree89f0e3822bab8f163ec99ff4dde6a48cd529d54b /chrome/browser/notifications
parent4cb6dca5bcdabfa14f067f741243ca4fcda0b833 (diff)
downloadchromium_src-d19ee3444d4c8042a97bd653e57c775206a04bed.zip
chromium_src-d19ee3444d4c8042a97bd653e57c775206a04bed.tar.gz
chromium_src-d19ee3444d4c8042a97bd653e57c775206a04bed.tar.bz2
Add notification processes to the task manager.
BUG=29332 TEST=notifications in task manager Review URL: http://codereview.chromium.org/1610006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@44014 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/notifications')
-rw-r--r--chrome/browser/notifications/balloon.h4
-rw-r--r--chrome/browser/notifications/balloon_collection.h6
-rw-r--r--chrome/browser/notifications/balloon_collection_impl.h3
-rw-r--r--chrome/browser/notifications/balloon_host.cc26
-rw-r--r--chrome/browser/notifications/balloon_host.h12
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.cc27
-rw-r--r--chrome/browser/notifications/desktop_notifications_unittest.h9
-rw-r--r--chrome/browser/notifications/notification_test_util.h1
8 files changed, 59 insertions, 29 deletions
diff --git a/chrome/browser/notifications/balloon.h b/chrome/browser/notifications/balloon.h
index ddaa14d..2df44d9 100644
--- a/chrome/browser/notifications/balloon.h
+++ b/chrome/browser/notifications/balloon.h
@@ -17,6 +17,7 @@
class Balloon;
class BalloonCollection;
+class BalloonHost;
class Notification;
class Profile;
class SiteInstance;
@@ -40,6 +41,9 @@ class BalloonView {
// The total size of the view.
virtual gfx::Size GetSize() const = 0;
+
+ // The host for the view's contents.
+ virtual BalloonHost* GetHost() const = 0;
};
// Represents a Notification on the screen.
diff --git a/chrome/browser/notifications/balloon_collection.h b/chrome/browser/notifications/balloon_collection.h
index 998142b..2d868c4 100644
--- a/chrome/browser/notifications/balloon_collection.h
+++ b/chrome/browser/notifications/balloon_collection.h
@@ -7,6 +7,8 @@
#ifndef CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_
#define CHROME_BROWSER_NOTIFICATIONS_BALLOON_COLLECTION_H_
+#include <deque>
+
class Balloon;
class Notification;
class Profile;
@@ -54,6 +56,10 @@ class BalloonCollection {
// Inform the collection that a balloon was closed.
virtual void OnBalloonClosed(Balloon* source) = 0;
+ // Get const collection of the active balloons.
+ typedef std::deque<Balloon*> Balloons;
+ virtual const Balloons& GetActiveBalloons() = 0;
+
BalloonSpaceChangeListener* space_change_listener() {
return space_change_listener_;
}
diff --git a/chrome/browser/notifications/balloon_collection_impl.h b/chrome/browser/notifications/balloon_collection_impl.h
index c7fe67c..5b39f6f 100644
--- a/chrome/browser/notifications/balloon_collection_impl.h
+++ b/chrome/browser/notifications/balloon_collection_impl.h
@@ -31,6 +31,9 @@ class BalloonCollectionImpl : public BalloonCollection {
virtual void ResizeBalloon(Balloon* balloon, const gfx::Size& size);
virtual void DisplayChanged();
virtual void OnBalloonClosed(Balloon* source);
+ virtual const Balloons& GetActiveBalloons() {
+ return balloons_;
+ }
protected:
// Calculates layout values for the balloons including
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 19414a0..541d5a4 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -41,6 +41,7 @@ BalloonHost::BalloonHost(Balloon* balloon)
void BalloonHost::Shutdown() {
if (render_view_host_) {
+ NotifyDisconnect();
render_view_host_->Shutdown();
render_view_host_ = NULL;
}
@@ -56,27 +57,20 @@ void BalloonHost::Close(RenderViewHost* render_view_host) {
balloon_->CloseByScript();
}
-
void BalloonHost::RenderViewCreated(RenderViewHost* render_view_host) {
render_view_host->Send(new ViewMsg_EnablePreferredSizeChangedMode(
render_view_host->routing_id()));
}
-void BalloonHost::RendererReady(RenderViewHost* render_view_host) {
+void BalloonHost::RenderViewReady(RenderViewHost* render_view_host) {
should_notify_on_disconnect_ = true;
NotificationService::current()->Notify(
NotificationType::NOTIFY_BALLOON_CONNECTED,
- Source<Balloon>(balloon_), NotificationService::NoDetails());
+ Source<BalloonHost>(this), NotificationService::NoDetails());
}
-void BalloonHost::RendererGone(RenderViewHost* render_view_host) {
- if (!should_notify_on_disconnect_)
- return;
-
- should_notify_on_disconnect_ = false;
- NotificationService::current()->Notify(
- NotificationType::NOTIFY_BALLOON_DISCONNECTED,
- Source<Balloon>(balloon_), NotificationService::NoDetails());
+void BalloonHost::RenderViewGone(RenderViewHost* render_view_host) {
+ Close(render_view_host);
}
void BalloonHost::ProcessDOMUIMessage(const std::string& message,
@@ -141,3 +135,13 @@ void BalloonHost::Init() {
initialized_ = true;
}
+
+void BalloonHost::NotifyDisconnect() {
+ if (!should_notify_on_disconnect_)
+ return;
+
+ should_notify_on_disconnect_ = false;
+ NotificationService::current()->Notify(
+ NotificationType::NOTIFY_BALLOON_DISCONNECTED,
+ Source<BalloonHost>(this), NotificationService::NoDetails());
+}
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 5935cf7..521d898 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -43,6 +43,10 @@ class BalloonHost : public RenderViewHostDelegate,
RenderViewHost* render_view_host() const { return render_view_host_; }
+ std::wstring GetSource() const {
+ return balloon_->notification().display_source();
+ }
+
// RenderViewHostDelegate overrides.
virtual WebPreferences GetWebkitPrefs();
virtual SiteInstance* GetSiteInstance() const {
@@ -54,8 +58,8 @@ class BalloonHost : public RenderViewHostDelegate,
}
virtual void Close(RenderViewHost* render_view_host);
virtual void RenderViewCreated(RenderViewHost* render_view_host);
- virtual void RendererReady(RenderViewHost* render_view_host);
- virtual void RendererGone(RenderViewHost* render_view_host);
+ virtual void RenderViewReady(RenderViewHost* render_view_host);
+ virtual void RenderViewGone(RenderViewHost* render_view_host);
virtual void UpdateTitle(RenderViewHost* render_view_host,
int32 page_id, const std::wstring& title) {}
virtual int GetBrowserWindowID() const { return -1; }
@@ -112,6 +116,10 @@ class BalloonHost : public RenderViewHostDelegate,
RenderViewHost* render_view_host_;
private:
+ // Called to send an event that the balloon has been disconnected from
+ // a renderer (if should_notify_on_disconnect_ is true).
+ void NotifyDisconnect();
+
// Non-owned pointer to the associated balloon.
Balloon* balloon_;
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.cc b/chrome/browser/notifications/desktop_notifications_unittest.cc
index b15a46e..637d9a1 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.cc
+++ b/chrome/browser/notifications/desktop_notifications_unittest.cc
@@ -38,18 +38,24 @@ Balloon* MockBalloonCollection::MakeBalloon(const Notification& notification,
// Start with a normal balloon but mock out the view.
Balloon* balloon = BalloonCollectionImpl::MakeBalloon(notification, profile);
balloon->set_view(new MockBalloonView(balloon));
- balloons_.insert(balloon);
+ balloons_.push_back(balloon);
return balloon;
}
void MockBalloonCollection::OnBalloonClosed(Balloon* source) {
- balloons_.erase(source);
- BalloonCollectionImpl::OnBalloonClosed(source);
+ std::deque<Balloon*>::iterator it;
+ for (it = balloons_.begin(); it != balloons_.end(); ++it) {
+ if (*it == source) {
+ balloons_.erase(it);
+ BalloonCollectionImpl::OnBalloonClosed(source);
+ break;
+ }
+ }
}
int MockBalloonCollection::UppermostVerticalPosition() {
int min = 0;
- std::set<Balloon*>::iterator iter;
+ std::deque<Balloon*>::iterator iter;
for (iter = balloons_.begin(); iter != balloons_.end(); ++iter) {
int pos = (*iter)->position().y();
if (iter == balloons_.begin() || pos < min)
@@ -111,15 +117,10 @@ TEST_F(DesktopNotificationsTest, TestClose) {
EXPECT_EQ(1, balloon_collection_->count());
// Close all the open balloons.
- std::set<Balloon*> balloons = balloon_collection_->balloons();
- std::set<Balloon*>::iterator iter;
- for (iter = balloons.begin(); iter != balloons.end(); ++iter) {
- (*iter)->OnClose(true);
+ while (balloon_collection_->count() > 0) {
+ (*(balloon_collection_->GetActiveBalloons().begin()))->OnClose(true);
}
- // Verify that the balloon collection is now empty.
- EXPECT_EQ(0, balloon_collection_->count());
-
EXPECT_EQ("notification displayed\n"
"notification closed by user\n",
log_output_);
@@ -190,8 +191,8 @@ TEST_F(DesktopNotificationsTest, TestVariableSize) {
0, 0, DesktopNotificationService::PageNotification, 1));
expected_log.append("notification displayed\n");
- std::set<Balloon*>& balloons = balloon_collection_->balloons();
- std::set<Balloon*>::iterator iter;
+ std::deque<Balloon*>& balloons = balloon_collection_->balloons();
+ std::deque<Balloon*>::iterator iter;
for (iter = balloons.begin(); iter != balloons.end(); ++iter) {
if ((*iter)->notification().origin_url().host() == "long.google.com") {
EXPECT_GE((*iter)->GetViewSize().height(),
diff --git a/chrome/browser/notifications/desktop_notifications_unittest.h b/chrome/browser/notifications/desktop_notifications_unittest.h
index 60112c3..77e1b11 100644
--- a/chrome/browser/notifications/desktop_notifications_unittest.h
+++ b/chrome/browser/notifications/desktop_notifications_unittest.h
@@ -5,7 +5,7 @@
#ifndef CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_
#define CHROME_BROWSER_NOTIFICATIONS_DESKTOP_NOTIFICATIONS_UNITTEST_H_
-#include <set>
+#include <deque>
#include <string>
#include "base/message_loop.h"
@@ -44,9 +44,12 @@ class MockBalloonCollection : public BalloonCollectionImpl {
Profile* profile);
virtual void DisplayChanged() {}
virtual void OnBalloonClosed(Balloon* source);
+ virtual const BalloonCollection::Balloons& GetActiveBalloons() {
+ return balloons_;
+ }
// Number of balloons being shown.
- std::set<Balloon*>& balloons() { return balloons_; }
+ std::deque<Balloon*>& balloons() { return balloons_; }
int count() const { return balloons_.size(); }
// Returns the highest y-coordinate of all the balloons in the collection.
@@ -57,7 +60,7 @@ class MockBalloonCollection : public BalloonCollectionImpl {
int MaxHeight() { return Layout::max_balloon_height(); }
private:
- std::set<Balloon*> balloons_;
+ std::deque<Balloon*> balloons_;
scoped_refptr<LoggingNotificationProxy> log_proxy_;
};
diff --git a/chrome/browser/notifications/notification_test_util.h b/chrome/browser/notifications/notification_test_util.h
index 15849c4..d3ad7ee 100644
--- a/chrome/browser/notifications/notification_test_util.h
+++ b/chrome/browser/notifications/notification_test_util.h
@@ -44,6 +44,7 @@ class MockBalloonView : public BalloonView {
void RepositionToBalloon() {}
void Close(bool by_user) { balloon_->OnClose(by_user); }
gfx::Size GetSize() const { return balloon_->content_size(); }
+ BalloonHost* GetHost() const { return NULL; }
private:
// Non-owned pointer.