summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 05:50:35 +0000
committerjohnnyg@chromium.org <johnnyg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 05:50:35 +0000
commit0ff62860f0db277412f8c56b43cc65356af6d820 (patch)
tree3c1d21cb3a1640b95e74fd0f919c3cc3681238e8 /chrome/browser
parentbcb9a7c0f0084dd42e3db746ed74bfae432ffb55 (diff)
downloadchromium_src-0ff62860f0db277412f8c56b43cc65356af6d820.zip
chromium_src-0ff62860f0db277412f8c56b43cc65356af6d820.tar.gz
chromium_src-0ff62860f0db277412f8c56b43cc65356af6d820.tar.bz2
Implement the plumbing to deliver click events from the notification balloon view to the javascript object.
BUG=51226 TEST=use notifications with an onclick event Review URL: http://codereview.chromium.org/3273007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58137 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/chromeos/notifications/notification_browsertest.cc1
-rw-r--r--chrome/browser/chromeos/notifications/system_notification.h2
-rw-r--r--chrome/browser/notifications/balloon.cc4
-rw-r--r--chrome/browser/notifications/balloon.h3
-rw-r--r--chrome/browser/notifications/balloon_host.cc4
-rw-r--r--chrome/browser/notifications/balloon_host.h2
-rw-r--r--chrome/browser/notifications/notification.h1
-rw-r--r--chrome/browser/notifications/notification_delegate.h3
-rw-r--r--chrome/browser/notifications/notification_object_proxy.cc9
-rw-r--r--chrome/browser/notifications/notification_object_proxy.h1
10 files changed, 28 insertions, 2 deletions
diff --git a/chrome/browser/chromeos/notifications/notification_browsertest.cc b/chrome/browser/chromeos/notifications/notification_browsertest.cc
index 0dac6c6..af199d9 100644
--- a/chrome/browser/chromeos/notifications/notification_browsertest.cc
+++ b/chrome/browser/chromeos/notifications/notification_browsertest.cc
@@ -30,6 +30,7 @@ class MockNotificationDelegate : public NotificationDelegate {
virtual void Display() {}
virtual void Error() {}
virtual void Close(bool by_user) {}
+ virtual void Click() {}
virtual std::string id() const { return id_; }
private:
diff --git a/chrome/browser/chromeos/notifications/system_notification.h b/chrome/browser/chromeos/notifications/system_notification.h
index c898b0f..fdb2afb 100644
--- a/chrome/browser/chromeos/notifications/system_notification.h
+++ b/chrome/browser/chromeos/notifications/system_notification.h
@@ -54,6 +54,7 @@ class SystemNotification {
void Display() {}
void Error() {}
void Close(bool by_user) {}
+ void Click() {}
std::string id() const { return id_; }
private:
@@ -76,4 +77,3 @@ class SystemNotification {
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_NOTIFICATIONS_SYSTEM_NOTIFICATION_H_
-
diff --git a/chrome/browser/notifications/balloon.cc b/chrome/browser/notifications/balloon.cc
index 969bde1..96f3fca 100644
--- a/chrome/browser/notifications/balloon.cc
+++ b/chrome/browser/notifications/balloon.cc
@@ -51,6 +51,10 @@ void Balloon::Update(const Notification& notification) {
}
}
+void Balloon::OnClick() {
+ notification_->Click();
+}
+
void Balloon::OnClose(bool by_user) {
notification_->Close(by_user);
collection_->OnBalloonClosed(this);
diff --git a/chrome/browser/notifications/balloon.h b/chrome/browser/notifications/balloon.h
index 225eca0..3f4ba0b 100644
--- a/chrome/browser/notifications/balloon.h
+++ b/chrome/browser/notifications/balloon.h
@@ -96,6 +96,9 @@ class Balloon {
// Notify that the content of notification has changed.
virtual void Update(const Notification& notification);
+ // Called when the balloon is clicked by the user.
+ virtual void OnClick();
+
// Called when the balloon is closed, either by user (through the UI)
// or by a script.
virtual void OnClose(bool by_user);
diff --git a/chrome/browser/notifications/balloon_host.cc b/chrome/browser/notifications/balloon_host.cc
index 8e5b676..6e3b44d 100644
--- a/chrome/browser/notifications/balloon_host.cc
+++ b/chrome/browser/notifications/balloon_host.cc
@@ -123,6 +123,10 @@ void BalloonHost::UpdatePreferredSize(const gfx::Size& new_size) {
balloon_->SetContentPreferredSize(new_size);
}
+void BalloonHost::HandleMouseDown() {
+ balloon_->OnClick();
+}
+
RendererPreferences BalloonHost::GetRendererPrefs(Profile* profile) const {
RendererPreferences preferences;
renderer_preferences_util::UpdateFromSystemSettings(&preferences, profile);
diff --git a/chrome/browser/notifications/balloon_host.h b/chrome/browser/notifications/balloon_host.h
index 84d9953..4211636 100644
--- a/chrome/browser/notifications/balloon_host.h
+++ b/chrome/browser/notifications/balloon_host.h
@@ -110,7 +110,7 @@ class BalloonHost : public RenderViewHostDelegate,
}
virtual void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {}
virtual void HandleMouseMove() {}
- virtual void HandleMouseDown() {}
+ virtual void HandleMouseDown();
virtual void HandleMouseLeave() {}
virtual void UpdatePreferredSize(const gfx::Size& pref_size);
virtual RendererPreferences GetRendererPrefs(Profile* profile) const;
diff --git a/chrome/browser/notifications/notification.h b/chrome/browser/notifications/notification.h
index 49aabf2..f8ab903 100644
--- a/chrome/browser/notifications/notification.h
+++ b/chrome/browser/notifications/notification.h
@@ -57,6 +57,7 @@ class Notification {
void Display() const { delegate()->Display(); }
void Error() const { delegate()->Error(); }
+ void Click() const { delegate()->Click(); }
void Close(bool by_user) const { delegate()->Close(by_user); }
bool IsSame(const Notification& other) const {
diff --git a/chrome/browser/notifications/notification_delegate.h b/chrome/browser/notifications/notification_delegate.h
index 6814bde..53226e5 100644
--- a/chrome/browser/notifications/notification_delegate.h
+++ b/chrome/browser/notifications/notification_delegate.h
@@ -27,6 +27,9 @@ class NotificationDelegate
// user explicitly (as opposed to timeout/script), |by_user| should be true.
virtual void Close(bool by_user) = 0;
+ // To be called when a desktop notification is clicked.
+ virtual void Click() = 0;
+
// Returns unique id of the notification.
virtual std::string id() const = 0;
diff --git a/chrome/browser/notifications/notification_object_proxy.cc b/chrome/browser/notifications/notification_object_proxy.cc
index 76363e5..edf35df 100644
--- a/chrome/browser/notifications/notification_object_proxy.cc
+++ b/chrome/browser/notifications/notification_object_proxy.cc
@@ -49,6 +49,15 @@ void NotificationObjectProxy::Close(bool by_user) {
}
}
+void NotificationObjectProxy::Click() {
+ if (worker_) {
+ NOTREACHED();
+ } else {
+ DeliverMessage(new ViewMsg_PostClickToNotificationObject(
+ route_id_, notification_id_));
+ }
+}
+
std::string NotificationObjectProxy::id() const {
return StringPrintf("%d:%d:%d:%d", process_id_, route_id_,
notification_id_, worker_);
diff --git a/chrome/browser/notifications/notification_object_proxy.h b/chrome/browser/notifications/notification_object_proxy.h
index 70aa193..c3cb777 100644
--- a/chrome/browser/notifications/notification_object_proxy.h
+++ b/chrome/browser/notifications/notification_object_proxy.h
@@ -30,6 +30,7 @@ class NotificationObjectProxy
virtual void Display();
virtual void Error();
virtual void Close(bool by_user);
+ virtual void Click();
virtual std::string id() const;
protected: