| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. | 3 * Copyright (C) 2013 Samsung Electronics. All rights reserved. |
| 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 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "core/storage/StorageNamespace.h" | 47 #include "core/storage/StorageNamespace.h" |
| 48 #include "platform/JSONValues.h" | 48 #include "platform/JSONValues.h" |
| 49 #include "platform/weborigin/SecurityOrigin.h" | 49 #include "platform/weborigin/SecurityOrigin.h" |
| 50 | 50 |
| 51 namespace WebCore { | 51 namespace WebCore { |
| 52 | 52 |
| 53 namespace DOMStorageAgentState { | 53 namespace DOMStorageAgentState { |
| 54 static const char domStorageAgentEnabled[] = "domStorageAgentEnabled"; | 54 static const char domStorageAgentEnabled[] = "domStorageAgentEnabled"; |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 static bool hadException(ExceptionState& es, ErrorString* errorString) | 57 static bool hadException(ExceptionState& exceptionState, ErrorString* errorStrin
g) |
| 58 { | 58 { |
| 59 if (!es.hadException()) | 59 if (!exceptionState.hadException()) |
| 60 return false; | 60 return false; |
| 61 | 61 |
| 62 switch (es.code()) { | 62 switch (exceptionState.code()) { |
| 63 case SecurityError: | 63 case SecurityError: |
| 64 *errorString = "Security error"; | 64 *errorString = "Security error"; |
| 65 return true; | 65 return true; |
| 66 default: | 66 default: |
| 67 *errorString = "Unknown DOM storage error"; | 67 *errorString = "Unknown DOM storage error"; |
| 68 return true; | 68 return true; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 InspectorDOMStorageAgent::InspectorDOMStorageAgent(InstrumentingAgents* instrume
ntingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state) | 72 InspectorDOMStorageAgent::InspectorDOMStorageAgent(InstrumentingAgents* instrume
ntingAgents, InspectorPageAgent* pageAgent, InspectorCompositeState* state) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 | 110 |
| 111 void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, cons
t RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<St
ring> > >& items) | 111 void InspectorDOMStorageAgent::getDOMStorageItems(ErrorString* errorString, cons
t RefPtr<JSONObject>& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<St
ring> > >& items) |
| 112 { | 112 { |
| 113 Frame* frame; | 113 Frame* frame; |
| 114 OwnPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, fr
ame); | 114 OwnPtr<StorageArea> storageArea = findStorageArea(errorString, storageId, fr
ame); |
| 115 if (!storageArea) | 115 if (!storageArea) |
| 116 return; | 116 return; |
| 117 | 117 |
| 118 RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > > storageItems = Type
Builder::Array<TypeBuilder::Array<String> >::create(); | 118 RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > > storageItems = Type
Builder::Array<TypeBuilder::Array<String> >::create(); |
| 119 | 119 |
| 120 TrackExceptionState es; | 120 TrackExceptionState exceptionState; |
| 121 for (unsigned i = 0; i < storageArea->length(es, frame); ++i) { | 121 for (unsigned i = 0; i < storageArea->length(exceptionState, frame); ++i) { |
| 122 String name(storageArea->key(i, es, frame)); | 122 String name(storageArea->key(i, exceptionState, frame)); |
| 123 if (hadException(es, errorString)) | 123 if (hadException(exceptionState, errorString)) |
| 124 return; | 124 return; |
| 125 String value(storageArea->getItem(name, es, frame)); | 125 String value(storageArea->getItem(name, exceptionState, frame)); |
| 126 if (hadException(es, errorString)) | 126 if (hadException(exceptionState, errorString)) |
| 127 return; | 127 return; |
| 128 RefPtr<TypeBuilder::Array<String> > entry = TypeBuilder::Array<String>::
create(); | 128 RefPtr<TypeBuilder::Array<String> > entry = TypeBuilder::Array<String>::
create(); |
| 129 entry->addItem(name); | 129 entry->addItem(name); |
| 130 entry->addItem(value); | 130 entry->addItem(value); |
| 131 storageItems->addItem(entry); | 131 storageItems->addItem(entry); |
| 132 } | 132 } |
| 133 items = storageItems.release(); | 133 items = storageItems.release(); |
| 134 } | 134 } |
| 135 | 135 |
| 136 static String toErrorString(ExceptionState& es) | 136 static String toErrorString(ExceptionState& exceptionState) |
| 137 { | 137 { |
| 138 if (es.hadException()) | 138 if (exceptionState.hadException()) |
| 139 return DOMException::getErrorName(es.code()); | 139 return DOMException::getErrorName(exceptionState.code()); |
| 140 return ""; | 140 return ""; |
| 141 } | 141 } |
| 142 | 142 |
| 143 void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const
RefPtr<JSONObject>& storageId, const String& key, const String& value) | 143 void InspectorDOMStorageAgent::setDOMStorageItem(ErrorString* errorString, const
RefPtr<JSONObject>& storageId, const String& key, const String& value) |
| 144 { | 144 { |
| 145 Frame* frame; | 145 Frame* frame; |
| 146 OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); | 146 OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); |
| 147 if (!storageArea) { | 147 if (!storageArea) { |
| 148 *errorString = "Storage not found"; | 148 *errorString = "Storage not found"; |
| 149 return; | 149 return; |
| 150 } | 150 } |
| 151 | 151 |
| 152 TrackExceptionState es; | 152 TrackExceptionState exceptionState; |
| 153 storageArea->setItem(key, value, es, frame); | 153 storageArea->setItem(key, value, exceptionState, frame); |
| 154 *errorString = toErrorString(es); | 154 *errorString = toErrorString(exceptionState); |
| 155 } | 155 } |
| 156 | 156 |
| 157 void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, co
nst RefPtr<JSONObject>& storageId, const String& key) | 157 void InspectorDOMStorageAgent::removeDOMStorageItem(ErrorString* errorString, co
nst RefPtr<JSONObject>& storageId, const String& key) |
| 158 { | 158 { |
| 159 Frame* frame; | 159 Frame* frame; |
| 160 OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); | 160 OwnPtr<StorageArea> storageArea = findStorageArea(0, storageId, frame); |
| 161 if (!storageArea) { | 161 if (!storageArea) { |
| 162 *errorString = "Storage not found"; | 162 *errorString = "Storage not found"; |
| 163 return; | 163 return; |
| 164 } | 164 } |
| 165 | 165 |
| 166 TrackExceptionState es; | 166 TrackExceptionState exceptionState; |
| 167 storageArea->removeItem(key, es, frame); | 167 storageArea->removeItem(key, exceptionState, frame); |
| 168 *errorString = toErrorString(es); | 168 *errorString = toErrorString(exceptionState); |
| 169 } | 169 } |
| 170 | 170 |
| 171 String InspectorDOMStorageAgent::storageId(Storage* storage) | 171 String InspectorDOMStorageAgent::storageId(Storage* storage) |
| 172 { | 172 { |
| 173 ASSERT(storage); | 173 ASSERT(storage); |
| 174 Document* document = storage->frame()->document(); | 174 Document* document = storage->frame()->document(); |
| 175 ASSERT(document); | 175 ASSERT(document); |
| 176 DOMWindow* window = document->domWindow(); | 176 DOMWindow* window = document->domWindow(); |
| 177 ASSERT(window); | 177 ASSERT(window); |
| 178 RefPtr<SecurityOrigin> securityOrigin = document->securityOrigin(); | 178 RefPtr<SecurityOrigin> securityOrigin = document->securityOrigin(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 } | 225 } |
| 226 targetFrame = frame; | 226 targetFrame = frame; |
| 227 | 227 |
| 228 if (isLocalStorage) | 228 if (isLocalStorage) |
| 229 return StorageNamespace::localStorageArea(frame->document()->securityOri
gin()); | 229 return StorageNamespace::localStorageArea(frame->document()->securityOri
gin()); |
| 230 return m_pageAgent->page()->sessionStorage()->storageArea(frame->document()-
>securityOrigin()); | 230 return m_pageAgent->page()->sessionStorage()->storageArea(frame->document()-
>securityOrigin()); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace WebCore | 233 } // namespace WebCore |
| 234 | 234 |
| OLD | NEW |