OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "webkit/dom_storage/dom_storage_host.h" | 5 #include "webkit/dom_storage/dom_storage_host.h" |
6 | 6 |
7 #include "googleurl/src/gurl.h" | 7 #include "googleurl/src/gurl.h" |
8 #include "webkit/dom_storage/dom_storage_area.h" | 8 #include "webkit/dom_storage/dom_storage_area.h" |
9 #include "webkit/dom_storage/dom_storage_context.h" | 9 #include "webkit/dom_storage/dom_storage_context.h" |
10 #include "webkit/dom_storage/dom_storage_namespace.h" | 10 #include "webkit/dom_storage/dom_storage_namespace.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 bool DomStorageHost::ClearArea(int connection_id, const GURL& page_url) { | 108 bool DomStorageHost::ClearArea(int connection_id, const GURL& page_url) { |
109 DomStorageArea* area = GetOpenArea(connection_id); | 109 DomStorageArea* area = GetOpenArea(connection_id); |
110 if (!area) | 110 if (!area) |
111 return false; | 111 return false; |
112 if (!area->Clear()) | 112 if (!area->Clear()) |
113 return false; | 113 return false; |
114 context_->NotifyAreaCleared(area, page_url); | 114 context_->NotifyAreaCleared(area, page_url); |
115 return true; | 115 return true; |
116 } | 116 } |
117 | 117 |
| 118 bool DomStorageHost::HasAreaOpen( |
| 119 int namespace_id, const GURL& origin) const { |
| 120 AreaMap::const_iterator it = connections_.begin(); |
| 121 for (; it != connections_.end(); ++it) { |
| 122 if (namespace_id == it->second.namespace_->namespace_id() && |
| 123 origin == it->second.area_->origin()) { |
| 124 return true; |
| 125 } |
| 126 } |
| 127 return false; |
| 128 } |
| 129 |
118 DomStorageArea* DomStorageHost::GetOpenArea(int connection_id) { | 130 DomStorageArea* DomStorageHost::GetOpenArea(int connection_id) { |
119 AreaMap::iterator found = connections_.find(connection_id); | 131 AreaMap::iterator found = connections_.find(connection_id); |
120 if (found == connections_.end()) | 132 if (found == connections_.end()) |
121 return NULL; | 133 return NULL; |
122 return found->second.area_; | 134 return found->second.area_; |
123 } | 135 } |
124 | 136 |
125 // NamespaceAndArea | 137 // NamespaceAndArea |
126 | 138 |
127 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} | 139 DomStorageHost::NamespaceAndArea::NamespaceAndArea() {} |
128 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} | 140 DomStorageHost::NamespaceAndArea::~NamespaceAndArea() {} |
129 | 141 |
130 } // namespace dom_storage | 142 } // namespace dom_storage |
OLD | NEW |