Index: content/browser/dom_storage/dom_storage_context_impl.cc |
diff --git a/content/browser/dom_storage/dom_storage_context_impl.cc b/content/browser/dom_storage/dom_storage_context_impl.cc |
index cd2cdbd49181b9fce9b888f912c708c41fc2096e..450e2c458e0ee4271102b23f00f6c62488750db9 100644 |
--- a/content/browser/dom_storage/dom_storage_context_impl.cc |
+++ b/content/browser/dom_storage/dom_storage_context_impl.cc |
@@ -30,8 +30,9 @@ |
#include "content/public/browser/dom_storage_context.h" |
#include "content/public/browser/local_storage_usage_info.h" |
#include "content/public/browser/session_storage_usage_info.h" |
-#include "content/public/common/origin_util.h" |
#include "storage/browser/quota/special_storage_policy.h" |
+#include "url/gurl.h" |
+#include "url/origin.h" |
namespace content { |
namespace { |
@@ -201,27 +202,30 @@ void DOMStorageContextImpl::GetSessionStorageUsage( |
} |
} |
-void DOMStorageContextImpl::DeleteLocalStorage(const GURL& origin) { |
+void DOMStorageContextImpl::DeleteLocalStorage(const GURL& origin_url) { |
DCHECK(!is_shutdown_); |
+ url::Origin origin(origin_url); |
DOMStorageNamespace* local = GetStorageNamespace(kLocalStorageNamespaceId); |
std::vector<GURL> origins; |
local->GetOriginsWithAreas(&origins); |
// Suborigin storage should be deleted in tandem with the physical origin's |
// storage. https://w3c.github.io/webappsec-suborigins/ |
- for (auto origin_candidate : origins) { |
+ for (auto origin_candidate_url : origins) { |
+ url::Origin origin_candidate(origin_candidate_url); |
// |origin| is guaranteed to be deleted below, so don't delete it until |
- // then. |
- if (origin_candidate == origin || |
- StripSuboriginFromUrl(origin_candidate) != origin) { |
+ // then. That is, only suborigins at the same physical origin as |origin| |
+ // should be deleted at this point. |
+ if (origin.IsSameOriginWith(origin) || |
michaeln
2016/10/17 20:06:59
What is the desired behavior if an "origin_url" ex
jww
2016/10/18 06:44:19
Great point, Michael! In short, yes, you can yet a
|
+ !origin_candidate.IsSamePhysicalOriginWith(origin)) { |
continue; |
} |
- DeleteAndClearStorageNamespaceForOrigin(origin_candidate, local); |
+ DeleteAndClearStorageNamespaceForOrigin(origin_candidate_url, local); |
} |
// It is important to always explicitly delete |origin|. If it does not appear |
// it |origins| above, there still may be a directory open in the namespace in |
// preparation for this storage, and this call will make sure that the |
// directory is deleted. |
- DeleteAndClearStorageNamespaceForOrigin(origin, local); |
+ DeleteAndClearStorageNamespaceForOrigin(origin_url, local); |
} |
void DOMStorageContextImpl::DeleteSessionStorage( |
@@ -624,14 +628,14 @@ void DOMStorageContextImpl::DeleteNextUnusedNamespaceInCommitSequence() { |
} |
void DOMStorageContextImpl::DeleteAndClearStorageNamespaceForOrigin( |
- const GURL& origin, |
+ const GURL& origin_url, |
DOMStorageNamespace* local) { |
- local->DeleteLocalStorageOrigin(origin); |
+ local->DeleteLocalStorageOrigin(origin_url); |
// Synthesize a 'cleared' event if the area is open so CachedAreas in |
// renderers get emptied out too. |
- DOMStorageArea* area = local->GetOpenStorageArea(origin); |
+ DOMStorageArea* area = local->GetOpenStorageArea(origin_url); |
if (area) |
- NotifyAreaCleared(area, origin); |
+ NotifyAreaCleared(area, origin_url); |
} |
} // namespace content |