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

Side by Side Diff: Source/web/StorageAreaProxy.cpp

Issue 61773005: Rename WebKit namespace to blink (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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
« no previous file with comments | « Source/web/StorageAreaProxy.h ('k') | Source/web/StorageNamespaceProxy.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 #include "WebFrameImpl.h" 45 #include "WebFrameImpl.h"
46 #include "WebPermissionClient.h" 46 #include "WebPermissionClient.h"
47 #include "WebViewImpl.h" 47 #include "WebViewImpl.h"
48 #include "public/platform/WebStorageArea.h" 48 #include "public/platform/WebStorageArea.h"
49 #include "public/platform/WebString.h" 49 #include "public/platform/WebString.h"
50 #include "public/platform/WebURL.h" 50 #include "public/platform/WebURL.h"
51 51
52 namespace WebCore { 52 namespace WebCore {
53 53
54 StorageAreaProxy::StorageAreaProxy(PassOwnPtr<WebKit::WebStorageArea> storageAre a, StorageType storageType) 54 StorageAreaProxy::StorageAreaProxy(PassOwnPtr<blink::WebStorageArea> storageArea , StorageType storageType)
55 : m_storageArea(storageArea) 55 : m_storageArea(storageArea)
56 , m_storageType(storageType) 56 , m_storageType(storageType)
57 , m_canAccessStorageCachedResult(false) 57 , m_canAccessStorageCachedResult(false)
58 , m_canAccessStorageCachedFrame(0) 58 , m_canAccessStorageCachedFrame(0)
59 { 59 {
60 } 60 }
61 61
62 StorageAreaProxy::~StorageAreaProxy() 62 StorageAreaProxy::~StorageAreaProxy()
63 { 63 {
64 } 64 }
(...skipping 24 matching lines...) Expand all
89 } 89 }
90 return m_storageArea->getItem(key); 90 return m_storageArea->getItem(key);
91 } 91 }
92 92
93 void StorageAreaProxy::setItem(const String& key, const String& value, Exception State& es, Frame* frame) 93 void StorageAreaProxy::setItem(const String& key, const String& value, Exception State& es, Frame* frame)
94 { 94 {
95 if (!canAccessStorage(frame)) { 95 if (!canAccessStorage(frame)) {
96 es.throwSecurityError(ExceptionMessages::failedToExecute("setItem", "Sto rage", "access is denied for this document.")); 96 es.throwSecurityError(ExceptionMessages::failedToExecute("setItem", "Sto rage", "access is denied for this document."));
97 return; 97 return;
98 } 98 }
99 WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK; 99 blink::WebStorageArea::Result result = blink::WebStorageArea::ResultOK;
100 m_storageArea->setItem(key, value, frame->document()->url(), result); 100 m_storageArea->setItem(key, value, frame->document()->url(), result);
101 if (result != WebKit::WebStorageArea::ResultOK) 101 if (result != blink::WebStorageArea::ResultOK)
102 es.throwDOMException(QuotaExceededError, ExceptionMessages::failedToExec ute("setItem", "Storage", "Setting the value of '" + key + "' exceeded the quota .")); 102 es.throwDOMException(QuotaExceededError, ExceptionMessages::failedToExec ute("setItem", "Storage", "Setting the value of '" + key + "' exceeded the quota ."));
103 } 103 }
104 104
105 void StorageAreaProxy::removeItem(const String& key, ExceptionState& es, Frame* frame) 105 void StorageAreaProxy::removeItem(const String& key, ExceptionState& es, Frame* frame)
106 { 106 {
107 if (!canAccessStorage(frame)) { 107 if (!canAccessStorage(frame)) {
108 es.throwSecurityError(ExceptionMessages::failedToExecute("removeItem", " Storage", "access is denied for this document.")); 108 es.throwSecurityError(ExceptionMessages::failedToExecute("removeItem", " Storage", "access is denied for this document."));
109 return; 109 return;
110 } 110 }
111 m_storageArea->removeItem(key, frame->document()->url()); 111 m_storageArea->removeItem(key, frame->document()->url());
(...skipping 16 matching lines...) Expand all
128 } 128 }
129 return !getItem(key, es, frame).isNull(); 129 return !getItem(key, es, frame).isNull();
130 } 130 }
131 131
132 bool StorageAreaProxy::canAccessStorage(Frame* frame) 132 bool StorageAreaProxy::canAccessStorage(Frame* frame)
133 { 133 {
134 if (!frame || !frame->page()) 134 if (!frame || !frame->page())
135 return false; 135 return false;
136 if (m_canAccessStorageCachedFrame == frame) 136 if (m_canAccessStorageCachedFrame == frame)
137 return m_canAccessStorageCachedResult; 137 return m_canAccessStorageCachedResult;
138 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); 138 blink::WebFrameImpl* webFrame = blink::WebFrameImpl::fromFrame(frame);
139 WebKit::WebViewImpl* webView = webFrame->viewImpl(); 139 blink::WebViewImpl* webView = webFrame->viewImpl();
140 bool result = !webView->permissionClient() || webView->permissionClient()->a llowStorage(webFrame, m_storageType == LocalStorage); 140 bool result = !webView->permissionClient() || webView->permissionClient()->a llowStorage(webFrame, m_storageType == LocalStorage);
141 m_canAccessStorageCachedFrame = frame; 141 m_canAccessStorageCachedFrame = frame;
142 m_canAccessStorageCachedResult = result; 142 m_canAccessStorageCachedResult = result;
143 return result; 143 return result;
144 } 144 }
145 145
146 size_t StorageAreaProxy::memoryBytesUsedByCache() 146 size_t StorageAreaProxy::memoryBytesUsedByCache()
147 { 147 {
148 return m_storageArea->memoryBytesUsedByCache(); 148 return m_storageArea->memoryBytesUsedByCache();
149 } 149 }
150 150
151 void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String & oldValue, const String& newValue, 151 void StorageAreaProxy::dispatchLocalStorageEvent(const String& key, const String & oldValue, const String& newValue,
152 SecurityOrigin* securityOrigin, const KURL& pageURL, WebKit::WebStorageArea* sourceAreaInstance, bool originate dInProcess) 152 SecurityOrigin* securityOrigin, const KURL& pageURL, blink::WebStorageArea* sourceAreaInstance, bool originated InProcess)
153 { 153 {
154 // FIXME: This looks suspicious. Why doesn't this use allPages instead? 154 // FIXME: This looks suspicious. Why doesn't this use allPages instead?
155 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); 155 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages();
156 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); + +it) { 156 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); + +it) {
157 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra verseNext()) { 157 for (Frame* frame = (*it)->mainFrame(); frame; frame = frame->tree().tra verseNext()) {
158 Storage* storage = frame->domWindow()->optionalLocalStorage(); 158 Storage* storage = frame->domWindow()->optionalLocalStorage();
159 if (storage && frame->document()->securityOrigin()->equal(securityOr igin) && !isEventSource(storage, sourceAreaInstance)) 159 if (storage && frame->document()->securityOrigin()->equal(securityOr igin) && !isEventSource(storage, sourceAreaInstance))
160 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(Even tTypeNames::storage, key, oldValue, newValue, pageURL, storage)); 160 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(Even tTypeNames::storage, key, oldValue, newValue, pageURL, storage));
161 } 161 }
162 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue, newValue, LocalStorage, securityOrigin); 162 InspectorInstrumentation::didDispatchDOMStorageEvent(*it, key, oldValue, newValue, LocalStorage, securityOrigin);
163 } 163 }
164 } 164 }
165 165
166 static Page* findPageWithSessionStorageNamespace(const WebKit::WebStorageNamespa ce& sessionNamespace) 166 static Page* findPageWithSessionStorageNamespace(const blink::WebStorageNamespac e& sessionNamespace)
167 { 167 {
168 // FIXME: This looks suspicious. Why doesn't this use allPages instead? 168 // FIXME: This looks suspicious. Why doesn't this use allPages instead?
169 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages(); 169 const HashSet<Page*>& pages = PageGroup::sharedGroup()->pages();
170 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); + +it) { 170 for (HashSet<Page*>::const_iterator it = pages.begin(); it != pages.end(); + +it) {
171 const bool dontCreateIfMissing = false; 171 const bool dontCreateIfMissing = false;
172 StorageNamespaceProxy* proxy = static_cast<StorageNamespaceProxy*>((*it) ->sessionStorage(dontCreateIfMissing)); 172 StorageNamespaceProxy* proxy = static_cast<StorageNamespaceProxy*>((*it) ->sessionStorage(dontCreateIfMissing));
173 if (proxy && proxy->isSameNamespace(sessionNamespace)) 173 if (proxy && proxy->isSameNamespace(sessionNamespace))
174 return *it; 174 return *it;
175 } 175 }
176 return 0; 176 return 0;
177 } 177 }
178 178
179 void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const Stri ng& oldValue, const String& newValue, 179 void StorageAreaProxy::dispatchSessionStorageEvent(const String& key, const Stri ng& oldValue, const String& newValue,
180 SecurityOrigin* securityOrigi n, const KURL& pageURL, const WebKit::WebStorageNamespace& sessionNamespace, 180 SecurityOrigin* securityOrigi n, const KURL& pageURL, const blink::WebStorageNamespace& sessionNamespace,
181 WebKit::WebStorageArea* sourc eAreaInstance, bool originatedInProcess) 181 blink::WebStorageArea* source AreaInstance, bool originatedInProcess)
182 { 182 {
183 Page* page = findPageWithSessionStorageNamespace(sessionNamespace); 183 Page* page = findPageWithSessionStorageNamespace(sessionNamespace);
184 if (!page) 184 if (!page)
185 return; 185 return;
186 186
187 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse Next()) { 187 for (Frame* frame = page->mainFrame(); frame; frame = frame->tree().traverse Next()) {
188 Storage* storage = frame->domWindow()->optionalSessionStorage(); 188 Storage* storage = frame->domWindow()->optionalSessionStorage();
189 if (storage && frame->document()->securityOrigin()->equal(securityOrigin ) && !isEventSource(storage, sourceAreaInstance)) 189 if (storage && frame->document()->securityOrigin()->equal(securityOrigin ) && !isEventSource(storage, sourceAreaInstance))
190 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(EventTyp eNames::storage, key, oldValue, newValue, pageURL, storage)); 190 frame->domWindow()->enqueueWindowEvent(StorageEvent::create(EventTyp eNames::storage, key, oldValue, newValue, pageURL, storage));
191 } 191 }
192 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne wValue, SessionStorage, securityOrigin); 192 InspectorInstrumentation::didDispatchDOMStorageEvent(page, key, oldValue, ne wValue, SessionStorage, securityOrigin);
193 } 193 }
194 194
195 bool StorageAreaProxy::isEventSource(Storage* storage, WebKit::WebStorageArea* s ourceAreaInstance) 195 bool StorageAreaProxy::isEventSource(Storage* storage, blink::WebStorageArea* so urceAreaInstance)
196 { 196 {
197 ASSERT(storage); 197 ASSERT(storage);
198 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area() ); 198 StorageAreaProxy* areaProxy = static_cast<StorageAreaProxy*>(storage->area() );
199 return areaProxy->m_storageArea == sourceAreaInstance; 199 return areaProxy->m_storageArea == sourceAreaInstance;
200 } 200 }
201 201
202 } // namespace WebCore 202 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/web/StorageAreaProxy.h ('k') | Source/web/StorageNamespaceProxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698