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

Side by Side Diff: Source/core/storage/StorageArea.cpp

Issue 683013002: Extract a DOMWindow interface from LocalDOMWindow and use it in the idl. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix incorrect assumption Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess) 158 void StorageArea::dispatchLocalStorageEvent(const String& key, const String& old Value, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pageU RL, WebStorageArea* sourceAreaInstance, bool originatedInProcess)
159 { 159 {
160 // FIXME: This looks suspicious. Why doesn't this use allPages instead? 160 // FIXME: This looks suspicious. Why doesn't this use allPages instead?
161 const HashSet<Page*>& pages = Page::ordinaryPages(); 161 const HashSet<Page*>& pages = Page::ordinaryPages();
162 for (Page* page : pages) { 162 for (Page* page : pages) {
163 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav erseNext()) { 163 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().trav erseNext()) {
164 // FIXME: We do not yet have a way to dispatch events to out-of-proc ess frames. 164 // FIXME: We do not yet have a way to dispatch events to out-of-proc ess frames.
165 if (!frame->isLocalFrame()) 165 if (!frame->isLocalFrame())
166 continue; 166 continue;
167 Storage* storage = frame->domWindow()->optionalLocalStorage(); 167 LocalFrame* localFrame = toLocalFrame(frame);
168 if (storage && toLocalFrame(frame)->document()->securityOrigin()->ca nAccess(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) 168 Storage* storage = localFrame->localDOMWindow()->optionalLocalStorag e();
169 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(Even tTypeNames::storage, key, oldValue, newValue, pageURL, storage)); 169 if (storage && localFrame->document()->securityOrigin()->canAccess(s ecurityOrigin) && !isEventSource(storage, sourceAreaInstance))
170 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::c reate(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage));
170 } 171 }
171 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue , newValue, LocalStorage, securityOrigin); 172 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue , newValue, LocalStorage, securityOrigin);
172 } 173 }
173 } 174 }
174 175
175 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess ionNamespace) 176 static Page* findPageWithSessionStorageNamespace(const WebStorageNamespace& sess ionNamespace)
176 { 177 {
177 // FIXME: This looks suspicious. Why doesn't this use allPages instead? 178 // FIXME: This looks suspicious. Why doesn't this use allPages instead?
178 const HashSet<Page*>& pages = Page::ordinaryPages(); 179 const HashSet<Page*>& pages = Page::ordinaryPages();
179 for (Page* page : pages) { 180 for (Page* page : pages) {
180 const bool dontCreateIfMissing = false; 181 const bool dontCreateIfMissing = false;
181 StorageNamespace* storageNamespace = page->sessionStorage(dontCreateIfMi ssing); 182 StorageNamespace* storageNamespace = page->sessionStorage(dontCreateIfMi ssing);
182 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa ce)) 183 if (storageNamespace && storageNamespace->isSameNamespace(sessionNamespa ce))
183 return page; 184 return page;
184 } 185 }
185 return nullptr; 186 return nullptr;
186 } 187 }
187 188
188 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag eURL, const WebStorageNamespace& sessionNamespace, WebStorageArea* sourceAreaIns tance, bool originatedInProcess) 189 void StorageArea::dispatchSessionStorageEvent(const String& key, const String& o ldValue, const String& newValue, SecurityOrigin* securityOrigin, const KURL& pag eURL, const WebStorageNamespace& sessionNamespace, WebStorageArea* sourceAreaIns tance, bool originatedInProcess)
189 { 190 {
190 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); 191 Page* page = findPageWithSessionStorageNamespace(sessionNamespace);
191 if (!page) 192 if (!page)
192 return; 193 return;
193 194
194 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse Next()) { 195 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. 196 // FIXME: We do not yet have a way to dispatch events to out-of-process frames.
196 if (!frame->isLocalFrame()) 197 if (!frame->isLocalFrame())
197 continue; 198 continue;
198 Storage* storage = frame->domWindow()->optionalSessionStorage(); 199 LocalFrame* localFrame = toLocalFrame(frame);
199 if (storage && toLocalFrame(frame)->document()->securityOrigin()->canAcc ess(securityOrigin) && !isEventSource(storage, sourceAreaInstance)) 200 Storage* storage = localFrame->localDOMWindow()->optionalSessionStorage( );
200 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(EventTyp eNames::storage, key, oldValue, newValue, pageURL, storage)); 201 if (storage && localFrame->document()->securityOrigin()->canAccess(secur ityOrigin) && !isEventSource(storage, sourceAreaInstance))
202 localFrame->localDOMWindow()->enqueueWindowEvent(StorageEvent::creat e(EventTypeNames::storage, key, oldValue, newValue, pageURL, storage));
201 } 203 }
202 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne wValue, SessionStorage, securityOrigin); 204 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne wValue, SessionStorage, securityOrigin);
203 } 205 }
204 206
205 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst ance) 207 bool StorageArea::isEventSource(Storage* storage, WebStorageArea* sourceAreaInst ance)
206 { 208 {
207 ASSERT(storage); 209 ASSERT(storage);
208 StorageArea* area = storage->area(); 210 StorageArea* area = storage->area();
209 return area->m_storageArea == sourceAreaInstance; 211 return area->m_storageArea == sourceAreaInstance;
210 } 212 }
211 213
212 } // namespace blink 214 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698