blob: 1d3955144c25916fb6517985034f8cb43a85a0a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/net/clear_on_exit_policy.h"
#include "content/public/common/url_constants.h"
#include "googleurl/src/gurl.h"
#include "webkit/quota/special_storage_policy.h"
ClearOnExitPolicy::ClearOnExitPolicy(
quota::SpecialStoragePolicy* special_storage_policy)
: special_storage_policy_(special_storage_policy) {
}
ClearOnExitPolicy::~ClearOnExitPolicy() {
}
bool ClearOnExitPolicy::HasClearOnExitOrigins() {
return special_storage_policy_.get() &&
special_storage_policy_->HasSessionOnlyOrigins();
}
bool ClearOnExitPolicy::ShouldClearOriginOnExit(const std::string& domain,
bool scheme_is_secure) {
if (domain.length() == 0)
return false;
std::string scheme =
scheme_is_secure ? chrome::kHttpsScheme : chrome::kHttpScheme;
std::string host = domain[0] == '.' ? domain.substr(1) : domain;
GURL url(scheme + content::kStandardSchemeSeparator + host);
return special_storage_policy_->IsStorageSessionOnly(url) &&
!special_storage_policy_->IsStorageProtected(url);
}
|