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_browser_policy_connector.h" | 7 #include "android_webview/browser/aw_browser_policy_connector.h" |
8 #include "android_webview/browser/aw_form_database_service.h" | 8 #include "android_webview/browser/aw_form_database_service.h" |
9 #include "android_webview/browser/aw_permission_manager.h" | 9 #include "android_webview/browser/aw_permission_manager.h" |
10 #include "android_webview/browser/aw_pref_store.h" | 10 #include "android_webview/browser/aw_pref_store.h" |
(...skipping 29 matching lines...) Expand all Loading... |
40 #include "content/public/browser/web_contents.h" | 40 #include "content/public/browser/web_contents.h" |
41 #include "net/cookies/cookie_store.h" | 41 #include "net/cookies/cookie_store.h" |
42 #include "net/proxy/proxy_config_service_android.h" | 42 #include "net/proxy/proxy_config_service_android.h" |
43 #include "net/proxy/proxy_service.h" | 43 #include "net/proxy/proxy_service.h" |
44 | 44 |
45 using base::FilePath; | 45 using base::FilePath; |
46 using content::BrowserThread; | 46 using content::BrowserThread; |
47 | 47 |
48 namespace android_webview { | 48 namespace android_webview { |
49 | 49 |
| 50 namespace prefs { |
| 51 |
| 52 // String that specifies the Android account type to use for Negotiate |
| 53 // authentication. |
| 54 const char kAuthAndroidNegotiateAccountType[] = |
| 55 "auth.android_negotiate_account_type"; |
| 56 |
| 57 // Whitelist containing servers for which Integrated Authentication is enabled. |
| 58 const char kAuthServerWhitelist[] = "auth.server_whitelist"; |
| 59 |
| 60 } // namespace prefs |
| 61 |
50 namespace { | 62 namespace { |
51 | 63 |
52 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 64 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
53 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 65 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
54 } | 66 } |
55 | 67 |
56 void DeleteDirRecursively(const base::FilePath& path) { | 68 void DeleteDirRecursively(const base::FilePath& path) { |
57 if (!base::DeleteFile(path, true)) { | 69 if (!base::DeleteFile(path, true)) { |
58 // Deleting a non-existent file is considered successful, so this will | 70 // Deleting a non-existent file is considered successful, so this will |
59 // trigger only in case of real errors. | 71 // trigger only in case of real errors. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // Delay the legacy dir removal to not impact startup performance. | 186 // Delay the legacy dir removal to not impact startup performance. |
175 BrowserThread::PostDelayedTask( | 187 BrowserThread::PostDelayedTask( |
176 BrowserThread::FILE, FROM_HERE, | 188 BrowserThread::FILE, FROM_HERE, |
177 base::Bind(&DeleteDirRecursively, fallback_cache_dir), | 189 base::Bind(&DeleteDirRecursively, fallback_cache_dir), |
178 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); | 190 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); |
179 } else { | 191 } else { |
180 cache_path = fallback_cache_dir; | 192 cache_path = fallback_cache_dir; |
181 LOG(WARNING) << "Failed to get cache directory for Android WebView. " | 193 LOG(WARNING) << "Failed to get cache directory for Android WebView. " |
182 << "Using app data directory as a fallback."; | 194 << "Using app data directory as a fallback."; |
183 } | 195 } |
| 196 |
| 197 browser_policy_connector_.reset(new AwBrowserPolicyConnector()); |
| 198 |
| 199 InitUserPrefService(); |
| 200 |
184 url_request_context_getter_ = new AwURLRequestContextGetter( | 201 url_request_context_getter_ = new AwURLRequestContextGetter( |
185 cache_path, cookie_store_.get(), CreateProxyConfigService()); | 202 cache_path, cookie_store_.get(), CreateProxyConfigService(), |
| 203 user_pref_service_.get()); |
186 | 204 |
187 data_reduction_proxy_io_data_.reset( | 205 data_reduction_proxy_io_data_.reset( |
188 new data_reduction_proxy::DataReductionProxyIOData( | 206 new data_reduction_proxy::DataReductionProxyIOData( |
189 data_reduction_proxy::Client::WEBVIEW_ANDROID, | 207 data_reduction_proxy::Client::WEBVIEW_ANDROID, |
190 data_reduction_proxy::DataReductionProxyParams::kAllowed, | 208 data_reduction_proxy::DataReductionProxyParams::kAllowed, |
191 url_request_context_getter_->GetNetLog(), | 209 url_request_context_getter_->GetNetLog(), |
192 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 210 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
193 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 211 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
194 false /* enable */, | 212 false /* enable */, |
195 false /* enable_quic */, | 213 false /* enable_quic */, |
(...skipping 17 matching lines...) Expand all Loading... |
213 data_reduction_proxy_io_data_->SetDataReductionProxyService( | 231 data_reduction_proxy_io_data_->SetDataReductionProxyService( |
214 data_reduction_proxy_service_->GetWeakPtr()); | 232 data_reduction_proxy_service_->GetWeakPtr()); |
215 | 233 |
216 visitedlink_master_.reset( | 234 visitedlink_master_.reset( |
217 new visitedlink::VisitedLinkMaster(this, this, false)); | 235 new visitedlink::VisitedLinkMaster(this, this, false)); |
218 visitedlink_master_->Init(); | 236 visitedlink_master_->Init(); |
219 | 237 |
220 form_database_service_.reset( | 238 form_database_service_.reset( |
221 new AwFormDatabaseService(context_storage_path_)); | 239 new AwFormDatabaseService(context_storage_path_)); |
222 | 240 |
223 browser_policy_connector_.reset(new AwBrowserPolicyConnector()); | |
224 | |
225 InitUserPrefService(); | |
226 | |
227 // Ensure the storage partition is initialized in time for DataReductionProxy. | 241 // Ensure the storage partition is initialized in time for DataReductionProxy. |
228 EnsureResourceContextInitialized(this); | 242 EnsureResourceContextInitialized(this); |
229 | 243 |
230 // TODO(dgn) lazy init, see http://crbug.com/521542 | 244 // TODO(dgn) lazy init, see http://crbug.com/521542 |
231 data_reduction_proxy_settings_->InitDataReductionProxySettings( | 245 data_reduction_proxy_settings_->InitDataReductionProxySettings( |
232 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), | 246 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), |
233 data_reduction_proxy_service_.Pass()); | 247 data_reduction_proxy_service_.Pass()); |
234 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); | 248 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); |
235 | 249 |
236 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); | 250 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 } | 305 } |
292 | 306 |
293 AwMessagePortService* AwBrowserContext::GetMessagePortService() { | 307 AwMessagePortService* AwBrowserContext::GetMessagePortService() { |
294 if (!message_port_service_.get()) { | 308 if (!message_port_service_.get()) { |
295 message_port_service_.reset( | 309 message_port_service_.reset( |
296 native_factory_->CreateAwMessagePortService()); | 310 native_factory_->CreateAwMessagePortService()); |
297 } | 311 } |
298 return message_port_service_.get(); | 312 return message_port_service_.get(); |
299 } | 313 } |
300 | 314 |
301 // Create user pref service for autofill functionality. | 315 // Create user pref service |
302 void AwBrowserContext::InitUserPrefService() { | 316 void AwBrowserContext::InitUserPrefService() { |
303 user_prefs::PrefRegistrySyncable* pref_registry = | 317 user_prefs::PrefRegistrySyncable* pref_registry = |
304 new user_prefs::PrefRegistrySyncable(); | 318 new user_prefs::PrefRegistrySyncable(); |
305 // We only use the autocomplete feature of the Autofill, which is | 319 // We only use the autocomplete feature of the Autofill, which is |
306 // controlled via the manager_delegate. We don't use the rest | 320 // controlled via the manager_delegate. We don't use the rest |
307 // of autofill, which is why it is hardcoded as disabled here. | 321 // of autofill, which is why it is hardcoded as disabled here. |
308 pref_registry->RegisterBooleanPref( | 322 pref_registry->RegisterBooleanPref( |
309 autofill::prefs::kAutofillEnabled, false); | 323 autofill::prefs::kAutofillEnabled, false); |
310 pref_registry->RegisterDoublePref( | 324 pref_registry->RegisterDoublePref( |
311 autofill::prefs::kAutofillPositiveUploadRate, 0.0); | 325 autofill::prefs::kAutofillPositiveUploadRate, 0.0); |
312 pref_registry->RegisterDoublePref( | 326 pref_registry->RegisterDoublePref( |
313 autofill::prefs::kAutofillNegativeUploadRate, 0.0); | 327 autofill::prefs::kAutofillNegativeUploadRate, 0.0); |
314 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); | 328 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); |
315 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 329 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
316 | 330 |
| 331 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
| 332 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 333 std::string()); |
| 334 |
317 base::PrefServiceFactory pref_service_factory; | 335 base::PrefServiceFactory pref_service_factory; |
318 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 336 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
319 pref_service_factory.set_managed_prefs( | 337 pref_service_factory.set_managed_prefs( |
320 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 338 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
321 browser_policy_connector_->GetPolicyService(), | 339 browser_policy_connector_->GetPolicyService(), |
322 browser_policy_connector_->GetHandlerList(), | 340 browser_policy_connector_->GetHandlerList(), |
323 policy::POLICY_LEVEL_MANDATORY))); | 341 policy::POLICY_LEVEL_MANDATORY))); |
324 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 342 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
325 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); | 343 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); |
326 | 344 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
441 return; | 459 return; |
442 // We don't care about commit_delay for now. It is just a dummy value. | 460 // We don't care about commit_delay for now. It is just a dummy value. |
443 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 461 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
444 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 462 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
445 user_pref_service_.get(), | 463 user_pref_service_.get(), |
446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 464 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
447 commit_delay); | 465 commit_delay); |
448 } | 466 } |
449 | 467 |
450 } // namespace android_webview | 468 } // namespace android_webview |
OLD | NEW |