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 "android_webview/browser/aw_browser_context.h" | 5 #include "android_webview/browser/aw_browser_context.h" |
6 | 6 |
7 #include "android_webview/browser/aw_form_database_service.h" | 7 #include "android_webview/browser/aw_form_database_service.h" |
8 #include "android_webview/browser/aw_pref_store.h" | 8 #include "android_webview/browser/aw_pref_store.h" |
9 #include "android_webview/browser/aw_quota_manager_bridge.h" | 9 #include "android_webview/browser/aw_quota_manager_bridge.h" |
10 #include "android_webview/browser/jni_dependency_factory.h" | 10 #include "android_webview/browser/jni_dependency_factory.h" |
11 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 11 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
12 #include "android_webview/browser/net/init_native_callback.h" | 12 #include "android_webview/browser/net/init_native_callback.h" |
13 #include "base/prefs/pref_registry_simple.h" | 13 #include "base/prefs/pref_registry_simple.h" |
14 #include "base/prefs/pref_service.h" | 14 #include "base/prefs/pref_service.h" |
15 #include "base/prefs/pref_service_builder.h" | 15 #include "base/prefs/pref_service_builder.h" |
16 #include "components/autofill/core/common/autofill_pref_names.h" | 16 #include "components/autofill/core/common/autofill_pref_names.h" |
17 #include "components/user_prefs/user_prefs.h" | 17 #include "components/user_prefs/user_prefs.h" |
18 #include "components/visitedlink/browser/visitedlink_master.h" | 18 #include "components/visitedlink/browser/visitedlink_master.h" |
19 #include "content/public/browser/browser_thread.h" | 19 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/cookie_store_factory.h" | 20 #include "content/public/browser/cookie_store_factory.h" |
21 #include "content/public/browser/resource_context.h" | 21 #include "content/public/browser/resource_context.h" |
22 #include "content/public/browser/storage_partition.h" | 22 #include "content/public/browser/storage_partition.h" |
23 #include "content/public/browser/web_contents.h" | 23 #include "content/public/browser/web_contents.h" |
24 #include "content/public/common/content_constants.h" | |
25 #include "content/public/common/url_constants.h" | |
26 #include "net/cookies/cookie_monster.h" | |
27 #include "net/url_request/url_request_context.h" | 24 #include "net/url_request/url_request_context.h" |
28 | 25 |
29 namespace android_webview { | 26 namespace android_webview { |
30 | 27 |
31 namespace { | 28 namespace { |
32 | 29 |
33 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 30 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
34 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 31 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
35 } | 32 } |
36 | 33 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 } | 88 } |
92 | 89 |
93 // static | 90 // static |
94 AwBrowserContext* AwBrowserContext::FromWebContents( | 91 AwBrowserContext* AwBrowserContext::FromWebContents( |
95 content::WebContents* web_contents) { | 92 content::WebContents* web_contents) { |
96 // This is safe; this is the only implementation of the browser context. | 93 // This is safe; this is the only implementation of the browser context. |
97 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); | 94 return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext()); |
98 } | 95 } |
99 | 96 |
100 void AwBrowserContext::PreMainMessageLoopRun() { | 97 void AwBrowserContext::PreMainMessageLoopRun() { |
101 url_request_context_getter_ = new AwURLRequestContextGetter(GetPath()); | 98 cookie_store_ = content::CreatePersistentCookieStore( |
| 99 GetPath().Append(FILE_PATH_LITERAL("Cookies")), |
| 100 true, |
| 101 NULL, |
| 102 NULL); |
| 103 cookie_store_->GetCookieMonster()->SetPersistSessionCookies(true); |
| 104 url_request_context_getter_ = |
| 105 new AwURLRequestContextGetter(GetPath(), cookie_store_.get()); |
102 | 106 |
103 DidCreateCookieMonster( | 107 DidCreateCookieMonster(cookie_store_->GetCookieMonster()); |
104 GetDefaultStoragePartition(this)->GetCookieStoreForScheme( | |
105 chrome::kHttpScheme)->GetCookieMonster()); | |
106 | 108 |
107 visitedlink_master_.reset( | 109 visitedlink_master_.reset( |
108 new visitedlink::VisitedLinkMaster(this, this, false)); | 110 new visitedlink::VisitedLinkMaster(this, this, false)); |
109 visitedlink_master_->Init(); | 111 visitedlink_master_->Init(); |
110 } | 112 } |
111 | 113 |
112 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 114 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
113 DCHECK(visitedlink_master_); | 115 DCHECK(visitedlink_master_); |
114 visitedlink_master_->AddURLs(urls); | 116 visitedlink_master_->AddURLs(urls); |
115 } | 117 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 pref_service_builder.WithReadErrorCallback(base::Bind(&HandleReadError)); | 175 pref_service_builder.WithReadErrorCallback(base::Bind(&HandleReadError)); |
174 | 176 |
175 user_prefs::UserPrefs::Set(this, | 177 user_prefs::UserPrefs::Set(this, |
176 pref_service_builder.Create(pref_registry)); | 178 pref_service_builder.Create(pref_registry)); |
177 } | 179 } |
178 | 180 |
179 base::FilePath AwBrowserContext::GetPath() const { | 181 base::FilePath AwBrowserContext::GetPath() const { |
180 return context_storage_path_; | 182 return context_storage_path_; |
181 } | 183 } |
182 | 184 |
183 void AwBrowserContext::OverrideCookieStoreConfigs( | |
184 const base::FilePath& partition_path, | |
185 bool in_memory_partition, | |
186 bool is_default_partition, | |
187 CookieSchemeMap* configs) { | |
188 using content::CookieStoreConfig; | |
189 configs->clear(); | |
190 // By default session cookies are always restored. An Android application can | |
191 // control this policy by calling CookieManager.removeSessionCookie() when | |
192 // Activity.onCreate() is called with savedInstanceState == null. | |
193 (*configs)[content::BrowserContext::kDefaultCookieScheme] = | |
194 CookieStoreConfig(partition_path.Append(content::kCookieFilename), | |
195 CookieStoreConfig::RESTORED_SESSION_COOKIES, | |
196 NULL, NULL); | |
197 } | |
198 | |
199 bool AwBrowserContext::IsOffTheRecord() const { | 185 bool AwBrowserContext::IsOffTheRecord() const { |
200 // Android WebView does not support off the record profile yet. | 186 // Android WebView does not support off the record profile yet. |
201 return false; | 187 return false; |
202 } | 188 } |
203 | 189 |
204 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { | 190 net::URLRequestContextGetter* AwBrowserContext::GetRequestContext() { |
205 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 191 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
206 } | 192 } |
207 | 193 |
208 net::URLRequestContextGetter* | 194 net::URLRequestContextGetter* |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 | 254 |
269 void AwBrowserContext::RebuildTable( | 255 void AwBrowserContext::RebuildTable( |
270 const scoped_refptr<URLEnumerator>& enumerator) { | 256 const scoped_refptr<URLEnumerator>& enumerator) { |
271 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 257 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
272 // can change in the lifetime of this WebView and may not yet be set here. | 258 // can change in the lifetime of this WebView and may not yet be set here. |
273 // Therefore this initialization path is not used. | 259 // Therefore this initialization path is not used. |
274 enumerator->OnComplete(true); | 260 enumerator->OnComplete(true); |
275 } | 261 } |
276 | 262 |
277 } // namespace android_webview | 263 } // namespace android_webview |
OLD | NEW |