OLD | NEW |
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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "StorageEvent.h" | 42 #include "StorageEvent.h" |
43 | 43 |
44 namespace WebCore { | 44 namespace WebCore { |
45 | 45 |
46 StorageEventDispatcherImpl::StorageEventDispatcherImpl(const String& groupName) | 46 StorageEventDispatcherImpl::StorageEventDispatcherImpl(const String& groupName) |
47 : m_pageGroup(PageGroup::pageGroup(groupName)) | 47 : m_pageGroup(PageGroup::pageGroup(groupName)) |
48 { | 48 { |
49 ASSERT(m_pageGroup); | 49 ASSERT(m_pageGroup); |
50 } | 50 } |
51 | 51 |
| 52 // FIXME(michaeln): add a sourceStorageArea parameter to this |
52 void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const S
tring& oldValue, | 53 void StorageEventDispatcherImpl::dispatchStorageEvent(const String& key, const S
tring& oldValue, |
53 const String& newValue, Se
curityOrigin* securityOrigin, | 54 const String& newValue, Se
curityOrigin* securityOrigin, |
54 const KURL& url, StorageTy
pe storageType) | 55 const KURL& url, StorageTy
pe storageType) |
55 { | 56 { |
56 // FIXME: Implement | 57 // FIXME: Implement |
57 if (storageType == SessionStorage) | 58 if (storageType == SessionStorage) |
58 return; | 59 return; |
59 | 60 |
60 // We need to copy all relevant frames from every page to a vector since sen
ding the event to one frame might mutate the frame tree | 61 // We need to copy all relevant frames from every page to a vector since sen
ding the event to one frame might mutate the frame tree |
61 // of any given page in the group or mutate the page group itself. | 62 // of any given page in the group or mutate the page group itself. |
62 Vector<RefPtr<Frame> > frames; | 63 Vector<RefPtr<Frame> > frames; |
63 | 64 |
64 const HashSet<Page*>& pages = m_pageGroup->pages(); | 65 const HashSet<Page*>& pages = m_pageGroup->pages(); |
65 HashSet<Page*>::const_iterator end = pages.end(); | 66 HashSet<Page*>::const_iterator end = pages.end(); |
66 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { | 67 for (HashSet<Page*>::const_iterator it = pages.begin(); it != end; ++it) { |
67 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) { | 68 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) { |
| 69 // FIXME(michaeln): identify the srcFrame while in this loop too, |
| 70 // and exclude it from 'frames'. |
68 if (frame->document()->securityOrigin()->equal(securityOrigin)) | 71 if (frame->document()->securityOrigin()->equal(securityOrigin)) |
69 frames.append(frame); | 72 frames.append(frame); |
70 } | 73 } |
71 } | 74 } |
72 | 75 |
73 for (unsigned i = 0; i < frames.size(); ++i) { | 76 for (unsigned i = 0; i < frames.size(); ++i) { |
74 ExceptionCode ec = 0; | 77 ExceptionCode ec = 0; |
75 Storage* storage = frames[i]->domWindow()->localStorage(ec); | 78 Storage* storage = frames[i]->domWindow()->localStorage(ec); |
76 if (!ec) | 79 if (!ec) |
77 frames[i]->document()->dispatchWindowEvent(StorageEvent::create(even
tNames().storageEvent, key, oldValue, newValue, url, storage)); | 80 frames[i]->document()->dispatchWindowEvent(StorageEvent::create(even
tNames().storageEvent, key, oldValue, newValue, url, storage)); |
78 } | 81 } |
79 } | 82 } |
80 | 83 |
81 } // namespace WebCore | 84 } // namespace WebCore |
OLD | NEW |