Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1547)

Unified Diff: chrome/browser/notifications/notification_object_proxy.cc

Issue 208068: Desktop Notifications UI (for windows) (Closed)
Patch Set: Created 11 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/notifications/notification_object_proxy.cc
diff --git a/chrome/browser/notifications/notification_object_proxy.cc b/chrome/browser/notifications/notification_object_proxy.cc
new file mode 100644
index 0000000000000000000000000000000000000000..0db3514fdd8ccaf7583a10a206d48e4c8a14c1a1
--- /dev/null
+++ b/chrome/browser/notifications/notification_object_proxy.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/notifications/notification_object_proxy.h"
+
+#include "base/message_loop.h"
+#include "base/string16.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chrome_thread.h"
+#include "chrome/browser/renderer_host/render_view_host.h"
+#include "chrome/common/render_messages.h"
+
+NotificationObjectProxy::NotificationObjectProxy(int process_id, int route_id,
+ int notification_id, bool worker)
+ : process_id_(process_id),
+ route_id_(route_id),
+ notification_id_(notification_id),
+ worker_(worker) {
+}
+
+void NotificationObjectProxy::display() {
+ if (worker_) {
+ // TODO(johnnyg): Worker support coming soon.
+ NOTREACHED();
+ } else {
+ DeliverMessage(new ViewMsg_PostDisplayToNotificationObject(
+ route_id_, notification_id_));
+ }
+}
+
+void NotificationObjectProxy::error() {
+ if (worker_) {
+ // TODO(johnnyg): Worker support coming soon.
+ NOTREACHED();
+ } else {
+ DeliverMessage(new ViewMsg_PostErrorToNotificationObject(
+ route_id_, notification_id_, string16()));
+ }
+}
+
+void NotificationObjectProxy::close(bool by_user) {
+ if (worker_) {
+ // TODO(johnnyg): Worker support coming soon.
+ NOTREACHED();
+ } else {
+ DeliverMessage(new ViewMsg_PostCloseToNotificationObject(
+ route_id_, notification_id_, by_user));
+ }
+}
+
+void NotificationObjectProxy::DeliverMessage(IPC::Message* message) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
+ base::Thread* io_thread = g_browser_process->io_thread();
+ if (!io_thread)
+ return;
+ MessageLoop* io_loop = io_thread->message_loop();
+ if (io_loop) {
+ io_loop->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &NotificationObjectProxy::Send, message));
+ }
+}
+
+// Deferred method which runs on the IO thread and sends a message to the
+// proxied notification, routing it through the correct host in the browser.
+void NotificationObjectProxy::Send(IPC::Message* message) {
+ DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
+ RenderViewHost* host = RenderViewHost::FromID(process_id_, route_id_);
+ if (host) host->Send(message);
+}
« no previous file with comments | « chrome/browser/notifications/notification_object_proxy.h ('k') | chrome/browser/notifications/notification_ui_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698