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" |
11 #include "android_webview/browser/aw_quota_manager_bridge.h" | 11 #include "android_webview/browser/aw_quota_manager_bridge.h" |
12 #include "android_webview/browser/aw_resource_context.h" | 12 #include "android_webview/browser/aw_resource_context.h" |
13 #include "android_webview/browser/jni_dependency_factory.h" | 13 #include "android_webview/browser/jni_dependency_factory.h" |
14 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 14 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
15 #include "android_webview/browser/net/init_native_callback.h" | 15 #include "android_webview/browser/net/init_native_callback.h" |
16 #include "android_webview/common/aw_content_client.h" | 16 #include "android_webview/common/aw_content_client.h" |
17 #include "android_webview/common/pref_names.h" | |
17 #include "base/base_paths_android.h" | 18 #include "base/base_paths_android.h" |
18 #include "base/bind.h" | 19 #include "base/bind.h" |
19 #include "base/path_service.h" | 20 #include "base/path_service.h" |
20 #include "base/prefs/pref_service.h" | 21 #include "base/prefs/pref_service.h" |
21 #include "base/prefs/pref_service_factory.h" | 22 #include "base/prefs/pref_service_factory.h" |
22 #include "components/autofill/core/common/autofill_pref_names.h" | 23 #include "components/autofill/core/common/autofill_pref_names.h" |
23 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h" | 24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_comp ression_stats.h" |
24 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" | 25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_io_d ata.h" |
25 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" | 26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_pref s.h" |
26 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" | 27 #include "components/data_reduction_proxy/core/browser/data_reduction_proxy_serv ice.h" |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 // Delay the legacy dir removal to not impact startup performance. | 175 // Delay the legacy dir removal to not impact startup performance. |
175 BrowserThread::PostDelayedTask( | 176 BrowserThread::PostDelayedTask( |
176 BrowserThread::FILE, FROM_HERE, | 177 BrowserThread::FILE, FROM_HERE, |
177 base::Bind(&DeleteDirRecursively, fallback_cache_dir), | 178 base::Bind(&DeleteDirRecursively, fallback_cache_dir), |
178 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); | 179 base::TimeDelta::FromMilliseconds(legacy_cache_removal_delay_ms_)); |
179 } else { | 180 } else { |
180 cache_path = fallback_cache_dir; | 181 cache_path = fallback_cache_dir; |
181 LOG(WARNING) << "Failed to get cache directory for Android WebView. " | 182 LOG(WARNING) << "Failed to get cache directory for Android WebView. " |
182 << "Using app data directory as a fallback."; | 183 << "Using app data directory as a fallback."; |
183 } | 184 } |
185 | |
186 browser_policy_connector_.reset(new AwBrowserPolicyConnector()); | |
sgurun-gerrit only
2015/11/13 08:43:51
I see why InitUserPrefService had to move up but i
dgn
2015/11/13 12:37:07
It's used in InitUserPrefService(). See lines 328/
sgurun-gerrit only
2015/11/18 02:23:28
k
| |
187 | |
188 InitUserPrefService(); | |
189 | |
184 url_request_context_getter_ = new AwURLRequestContextGetter( | 190 url_request_context_getter_ = new AwURLRequestContextGetter( |
185 cache_path, cookie_store_.get(), CreateProxyConfigService()); | 191 cache_path, cookie_store_.get(), CreateProxyConfigService(), |
192 user_pref_service_.get()); | |
186 | 193 |
187 data_reduction_proxy_io_data_.reset( | 194 data_reduction_proxy_io_data_.reset( |
188 new data_reduction_proxy::DataReductionProxyIOData( | 195 new data_reduction_proxy::DataReductionProxyIOData( |
189 data_reduction_proxy::Client::WEBVIEW_ANDROID, | 196 data_reduction_proxy::Client::WEBVIEW_ANDROID, |
190 data_reduction_proxy::DataReductionProxyParams::kAllowed, | 197 data_reduction_proxy::DataReductionProxyParams::kAllowed, |
191 url_request_context_getter_->GetNetLog(), | 198 url_request_context_getter_->GetNetLog(), |
192 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), | 199 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO), |
193 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 200 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
194 false /* enable */, | 201 false /* enable */, |
195 false /* enable_quic */, | 202 false /* enable_quic */, |
(...skipping 17 matching lines...) Expand all Loading... | |
213 data_reduction_proxy_io_data_->SetDataReductionProxyService( | 220 data_reduction_proxy_io_data_->SetDataReductionProxyService( |
214 data_reduction_proxy_service_->GetWeakPtr()); | 221 data_reduction_proxy_service_->GetWeakPtr()); |
215 | 222 |
216 visitedlink_master_.reset( | 223 visitedlink_master_.reset( |
217 new visitedlink::VisitedLinkMaster(this, this, false)); | 224 new visitedlink::VisitedLinkMaster(this, this, false)); |
218 visitedlink_master_->Init(); | 225 visitedlink_master_->Init(); |
219 | 226 |
220 form_database_service_.reset( | 227 form_database_service_.reset( |
221 new AwFormDatabaseService(context_storage_path_)); | 228 new AwFormDatabaseService(context_storage_path_)); |
222 | 229 |
223 browser_policy_connector_.reset(new AwBrowserPolicyConnector()); | |
224 | |
225 InitUserPrefService(); | |
226 | |
227 // Ensure the storage partition is initialized in time for DataReductionProxy. | 230 // Ensure the storage partition is initialized in time for DataReductionProxy. |
228 EnsureResourceContextInitialized(this); | 231 EnsureResourceContextInitialized(this); |
229 | 232 |
230 // TODO(dgn) lazy init, see http://crbug.com/521542 | 233 // TODO(dgn) lazy init, see http://crbug.com/521542 |
231 data_reduction_proxy_settings_->InitDataReductionProxySettings( | 234 data_reduction_proxy_settings_->InitDataReductionProxySettings( |
232 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), | 235 user_pref_service_.get(), data_reduction_proxy_io_data_.get(), |
233 data_reduction_proxy_service_.Pass()); | 236 data_reduction_proxy_service_.Pass()); |
234 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); | 237 data_reduction_proxy_settings_->MaybeActivateDataReductionProxy(true); |
235 | 238 |
236 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); | 239 blacklist_manager_.reset(CreateURLBlackListManager(user_pref_service_.get())); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
291 } | 294 } |
292 | 295 |
293 AwMessagePortService* AwBrowserContext::GetMessagePortService() { | 296 AwMessagePortService* AwBrowserContext::GetMessagePortService() { |
294 if (!message_port_service_.get()) { | 297 if (!message_port_service_.get()) { |
295 message_port_service_.reset( | 298 message_port_service_.reset( |
296 native_factory_->CreateAwMessagePortService()); | 299 native_factory_->CreateAwMessagePortService()); |
297 } | 300 } |
298 return message_port_service_.get(); | 301 return message_port_service_.get(); |
299 } | 302 } |
300 | 303 |
301 // Create user pref service for autofill functionality. | 304 // Create user pref service |
sgurun-gerrit only
2015/11/13 08:43:51
nit: s/Create/Initialize/
dgn
2015/11/13 12:37:07
It's a null pointer before that. Isn't Create appr
sgurun-gerrit only
2015/11/18 02:23:28
no strong opinion. I guess actually you are right,
| |
302 void AwBrowserContext::InitUserPrefService() { | 305 void AwBrowserContext::InitUserPrefService() { |
303 user_prefs::PrefRegistrySyncable* pref_registry = | 306 user_prefs::PrefRegistrySyncable* pref_registry = |
304 new user_prefs::PrefRegistrySyncable(); | 307 new user_prefs::PrefRegistrySyncable(); |
305 // We only use the autocomplete feature of the Autofill, which is | 308 // We only use the autocomplete feature of the Autofill, which is |
306 // controlled via the manager_delegate. We don't use the rest | 309 // controlled via the manager_delegate. We don't use the rest |
307 // of autofill, which is why it is hardcoded as disabled here. | 310 // of autofill, which is why it is hardcoded as disabled here. |
308 pref_registry->RegisterBooleanPref( | 311 pref_registry->RegisterBooleanPref( |
309 autofill::prefs::kAutofillEnabled, false); | 312 autofill::prefs::kAutofillEnabled, false); |
310 pref_registry->RegisterDoublePref( | 313 pref_registry->RegisterDoublePref( |
311 autofill::prefs::kAutofillPositiveUploadRate, 0.0); | 314 autofill::prefs::kAutofillPositiveUploadRate, 0.0); |
312 pref_registry->RegisterDoublePref( | 315 pref_registry->RegisterDoublePref( |
313 autofill::prefs::kAutofillNegativeUploadRate, 0.0); | 316 autofill::prefs::kAutofillNegativeUploadRate, 0.0); |
314 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); | 317 data_reduction_proxy::RegisterSimpleProfilePrefs(pref_registry); |
315 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 318 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
316 | 319 |
320 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | |
321 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | |
322 std::string()); | |
323 | |
317 base::PrefServiceFactory pref_service_factory; | 324 base::PrefServiceFactory pref_service_factory; |
318 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); | 325 pref_service_factory.set_user_prefs(make_scoped_refptr(new AwPrefStore())); |
319 pref_service_factory.set_managed_prefs( | 326 pref_service_factory.set_managed_prefs( |
320 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 327 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
321 browser_policy_connector_->GetPolicyService(), | 328 browser_policy_connector_->GetPolicyService(), |
322 browser_policy_connector_->GetHandlerList(), | 329 browser_policy_connector_->GetHandlerList(), |
323 policy::POLICY_LEVEL_MANDATORY))); | 330 policy::POLICY_LEVEL_MANDATORY))); |
324 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 331 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
325 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); | 332 user_pref_service_ = pref_service_factory.Create(pref_registry).Pass(); |
326 | 333 |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 return; | 448 return; |
442 // We don't care about commit_delay for now. It is just a dummy value. | 449 // We don't care about commit_delay for now. It is just a dummy value. |
443 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); | 450 base::TimeDelta commit_delay = base::TimeDelta::FromMinutes(60); |
444 data_reduction_proxy_service->EnableCompressionStatisticsLogging( | 451 data_reduction_proxy_service->EnableCompressionStatisticsLogging( |
445 user_pref_service_.get(), | 452 user_pref_service_.get(), |
446 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), | 453 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI), |
447 commit_delay); | 454 commit_delay); |
448 } | 455 } |
449 | 456 |
450 } // namespace android_webview | 457 } // namespace android_webview |
OLD | NEW |