OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "content/browser/net/quota_policy_server_bound_cert_store.h" | |
6 | |
7 #include <list> | |
8 #include <set> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/bind.h" | |
12 #include "base/file_util.h" | |
13 #include "base/files/file_path.h" | |
14 #include "base/logging.h" | |
15 #include "base/metrics/histogram.h" | |
16 #include "base/strings/string_util.h" | |
17 #include "base/threading/thread.h" | |
18 #include "base/threading/thread_restrictions.h" | |
19 #include "net/cookies/cookie_util.h" | |
20 #include "net/util/sqlite/sqlite_server_bound_cert_store.h" | |
21 #include "url/gurl.h" | |
22 #include "webkit/browser/quota/special_storage_policy.h" | |
23 | |
24 namespace content { | |
25 | |
26 QuotaPolicyServerBoundCertStore::QuotaPolicyServerBoundCertStore( | |
27 const base::FilePath& path, | |
28 const scoped_refptr<base::SequencedTaskRunner>& background_task_runner, | |
29 quota::SpecialStoragePolicy* special_storage_policy) | |
30 : force_keep_session_state_(false), | |
31 special_storage_policy_(special_storage_policy), | |
32 persistent_( | |
33 new net::SQLiteServerBoundCertStore(path, background_task_runner)), | |
34 temporary_( | |
35 new net::SQLiteServerBoundCertStore(path, background_task_runner)) { | |
36 } | |
37 | |
38 QuotaPolicyServerBoundCertStore::~QuotaPolicyServerBoundCertStore() { | |
39 // TODO(mef): delete temporary file. | |
40 // temporary_.release(); | |
41 } | |
42 | |
43 void QuotaPolicyServerBoundCertStore::Load( | |
44 const LoadedCallback& loaded_callback) { | |
45 persistent_->Load(loaded_callback); | |
46 } | |
47 | |
48 void QuotaPolicyServerBoundCertStore::AddServerBoundCert( | |
49 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { | |
50 if (IsStorageSessionOnly(cert)) { | |
51 temporary_->AddServerBoundCert(cert); | |
52 } else { | |
53 persistent_->AddServerBoundCert(cert); | |
54 } | |
55 } | |
56 | |
57 void QuotaPolicyServerBoundCertStore::DeleteServerBoundCert( | |
58 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { | |
59 if (IsStorageSessionOnly(cert)) { | |
60 temporary_->DeleteServerBoundCert(cert); | |
61 } else { | |
62 persistent_->DeleteServerBoundCert(cert); | |
63 } | |
64 } | |
65 | |
66 void QuotaPolicyServerBoundCertStore::SetForceKeepSessionState() { | |
67 force_keep_session_state_ = true; | |
68 } | |
69 | |
70 bool QuotaPolicyServerBoundCertStore::IsStorageSessionOnly( | |
71 const net::DefaultServerBoundCertStore::ServerBoundCert& cert) { | |
72 if (force_keep_session_state_ || !special_storage_policy_.get()) | |
73 return false; | |
74 const GURL url( | |
75 net::cookie_util::CookieOriginToURL(cert.server_identifier(), true)); | |
76 return !url.is_valid() || !special_storage_policy_->IsStorageSessionOnly(url); | |
Ryan Sleevi
2014/07/24 23:47:32
What about certs that the ssp decides later are Is
mef
2014/07/30 22:12:05
Good question, I actually don't know.
I imagine t
| |
77 } | |
78 | |
79 } // namespace content | |
OLD | NEW |