| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 5 #ifndef CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ |
| 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 6 #define CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/hash_tables.h" | 9 #include "base/hash_tables.h" |
| 10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 12 #include "base/nullable_string16.h" | 12 #include "base/nullable_string16.h" |
| 13 #include "base/string16.h" | 13 #include "base/string16.h" |
| 14 #include "content/common/dom_storage_common.h" | 14 #include "content/common/dom_storage_common.h" |
| 15 #include "googleurl/src/gurl.h" | 15 #include "googleurl/src/gurl.h" |
| 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" | 16 #include "third_party/WebKit/Source/WebKit/chromium/public/WebStorageArea.h" |
| 17 | 17 |
| 18 class DOMStorageNamespace; | 18 class DOMStorageNamespace; |
| 19 class HostContentSettingsMap; | |
| 20 | |
| 21 // Only use on the WebKit thread. DOMStorageNamespace manages our registration | 19 // Only use on the WebKit thread. DOMStorageNamespace manages our registration |
| 22 // with DOMStorageContext. | 20 // with DOMStorageContext. |
| 23 class DOMStorageArea { | 21 class DOMStorageArea { |
| 24 public: | 22 public: |
| 25 DOMStorageArea(const string16& origin, | 23 DOMStorageArea(const string16& origin, |
| 26 int64 id, | 24 int64 id, |
| 27 DOMStorageNamespace* owner, | 25 DOMStorageNamespace* owner); |
| 28 HostContentSettingsMap* host_content_settings_map); | |
| 29 ~DOMStorageArea(); | 26 ~DOMStorageArea(); |
| 30 | 27 |
| 31 unsigned Length(); | 28 unsigned Length(); |
| 32 NullableString16 Key(unsigned index); | 29 NullableString16 Key(unsigned index); |
| 33 NullableString16 GetItem(const string16& key); | 30 NullableString16 GetItem(const string16& key); |
| 34 NullableString16 SetItem( | 31 NullableString16 SetItem( |
| 35 const string16& key, const string16& value, | 32 const string16& key, const string16& value, |
| 36 WebKit::WebStorageArea::Result* result); | 33 WebKit::WebStorageArea::Result* result); |
| 37 NullableString16 RemoveItem(const string16& key); | 34 NullableString16 RemoveItem(const string16& key); |
| 38 bool Clear(); | 35 bool Clear(); |
| 39 void PurgeMemory(); | 36 void PurgeMemory(); |
| 40 | 37 |
| 41 int64 id() const { return id_; } | 38 int64 id() const { return id_; } |
| 42 | 39 |
| 43 DOMStorageNamespace* owner() const { return owner_; } | 40 DOMStorageNamespace* owner() const { return owner_; } |
| 44 | 41 |
| 45 private: | 42 private: |
| 46 // Creates the underlying WebStorageArea on demand. | 43 // Creates the underlying WebStorageArea on demand. |
| 47 void CreateWebStorageAreaIfNecessary(); | 44 void CreateWebStorageAreaIfNecessary(); |
| 48 | 45 |
| 49 // Used to see if setItem has permission to do its thing. | |
| 50 bool CheckContentSetting(const string16& key, const string16& value); | |
| 51 | |
| 52 // The origin this storage area represents. | 46 // The origin this storage area represents. |
| 53 string16 origin_; | 47 string16 origin_; |
| 54 GURL origin_url_; | 48 GURL origin_url_; |
| 55 | 49 |
| 56 // The storage area we wrap. | 50 // The storage area we wrap. |
| 57 scoped_ptr<WebKit::WebStorageArea> storage_area_; | 51 scoped_ptr<WebKit::WebStorageArea> storage_area_; |
| 58 | 52 |
| 59 // Our storage area id. Unique to our parent WebKitContext. | 53 // Our storage area id. Unique to our parent WebKitContext. |
| 60 int64 id_; | 54 int64 id_; |
| 61 | 55 |
| 62 // The DOMStorageNamespace that owns us. | 56 // The DOMStorageNamespace that owns us. |
| 63 DOMStorageNamespace* owner_; | 57 DOMStorageNamespace* owner_; |
| 64 | 58 |
| 65 scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | |
| 66 | |
| 67 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); | 59 DISALLOW_IMPLICIT_CONSTRUCTORS(DOMStorageArea); |
| 68 }; | 60 }; |
| 69 | 61 |
| 70 #if defined(COMPILER_GCC) | 62 #if defined(COMPILER_GCC) |
| 71 namespace __gnu_cxx { | 63 namespace __gnu_cxx { |
| 72 | 64 |
| 73 template<> | 65 template<> |
| 74 struct hash<DOMStorageArea*> { | 66 struct hash<DOMStorageArea*> { |
| 75 std::size_t operator()(DOMStorageArea* const& p) const { | 67 std::size_t operator()(DOMStorageArea* const& p) const { |
| 76 return reinterpret_cast<std::size_t>(p); | 68 return reinterpret_cast<std::size_t>(p); |
| 77 } | 69 } |
| 78 }; | 70 }; |
| 79 | 71 |
| 80 } // namespace __gnu_cxx | 72 } // namespace __gnu_cxx |
| 81 #endif | 73 #endif |
| 82 | 74 |
| 83 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ | 75 #endif // CONTENT_BROWSER_IN_PROCESS_WEBKIT_DOM_STORAGE_AREA_H_ |
| OLD | NEW |