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/aw_resource_context.h" | 10 #include "android_webview/browser/aw_resource_context.h" |
11 #include "android_webview/browser/jni_dependency_factory.h" | 11 #include "android_webview/browser/jni_dependency_factory.h" |
12 #include "android_webview/browser/net/aw_url_request_context_getter.h" | 12 #include "android_webview/browser/net/aw_url_request_context_getter.h" |
13 #include "android_webview/browser/net/init_native_callback.h" | 13 #include "android_webview/browser/net/init_native_callback.h" |
| 14 #include "base/bind.h" |
14 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
15 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
16 #include "base/prefs/pref_service_factory.h" | 17 #include "base/prefs/pref_service_factory.h" |
17 #include "components/autofill/core/common/autofill_pref_names.h" | 18 #include "components/autofill/core/common/autofill_pref_names.h" |
18 #include "components/data_reduction_proxy/browser/data_reduction_proxy_auth_requ
est_handler.h" | |
19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se
rvice.h" | 19 #include "components/data_reduction_proxy/browser/data_reduction_proxy_config_se
rvice.h" |
20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" | 20 #include "components/data_reduction_proxy/browser/data_reduction_proxy_params.h" |
21 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" | 21 #include "components/data_reduction_proxy/browser/data_reduction_proxy_prefs.h" |
22 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" | 22 #include "components/data_reduction_proxy/browser/data_reduction_proxy_settings.
h" |
23 #include "components/user_prefs/user_prefs.h" | 23 #include "components/user_prefs/user_prefs.h" |
24 #include "components/visitedlink/browser/visitedlink_master.h" | 24 #include "components/visitedlink/browser/visitedlink_master.h" |
25 #include "content/public/browser/browser_thread.h" | 25 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/ssl_host_state_delegate.h" | 26 #include "content/public/browser/ssl_host_state_delegate.h" |
27 #include "content/public/browser/storage_partition.h" | 27 #include "content/public/browser/storage_partition.h" |
28 #include "content/public/browser/web_contents.h" | 28 #include "content/public/browser/web_contents.h" |
29 #include "net/cookies/cookie_store.h" | 29 #include "net/cookies/cookie_store.h" |
| 30 #include "net/proxy/proxy_service.h" |
30 | 31 |
31 using base::FilePath; | 32 using base::FilePath; |
32 using content::BrowserThread; | 33 using content::BrowserThread; |
33 using data_reduction_proxy::DataReductionProxyAuthRequestHandler; | 34 using data_reduction_proxy::DataReductionProxyConfigService; |
34 using data_reduction_proxy::DataReductionProxySettings; | 35 using data_reduction_proxy::DataReductionProxySettings; |
35 | 36 |
36 namespace android_webview { | 37 namespace android_webview { |
37 | 38 |
38 namespace { | 39 namespace { |
39 | 40 |
40 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 41 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
41 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 42 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
42 } | 43 } |
43 | 44 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); | 97 proxy_settings->SetDataReductionProxyEnabled(data_reduction_proxy_enabled_); |
97 } | 98 } |
98 | 99 |
99 void AwBrowserContext::PreMainMessageLoopRun() { | 100 void AwBrowserContext::PreMainMessageLoopRun() { |
100 cookie_store_ = CreateCookieStore(this); | 101 cookie_store_ = CreateCookieStore(this); |
101 #if defined(SPDY_PROXY_AUTH_ORIGIN) | 102 #if defined(SPDY_PROXY_AUTH_ORIGIN) |
102 data_reduction_proxy_settings_.reset( | 103 data_reduction_proxy_settings_.reset( |
103 new DataReductionProxySettings( | 104 new DataReductionProxySettings( |
104 new data_reduction_proxy::DataReductionProxyParams( | 105 new data_reduction_proxy::DataReductionProxyParams( |
105 data_reduction_proxy::DataReductionProxyParams::kAllowed))); | 106 data_reduction_proxy::DataReductionProxyParams::kAllowed))); |
106 data_reduction_proxy_auth_request_handler_.reset( | |
107 new DataReductionProxyAuthRequestHandler( | |
108 data_reduction_proxy::kClientAndroidWebview, | |
109 data_reduction_proxy::kAndroidWebViewProtocolVersion, | |
110 data_reduction_proxy_settings_->params())); | |
111 #endif | 107 #endif |
112 | 108 scoped_ptr<DataReductionProxyConfigService> |
113 url_request_context_getter_ = | 109 data_reduction_proxy_config_service( |
114 new AwURLRequestContextGetter(GetPath(), cookie_store_.get()); | 110 new DataReductionProxyConfigService( |
115 | 111 scoped_ptr<net::ProxyConfigService>( |
116 if (data_reduction_proxy_settings_.get()) { | 112 net::ProxyService::CreateSystemProxyConfigService( |
| 113 BrowserThread::GetMessageLoopProxyForThread( |
| 114 BrowserThread::IO), |
| 115 NULL /* Ignored on Android */)).Pass())); |
| 116 if (data_reduction_proxy_settings_.get()) { |
117 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> | 117 scoped_ptr<data_reduction_proxy::DataReductionProxyConfigurator> |
118 configurator(new data_reduction_proxy::DataReductionProxyConfigTracker( | 118 configurator(new data_reduction_proxy::DataReductionProxyConfigTracker( |
119 url_request_context_getter_->proxy_config_service(), | 119 base::Bind(&DataReductionProxyConfigService::UpdateProxyConfig, |
| 120 base::Unretained( |
| 121 data_reduction_proxy_config_service.get())), |
120 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 122 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
121 data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass()); | 123 data_reduction_proxy_settings_->SetProxyConfigurator(configurator.Pass()); |
122 } | 124 } |
| 125 |
| 126 url_request_context_getter_ = |
| 127 new AwURLRequestContextGetter(GetPath(), |
| 128 cookie_store_.get(), |
| 129 data_reduction_proxy_config_service.Pass()); |
| 130 |
123 visitedlink_master_.reset( | 131 visitedlink_master_.reset( |
124 new visitedlink::VisitedLinkMaster(this, this, false)); | 132 new visitedlink::VisitedLinkMaster(this, this, false)); |
125 visitedlink_master_->Init(); | 133 visitedlink_master_->Init(); |
126 | 134 |
127 form_database_service_.reset( | 135 form_database_service_.reset( |
128 new AwFormDatabaseService(context_storage_path_)); | 136 new AwFormDatabaseService(context_storage_path_)); |
129 } | 137 } |
130 | 138 |
131 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 139 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
132 DCHECK(visitedlink_master_); | 140 DCHECK(visitedlink_master_); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 } | 173 } |
166 | 174 |
167 AwFormDatabaseService* AwBrowserContext::GetFormDatabaseService() { | 175 AwFormDatabaseService* AwBrowserContext::GetFormDatabaseService() { |
168 return form_database_service_.get(); | 176 return form_database_service_.get(); |
169 } | 177 } |
170 | 178 |
171 DataReductionProxySettings* AwBrowserContext::GetDataReductionProxySettings() { | 179 DataReductionProxySettings* AwBrowserContext::GetDataReductionProxySettings() { |
172 return data_reduction_proxy_settings_.get(); | 180 return data_reduction_proxy_settings_.get(); |
173 } | 181 } |
174 | 182 |
175 DataReductionProxyAuthRequestHandler* | |
176 AwBrowserContext::GetDataReductionProxyAuthRequestHandler() { | |
177 return data_reduction_proxy_auth_request_handler_.get(); | |
178 } | |
179 | |
180 // Create user pref service for autofill functionality. | 183 // Create user pref service for autofill functionality. |
181 void AwBrowserContext::CreateUserPrefServiceIfNecessary() { | 184 void AwBrowserContext::CreateUserPrefServiceIfNecessary() { |
182 if (user_pref_service_) | 185 if (user_pref_service_) |
183 return; | 186 return; |
184 | 187 |
185 PrefRegistrySimple* pref_registry = new PrefRegistrySimple(); | 188 PrefRegistrySimple* pref_registry = new PrefRegistrySimple(); |
186 // We only use the autocomplete feature of the Autofill, which is | 189 // We only use the autocomplete feature of the Autofill, which is |
187 // controlled via the manager_delegate. We don't use the rest | 190 // controlled via the manager_delegate. We don't use the rest |
188 // of autofill, which is why it is hardcoded as disabled here. | 191 // of autofill, which is why it is hardcoded as disabled here. |
189 pref_registry->RegisterBooleanPref( | 192 pref_registry->RegisterBooleanPref( |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 | 286 |
284 void AwBrowserContext::RebuildTable( | 287 void AwBrowserContext::RebuildTable( |
285 const scoped_refptr<URLEnumerator>& enumerator) { | 288 const scoped_refptr<URLEnumerator>& enumerator) { |
286 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 289 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
287 // can change in the lifetime of this WebView and may not yet be set here. | 290 // can change in the lifetime of this WebView and may not yet be set here. |
288 // Therefore this initialization path is not used. | 291 // Therefore this initialization path is not used. |
289 enumerator->OnComplete(true); | 292 enumerator->OnComplete(true); |
290 } | 293 } |
291 | 294 |
292 } // namespace android_webview | 295 } // namespace android_webview |
OLD | NEW |