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

Side by Side Diff: webkit/api/src/WebNotification.cpp

Issue 194079: renderer process notifications support (Closed)
Patch Set: last change for code review Created 11 years, 2 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 assign(0); 51 assign(0);
52 } 52 }
53 53
54 void WebNotification::assign(const WebNotification& other) 54 void WebNotification::assign(const WebNotification& other)
55 { 55 {
56 WebNotificationPrivate* p = const_cast<WebNotificationPrivate*>(other.m_private); 56 WebNotificationPrivate* p = const_cast<WebNotificationPrivate*>(other.m_private);
57 p->ref(); 57 p->ref();
58 assign(p); 58 assign(p);
59 } 59 }
60 60
61 bool WebNotification::lessThan(const WebNotification& other) const
62 {
63 return reinterpret_cast<uintptr_t>(m_private) < reinterpret_cast<uintptr_t>(other.m_private);
64 }
65
61 bool WebNotification::isHTML() const 66 bool WebNotification::isHTML() const
62 { 67 {
63 return m_private->isHTML(); 68 return m_private->isHTML();
64 } 69 }
65 70
66 WebURL WebNotification::url() const 71 WebURL WebNotification::url() const
67 { 72 {
68 ASSERT(isHTML()); 73 ASSERT(isHTML());
69 return m_private->url(); 74 return m_private->url();
70 } 75 }
(...skipping 11 matching lines...) Expand all
82 } 87 }
83 88
84 WebString WebNotification::body() const 89 WebString WebNotification::body() const
85 { 90 {
86 ASSERT(!isHTML()); 91 ASSERT(!isHTML());
87 return m_private->contents().body(); 92 return m_private->contents().body();
88 } 93 }
89 94
90 void WebNotification::dispatchDisplayEvent() 95 void WebNotification::dispatchDisplayEvent()
91 { 96 {
92 m_private->dispatchDisplayEvent(); 97 RefPtr<Event> event = Event::create("display", false, true);
98 m_private->dispatchEvent(event.release());
93 } 99 }
94 100
95 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */) 101 void WebNotification::dispatchErrorEvent(const WebKit::WebString& /* errorMessage */)
96 { 102 {
97 // FIXME: errorMessage not supported by WebCore yet 103 // FIXME: errorMessage not supported by WebCore yet
98 m_private->dispatchErrorEvent(); 104 RefPtr<Event> event = Event::create(eventNames().errorEvent, false, true);
105 m_private->dispatchEvent(event.release());
99 } 106 }
100 107
101 void WebNotification::dispatchCloseEvent(bool /* byUser */) 108 void WebNotification::dispatchCloseEvent(bool /* byUser */)
102 { 109 {
103 // FIXME: byUser flag not supported by WebCore yet 110 // FIXME: byUser flag not supported by WebCore yet
104 m_private->dispatchCloseEvent(); 111 RefPtr<Event> event = Event::create(eventNames().closeEvent, false, true);
112 m_private->dispatchEvent(event.release());
105 } 113 }
106 114
107 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification) 115 WebNotification::WebNotification(const WTF::PassRefPtr<Notification>& notification)
108 : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef())) 116 : m_private(static_cast<WebNotificationPrivate*>(notification.releaseRef()))
109 { 117 {
110 } 118 }
111 119
112 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification) 120 WebNotification& WebNotification::operator=(const WTF::PassRefPtr<Notification>& notification)
113 { 121 {
114 assign(static_cast<WebNotificationPrivate*>(notification.releaseRef())); 122 assign(static_cast<WebNotificationPrivate*>(notification.releaseRef()));
115 return *this; 123 return *this;
116 } 124 }
117 125
118 WebNotification::operator WTF::PassRefPtr<Notification>() const 126 WebNotification::operator WTF::PassRefPtr<Notification>() const
119 { 127 {
120 return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_private)); 128 return WTF::PassRefPtr<Notification>(const_cast<WebNotificationPrivate*>(m_private));
121 } 129 }
122 130
123 void WebNotification::assign(WebNotificationPrivate* p) 131 void WebNotification::assign(WebNotificationPrivate* p)
124 { 132 {
125 // p is already ref'd for us by the caller 133 // p is already ref'd for us by the caller
126 if (m_private) 134 if (m_private)
127 m_private->deref(); 135 m_private->deref();
128 m_private = p; 136 m_private = p;
129 } 137 }
130 138
131 } // namespace WebKit 139 } // namespace WebKit
132 140
133 #endif // ENABLE(NOTIFICATIONS) 141 #endif // ENABLE(NOTIFICATIONS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698