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 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 return false; | 140 return false; |
141 | 141 |
142 // LocalFrameLifecycleObserver is used to safely keep the cached | 142 // LocalFrameLifecycleObserver is used to safely keep the cached |
143 // reference to the LocalFrame. Should the LocalFrame die before | 143 // reference to the LocalFrame. Should the LocalFrame die before |
144 // this StorageArea does, that cached reference will be cleared. | 144 // this StorageArea does, that cached reference will be cleared. |
145 if (this->frame() == frame) | 145 if (this->frame() == frame) |
146 return m_canAccessStorageCachedResult; | 146 return m_canAccessStorageCachedResult; |
147 StorageNamespaceController* controller = StorageNamespaceController::from(fr
ame->page()); | 147 StorageNamespaceController* controller = StorageNamespaceController::from(fr
ame->page()); |
148 if (!controller) | 148 if (!controller) |
149 return false; | 149 return false; |
150 bool result = controller->storageClient()->canAccessStorage(frame, m_storage
Type); | 150 bool result = controller->getStorageClient()->canAccessStorage(frame, m_stor
ageType); |
151 // Move attention to the new LocalFrame. | 151 // Move attention to the new LocalFrame. |
152 LocalFrameLifecycleObserver::setContext(frame); | 152 LocalFrameLifecycleObserver::setContext(frame); |
153 m_canAccessStorageCachedResult = result; | 153 m_canAccessStorageCachedResult = result; |
154 return result; | 154 return result; |
155 } | 155 } |
156 | 156 |
157 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance) | 157 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old
Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU
RL, WebStorageArea* sourceAreaInstance) |
158 { | 158 { |
159 // Iterate over all pages that have a StorageNamespaceController supplement. | 159 // Iterate over all pages that have a StorageNamespaceController supplement. |
160 for (Page* page : Page::ordinaryPages()) { | 160 for (Page* page : Page::ordinaryPages()) { |
161 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { | 161 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav
erseNext()) { |
162 // FIXME: We do not yet have a way to dispatch events to out-of-proc
ess frames. | 162 // FIXME: We do not yet have a way to dispatch events to out-of-proc
ess frames. |
163 if (!frame->isLocalFrame()) | 163 if (!frame->isLocalFrame()) |
164 continue; | 164 continue; |
165 LocalFrame* localFrame = toLocalFrame(frame); | 165 LocalFrame* localFrame = toLocalFrame(frame); |
166 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); | 166 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); |
167 Storage* storage = DOMWindowStorage::from(*localWindow).optionalLoca
lStorage(); | 167 Storage* storage = DOMWindowStorage::from(*localWindow).optionalLoca
lStorage(); |
168 if (storage && localFrame->document()->securityOrigin()->canAccess(s
ecurityOrigin) && !isEventSource(storage, sourceAreaInstance)) | 168 if (storage && localFrame->document()->getSecurityOrigin()->canAcces
s(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) |
169 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::c
reate(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); | 169 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::c
reate(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); |
170 } | 170 } |
171 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(p
age)->inspectorAgent()) | 171 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(p
age)->inspectorAgent()) |
172 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStor
age, securityOrigin); | 172 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, LocalStor
age, securityOrigin); |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess
ionNamespace) | 176 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess
ionNamespace) |
177 { | 177 { |
178 // Iterate over all pages that have a StorageNamespaceController supplement. | 178 // Iterate over all pages that have a StorageNamespaceController supplement. |
(...skipping 12 matching lines...) Expand all Loading... |
191 if (!page) | 191 if (!page) |
192 return; | 192 return; |
193 | 193 |
194 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { | 194 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse
Next()) { |
195 // FIXME: We do not yet have a way to dispatch events to out-of-process
frames. | 195 // FIXME: We do not yet have a way to dispatch events to out-of-process
frames. |
196 if (!frame->isLocalFrame()) | 196 if (!frame->isLocalFrame()) |
197 continue; | 197 continue; |
198 LocalFrame* localFrame = toLocalFrame(frame); | 198 LocalFrame* localFrame = toLocalFrame(frame); |
199 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); | 199 LocalDOMWindow* localWindow = localFrame->localDOMWindow(); |
200 Storage* storage = DOMWindowStorage::from(*localWindow).optionalSessionS
torage(); | 200 Storage* storage = DOMWindowStorage::from(*localWindow).optionalSessionS
torage(); |
201 if (storage && localFrame->document()->securityOrigin()->canAccess(secur
ityOrigin) && !isEventSource(storage, sourceAreaInstance)) | 201 if (storage && localFrame->document()->getSecurityOrigin()->canAccess(se
curityOrigin) && !isEventSource(storage, sourceAreaInstance)) |
202 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::creat
e(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); | 202 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::creat
e(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage)); |
203 } | 203 } |
204 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(page)
->inspectorAgent()) | 204 if (InspectorDOMStorageAgent* agent = StorageNamespaceController::from(page)
->inspectorAgent()) |
205 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorag
e, securityOrigin); | 205 agent->didDispatchDOMStorageEvent(key, oldValue, newValue, SessionStorag
e, securityOrigin); |
206 } | 206 } |
207 | 207 |
208 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) | 208 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst
ance) |
209 { | 209 { |
210 ASSERT(storage); | 210 ASSERT(storage); |
211 StorageArea* area = storage->area(); | 211 StorageArea* area = storage->area(); |
212 return area->m_storageArea == sourceAreaInstance; | 212 return area->m_storageArea == sourceAreaInstance; |
213 } | 213 } |
214 | 214 |
215 } // namespace blink | 215 } // namespace blink |
OLD | NEW |