Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "ios/web/public/browser_state.h" | 5 #include "ios/web/public/browser_state.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "ios/web/active_state_manager_impl.h" | 9 #include "ios/web/active_state_manager_impl.h" |
| 10 #import "ios/web/browsing_data_partition_impl.h" | 10 #import "ios/web/browsing_data_partition_impl.h" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 27 // since reference counted objects can't be user data. | 27 // since reference counted objects can't be user data. |
| 28 struct CertificatePolicyCacheHandle : public base::SupportsUserData::Data { | 28 struct CertificatePolicyCacheHandle : public base::SupportsUserData::Data { |
| 29 explicit CertificatePolicyCacheHandle(CertificatePolicyCache* cache) | 29 explicit CertificatePolicyCacheHandle(CertificatePolicyCache* cache) |
| 30 : policy_cache(cache) {} | 30 : policy_cache(cache) {} |
| 31 | 31 |
| 32 scoped_refptr<CertificatePolicyCache> policy_cache; | 32 scoped_refptr<CertificatePolicyCache> policy_cache; |
| 33 }; | 33 }; |
| 34 } | 34 } |
| 35 | 35 |
| 36 // static | 36 // static |
| 37 bool BrowserState::HasActiveStateManager(BrowserState* browser_state) { | |
|
shreyasv1
2015/12/29 16:09:48
OPTIONAL: Move this closer to |GetActiveStateManag
sdefresne
2015/12/29 16:14:59
Done.
| |
| 38 DCHECK_CURRENTLY_ON_WEB_THREAD(WebThread::UI); | |
| 39 return browser_state->GetUserData(kCertificatePolicyCacheKeyName) != nullptr; | |
|
shreyasv1
2015/12/29 16:09:48
Wrong key.
sdefresne
2015/12/29 16:14:59
Oooops.
| |
| 40 } | |
| 41 | |
| 42 // static | |
| 37 scoped_refptr<CertificatePolicyCache> BrowserState::GetCertificatePolicyCache( | 43 scoped_refptr<CertificatePolicyCache> BrowserState::GetCertificatePolicyCache( |
| 38 BrowserState* browser_state) { | 44 BrowserState* browser_state) { |
| 39 DCHECK_CURRENTLY_ON_WEB_THREAD(WebThread::UI); | 45 DCHECK_CURRENTLY_ON_WEB_THREAD(WebThread::UI); |
| 40 if (!browser_state->GetUserData(kCertificatePolicyCacheKeyName)) { | 46 if (!browser_state->GetUserData(kCertificatePolicyCacheKeyName)) { |
| 41 CertificatePolicyCacheHandle* cert_cache_service_handle = | 47 CertificatePolicyCacheHandle* cert_cache_service_handle = |
| 42 new CertificatePolicyCacheHandle(new CertificatePolicyCache()); | 48 new CertificatePolicyCacheHandle(new CertificatePolicyCache()); |
| 43 | 49 |
| 44 browser_state->SetUserData(kCertificatePolicyCacheKeyName, | 50 browser_state->SetUserData(kCertificatePolicyCacheKeyName, |
| 45 cert_cache_service_handle); | 51 cert_cache_service_handle); |
| 46 } | 52 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 // static | 124 // static |
| 119 BrowserState* BrowserState::FromSupportsUserData( | 125 BrowserState* BrowserState::FromSupportsUserData( |
| 120 base::SupportsUserData* supports_user_data) { | 126 base::SupportsUserData* supports_user_data) { |
| 121 if (!supports_user_data || | 127 if (!supports_user_data || |
| 122 !supports_user_data->GetUserData(kBrowserStateIdentifierKey)) { | 128 !supports_user_data->GetUserData(kBrowserStateIdentifierKey)) { |
| 123 return nullptr; | 129 return nullptr; |
| 124 } | 130 } |
| 125 return static_cast<BrowserState*>(supports_user_data); | 131 return static_cast<BrowserState*>(supports_user_data); |
| 126 } | 132 } |
| 127 } // namespace web | 133 } // namespace web |
| OLD | NEW |