OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All Rights Reserved. | 2 * Copyright (C) 2009 Google Inc. All Rights Reserved. |
3 * (C) 2008 Apple Inc. | 3 * (C) 2008 Apple Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
7 * are met: | 7 * are met: |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 17 matching lines...) Expand all Loading... |
28 #include "StorageAreaProxy.h" | 28 #include "StorageAreaProxy.h" |
29 | 29 |
30 #include "DOMWindow.h" | 30 #include "DOMWindow.h" |
31 #include "Document.h" | 31 #include "Document.h" |
32 #include "EventNames.h" | 32 #include "EventNames.h" |
33 #include "ExceptionCode.h" | 33 #include "ExceptionCode.h" |
34 #include "Frame.h" | 34 #include "Frame.h" |
35 #include "Page.h" | 35 #include "Page.h" |
36 #include "PageGroup.h" | 36 #include "PageGroup.h" |
37 #include "SecurityOrigin.h" | 37 #include "SecurityOrigin.h" |
38 #include "StorageAreaImpl.h" | |
39 #include "StorageEvent.h" | 38 #include "StorageEvent.h" |
40 | 39 |
41 #include "WebFrameImpl.h" | 40 #include "WebFrameImpl.h" |
42 #include "WebPermissionClient.h" | 41 #include "WebPermissionClient.h" |
43 #include "WebStorageArea.h" | 42 #include "WebStorageArea.h" |
44 #include "platform/WebString.h" | 43 #include "platform/WebString.h" |
45 #include "platform/WebURL.h" | 44 #include "platform/WebURL.h" |
46 #include "WebViewImpl.h" | 45 #include "WebViewImpl.h" |
47 | 46 |
48 namespace WebCore { | 47 namespace WebCore { |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 // of any given page in the group or mutate the page group itself. | 132 // of any given page in the group or mutate the page group itself. |
134 Vector<RefPtr<Frame> > frames; | 133 Vector<RefPtr<Frame> > frames; |
135 if (storageType == SessionStorage) { | 134 if (storageType == SessionStorage) { |
136 // Send events only to our page. | 135 // Send events only to our page. |
137 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->tra
verseNext()) { | 136 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->tra
verseNext()) { |
138 if (sourceFrame != frame && frame->document()->securityOrigin()->equ
al(securityOrigin)) | 137 if (sourceFrame != frame && frame->document()->securityOrigin()->equ
al(securityOrigin)) |
139 frames.append(frame); | 138 frames.append(frame); |
140 } | 139 } |
141 | 140 |
142 for (unsigned i = 0; i < frames.size(); ++i) { | 141 for (unsigned i = 0; i < frames.size(); ++i) { |
| 142 // FIXME: maybe only raise if the window has an onstorage listener |
| 143 // attached to avoid creating the Storage instance. |
143 ExceptionCode ec = 0; | 144 ExceptionCode ec = 0; |
144 Storage* storage = frames[i]->domWindow()->sessionStorage(ec); | 145 Storage* storage = frames[i]->domWindow()->sessionStorage(ec); |
145 if (!ec) | 146 if (!ec) |
146 frames[i]->document()->enqueueWindowEvent(StorageEvent::create(e
ventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(
), storage)); | 147 frames[i]->document()->enqueueWindowEvent(StorageEvent::create(e
ventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(
), storage)); |
147 } | 148 } |
148 } else { | 149 } else { |
149 // Send events to every page. | 150 // Send events to every page. |
150 const HashSet<Page*>& pages = page->group().pages(); | 151 const HashSet<Page*>& pages = page->group().pages(); |
151 HashSet<Page*>::const_iterator end = pages.end(); | 152 HashSet<Page*>::const_iterator end = pages.end(); |
152 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it)
{ | 153 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it)
{ |
153 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()
->traverseNext()) { | 154 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()
->traverseNext()) { |
154 if (sourceFrame != frame && frame->document()->securityOrigin()-
>equal(securityOrigin)) | 155 if (sourceFrame != frame && frame->document()->securityOrigin()-
>equal(securityOrigin)) |
155 frames.append(frame); | 156 frames.append(frame); |
156 } | 157 } |
157 } | 158 } |
158 | 159 |
159 for (unsigned i = 0; i < frames.size(); ++i) { | 160 for (unsigned i = 0; i < frames.size(); ++i) { |
| 161 // FIXME: maybe only raise if the window has an onstorage listener |
| 162 // attached to avoid creating the Storage instance. |
160 ExceptionCode ec = 0; | 163 ExceptionCode ec = 0; |
161 Storage* storage = frames[i]->domWindow()->localStorage(ec); | 164 Storage* storage = frames[i]->domWindow()->localStorage(ec); |
162 if (!ec) | 165 if (!ec) |
163 frames[i]->document()->enqueueWindowEvent(StorageEvent::create(e
ventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(
), storage)); | 166 frames[i]->document()->enqueueWindowEvent(StorageEvent::create(e
ventNames().storageEvent, key, oldValue, newValue, sourceFrame->document()->url(
), storage)); |
164 } | 167 } |
165 } | 168 } |
166 } | 169 } |
167 | 170 |
168 bool StorageAreaProxy::canAccessStorage(Frame* frame) const | 171 bool StorageAreaProxy::canAccessStorage(Frame* frame) const |
169 { | 172 { |
170 if (!frame->page()) | 173 if (!frame->page()) |
171 return false; | 174 return false; |
172 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); | 175 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); |
173 WebKit::WebViewImpl* webView = webFrame->viewImpl(); | 176 WebKit::WebViewImpl* webView = webFrame->viewImpl(); |
174 return !webView->permissionClient() || webView->permissionClient()->allowSto
rage(webFrame, m_storageType == LocalStorage); | 177 return !webView->permissionClient() || webView->permissionClient()->allowSto
rage(webFrame, m_storageType == LocalStorage); |
175 } | 178 } |
176 | 179 |
177 } // namespace WebCore | 180 } // namespace WebCore |
OLD | NEW |