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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 #include "platform/WebString.h" | 46 #include "platform/WebString.h" |
47 #include "platform/WebURL.h" | 47 #include "platform/WebURL.h" |
48 #include "WebViewImpl.h" | 48 #include "WebViewImpl.h" |
49 | 49 |
50 namespace WebCore { | 50 namespace WebCore { |
51 | 51 |
52 // FIXME: storageArea argument should be a PassOwnPtr. | 52 // FIXME: storageArea argument should be a PassOwnPtr. |
53 StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea, StorageT
ype storageType) | 53 StorageAreaProxy::StorageAreaProxy(WebKit::WebStorageArea* storageArea, StorageT
ype storageType) |
54 : m_storageArea(adoptPtr(storageArea)) | 54 : m_storageArea(adoptPtr(storageArea)) |
55 , m_storageType(storageType) | 55 , m_storageType(storageType) |
| 56 , m_cachedCanAccessSetting(false) |
| 57 , m_cachedCanAccessSettingForFrame(0) |
56 { | 58 { |
57 } | 59 } |
58 | 60 |
59 StorageAreaProxy::~StorageAreaProxy() | 61 StorageAreaProxy::~StorageAreaProxy() |
60 { | 62 { |
61 } | 63 } |
62 | 64 |
63 unsigned StorageAreaProxy::length(Frame* frame) const | 65 unsigned StorageAreaProxy::length(Frame* frame) const |
64 { | 66 { |
65 if (canAccessStorage(frame)) | 67 if (canAccessStorage(frame)) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 103 |
102 void StorageAreaProxy::clear(Frame* frame) | 104 void StorageAreaProxy::clear(Frame* frame) |
103 { | 105 { |
104 if (!canAccessStorage(frame)) | 106 if (!canAccessStorage(frame)) |
105 return; | 107 return; |
106 m_storageArea->clear(frame->document()->url()); | 108 m_storageArea->clear(frame->document()->url()); |
107 } | 109 } |
108 | 110 |
109 bool StorageAreaProxy::contains(const String& key, Frame* frame) const | 111 bool StorageAreaProxy::contains(const String& key, Frame* frame) const |
110 { | 112 { |
111 return !getItem(key, frame).isNull(); | 113 if (!canAccessStorage(frame)) |
| 114 return false; |
| 115 return m_storageArea->containsItem(key); |
112 } | 116 } |
113 | 117 |
114 bool StorageAreaProxy::canAccessStorage(Frame* frame) const | 118 bool StorageAreaProxy::canAccessStorage(Frame* frame) const |
115 { | 119 { |
116 if (!frame->page()) | 120 if (!frame->page()) |
117 return false; | 121 return false; |
| 122 if (m_cachedCanAccessSettingForFrame == reinterpret_cast<void*>(frame)) |
| 123 return m_cachedCanAccessSetting; |
| 124 |
118 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); | 125 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); |
119 WebKit::WebViewImpl* webView = webFrame->viewImpl(); | 126 WebKit::WebViewImpl* webView = webFrame->viewImpl(); |
120 return !webView->permissionClient() || webView->permissionClient()->allowSto
rage(webFrame, m_storageType == LocalStorage); | 127 m_cachedCanAccessSetting = !webView->permissionClient() || webView->permissi
onClient()->allowStorage(webFrame, m_storageType == LocalStorage); |
| 128 m_cachedCanAccessSettingForFrame = reinterpret_cast<void*>(frame); |
| 129 return m_cachedCanAccessSetting; |
121 } | 130 } |
122 | 131 |
123 void StorageAreaProxy::dispatchLocalStorageEvent(PageGroup* pageGroup, const Str
ing& key, const String& oldValue, const String& newValue, | 132 void StorageAreaProxy::dispatchLocalStorageEvent(PageGroup* pageGroup, const Str
ing& key, const String& oldValue, const String& newValue, |
124 SecurityOrigin* securityOrigin,
const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originate
dInProcess) | 133 SecurityOrigin* securityOrigin,
const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originate
dInProcess) |
125 { | 134 { |
126 const HashSet<Page*>& pages = pageGroup->pages(); | 135 const HashSet<Page*>& pages = pageGroup->pages(); |
127 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { | 136 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); +
+it) { |
128 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) { | 137 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree()->tr
averseNext()) { |
129 Storage* storage = frame->domWindow()->optionalLocalStorage(); | 138 Storage* storage = frame->domWindow()->optionalLocalStorage(); |
130 if (storage && frame->document()->securityOrigin()->equal(securityOr
igin) && !isEventSource(storage, sourceAreaInstance)) | 139 if (storage && frame->document()->securityOrigin()->equal(securityOr
igin) && !isEventSource(storage, sourceAreaInstance)) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 172 } |
164 | 173 |
165 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s
ourceAreaInstance) | 174 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s
ourceAreaInstance) |
166 { | 175 { |
167 ASSERT(storage); | 176 ASSERT(storage); |
168 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area()
); | 177 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area()
); |
169 return areaProxy->m_storageArea == sourceAreaInstance; | 178 return areaProxy->m_storageArea == sourceAreaInstance; |
170 } | 179 } |
171 | 180 |
172 } // namespace WebCore | 181 } // namespace WebCore |
OLD | NEW |