[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 1 | // Copyright (c) 2009 The Chromium Authors. All rights reserved. Use of this |
| 2 | // source code is governed by a BSD-style license that can be found in the |
| 3 | // LICENSE file. |
| 4 | |
| 5 | #include "chrome/renderer/renderer_webstoragearea_impl.h" |
| 6 | |
| 7 | #include "chrome/common/render_messages.h" |
| 8 | #include "chrome/renderer/render_thread.h" |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 9 | #include "webkit/api/public/WebURL.h" |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 10 | |
[email protected] | 15bf871 | 2009-08-27 00:55:02 | [diff] [blame] | 11 | using WebKit::WebString; |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 12 | using WebKit::WebURL; |
[email protected] | 15bf871 | 2009-08-27 00:55:02 | [diff] [blame] | 13 | |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 14 | RendererWebStorageAreaImpl::RendererWebStorageAreaImpl( |
[email protected] | 3d392a6f | 2009-09-11 03:58:45 | [diff] [blame] | 15 | int64 namespace_id, const WebString& origin) { |
| 16 | RenderThread::current()->Send( |
| 17 | new ViewHostMsg_DOMStorageStorageAreaId(namespace_id, origin, |
| 18 | &storage_area_id_)); |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | RendererWebStorageAreaImpl::~RendererWebStorageAreaImpl() { |
| 22 | } |
| 23 | |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 24 | unsigned RendererWebStorageAreaImpl::length() { |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 25 | unsigned length; |
| 26 | RenderThread::current()->Send( |
| 27 | new ViewHostMsg_DOMStorageLength(storage_area_id_, &length)); |
| 28 | return length; |
| 29 | } |
| 30 | |
[email protected] | 15bf871 | 2009-08-27 00:55:02 | [diff] [blame] | 31 | WebString RendererWebStorageAreaImpl::key(unsigned index) { |
[email protected] | 15bf871 | 2009-08-27 00:55:02 | [diff] [blame] | 32 | NullableString16 key; |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 33 | RenderThread::current()->Send( |
[email protected] | 15bf871 | 2009-08-27 00:55:02 | [diff] [blame] | 34 | new ViewHostMsg_DOMStorageKey(storage_area_id_, index, &key)); |
| 35 | return key; |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 36 | } |
| 37 | |
[email protected] | 3d392a6f | 2009-09-11 03:58:45 | [diff] [blame] | 38 | WebString RendererWebStorageAreaImpl::getItem(const WebString& key) { |
| 39 | NullableString16 value; |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 40 | RenderThread::current()->Send( |
[email protected] | 3d392a6f | 2009-09-11 03:58:45 | [diff] [blame] | 41 | new ViewHostMsg_DOMStorageGetItem(storage_area_id_, key, &value)); |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 42 | return value; |
| 43 | } |
| 44 | |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 45 | void RendererWebStorageAreaImpl::setItem( |
| 46 | const WebString& key, const WebString& value, const WebURL& url, |
| 47 | bool& quota_exception) { |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 48 | RenderThread::current()->Send( |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 49 | new ViewHostMsg_DOMStorageSetItem(storage_area_id_, key, value, url, |
[email protected] | 75c91e64 | 2009-10-03 06:51:15 | [diff] [blame] | 50 | "a_exception)); |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 51 | } |
| 52 | |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 53 | void RendererWebStorageAreaImpl::removeItem(const WebString& key, |
| 54 | const WebURL& url) { |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 55 | RenderThread::current()->Send( |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 56 | new ViewHostMsg_DOMStorageRemoveItem(storage_area_id_, key, url)); |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 57 | } |
| 58 | |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 59 | void RendererWebStorageAreaImpl::clear(const WebURL& url) { |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 60 | RenderThread::current()->Send( |
[email protected] | ee2be5b3 | 2009-11-05 09:13:12 | [diff] [blame] | 61 | new ViewHostMsg_DOMStorageClear(storage_area_id_, url)); |
[email protected] | 2a10f681 | 2009-07-24 01:22:51 | [diff] [blame] | 62 | } |