| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 } |
| 65 | 65 |
| 66 unsigned StorageAreaProxy::length(ExceptionState& es, Frame* frame) | 66 unsigned StorageAreaProxy::length(ExceptionState& exceptionState, Frame* frame) |
| 67 { | 67 { |
| 68 if (!canAccessStorage(frame)) { | 68 if (!canAccessStorage(frame)) { |
| 69 es.throwSecurityError(ExceptionMessages::failedToGet("length", "Storage"
, "access is denied for this document.")); | 69 exceptionState.throwSecurityError(ExceptionMessages::failedToGet("length
", "Storage", "access is denied for this document.")); |
| 70 return 0; | 70 return 0; |
| 71 } | 71 } |
| 72 return m_storageArea->length(); | 72 return m_storageArea->length(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 String StorageAreaProxy::key(unsigned index, ExceptionState& es, Frame* frame) | 75 String StorageAreaProxy::key(unsigned index, ExceptionState& exceptionState, Fra
me* frame) |
| 76 { | 76 { |
| 77 if (!canAccessStorage(frame)) { | 77 if (!canAccessStorage(frame)) { |
| 78 es.throwSecurityError(ExceptionMessages::failedToExecute("length", "Stor
age", "access is denied for this document.")); | 78 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("le
ngth", "Storage", "access is denied for this document.")); |
| 79 return String(); | 79 return String(); |
| 80 } | 80 } |
| 81 return m_storageArea->key(index); | 81 return m_storageArea->key(index); |
| 82 } | 82 } |
| 83 | 83 |
| 84 String StorageAreaProxy::getItem(const String& key, ExceptionState& es, Frame* f
rame) | 84 String StorageAreaProxy::getItem(const String& key, ExceptionState& exceptionSta
te, Frame* frame) |
| 85 { | 85 { |
| 86 if (!canAccessStorage(frame)) { | 86 if (!canAccessStorage(frame)) { |
| 87 es.throwSecurityError(ExceptionMessages::failedToExecute("getItem", "Sto
rage", "access is denied for this document.")); | 87 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("ge
tItem", "Storage", "access is denied for this document.")); |
| 88 return String(); | 88 return String(); |
| 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& exceptionState, 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 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("se
tItem", "Storage", "access is denied for this document.")); |
| 97 return; | 97 return; |
| 98 } | 98 } |
| 99 blink::WebStorageArea::Result result = blink::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 != blink::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 exceptionState.throwDOMException(QuotaExceededError, ExceptionMessages::
failedToExecute("setItem", "Storage", "Setting the value of '" + key + "' exceed
ed 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& exceptionSt
ate, 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 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("re
moveItem", "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()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 void StorageAreaProxy::clear(ExceptionState& es, Frame* frame) | 114 void StorageAreaProxy::clear(ExceptionState& exceptionState, Frame* frame) |
| 115 { | 115 { |
| 116 if (!canAccessStorage(frame)) { | 116 if (!canAccessStorage(frame)) { |
| 117 es.throwSecurityError(ExceptionMessages::failedToExecute("clear", "Stora
ge", "access is denied for this document.")); | 117 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("cl
ear", "Storage", "access is denied for this document.")); |
| 118 return; | 118 return; |
| 119 } | 119 } |
| 120 m_storageArea->clear(frame->document()->url()); | 120 m_storageArea->clear(frame->document()->url()); |
| 121 } | 121 } |
| 122 | 122 |
| 123 bool StorageAreaProxy::contains(const String& key, ExceptionState& es, Frame* fr
ame) | 123 bool StorageAreaProxy::contains(const String& key, ExceptionState& exceptionStat
e, Frame* frame) |
| 124 { | 124 { |
| 125 if (!canAccessStorage(frame)) { | 125 if (!canAccessStorage(frame)) { |
| 126 es.throwSecurityError(ExceptionMessages::failedToExecute("contains", "St
orage", "access is denied for this document.")); | 126 exceptionState.throwSecurityError(ExceptionMessages::failedToExecute("co
ntains", "Storage", "access is denied for this document.")); |
| 127 return false; | 127 return false; |
| 128 } | 128 } |
| 129 return !getItem(key, es, frame).isNull(); | 129 return !getItem(key, exceptionState, 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 blink::WebFrameImpl* webFrame = blink::WebFrameImpl::fromFrame(frame); | 138 blink::WebFrameImpl* webFrame = blink::WebFrameImpl::fromFrame(frame); |
| 139 blink::WebViewImpl* webView = webFrame->viewImpl(); | 139 blink::WebViewImpl* webView = webFrame->viewImpl(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 } | 193 } |
| 194 | 194 |
| 195 bool StorageAreaProxy::isEventSource(Storage* storage, blink::WebStorageArea* so
urceAreaInstance) | 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 |
| OLD | NEW |