| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "android_webview/browser/aw_browser_policy_connector.h" | 9 #include "android_webview/browser/aw_browser_policy_connector.h" |
| 10 #include "android_webview/browser/aw_form_database_service.h" | 10 #include "android_webview/browser/aw_form_database_service.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 namespace prefs { | 45 namespace prefs { |
| 46 | 46 |
| 47 // String that specifies the Android account type to use for Negotiate | 47 // String that specifies the Android account type to use for Negotiate |
| 48 // authentication. | 48 // authentication. |
| 49 const char kAuthAndroidNegotiateAccountType[] = | 49 const char kAuthAndroidNegotiateAccountType[] = |
| 50 "auth.android_negotiate_account_type"; | 50 "auth.android_negotiate_account_type"; |
| 51 | 51 |
| 52 // Whitelist containing servers for which Integrated Authentication is enabled. | 52 // Whitelist containing servers for which Integrated Authentication is enabled. |
| 53 const char kAuthServerWhitelist[] = "auth.server_whitelist"; | 53 const char kAuthServerWhitelist[] = "auth.server_whitelist"; |
| 54 | 54 |
| 55 const char kWebRestrictionsAuthority[] = "web_restrictions_authority"; |
| 56 |
| 55 } // namespace prefs | 57 } // namespace prefs |
| 56 | 58 |
| 57 namespace { | 59 namespace { |
| 58 | 60 |
| 59 // Shows notifications which correspond to PersistentPrefStore's reading errors. | 61 // Shows notifications which correspond to PersistentPrefStore's reading errors. |
| 60 void HandleReadError(PersistentPrefStore::PrefReadError error) { | 62 void HandleReadError(PersistentPrefStore::PrefReadError error) { |
| 61 } | 63 } |
| 62 | 64 |
| 63 void DeleteDirRecursively(const base::FilePath& path) { | 65 void DeleteDirRecursively(const base::FilePath& path) { |
| 64 if (!base::DeleteFile(path, true)) { | 66 if (!base::DeleteFile(path, true)) { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 // anonymously identify logs. Every WebView-using app on every device | 195 // anonymously identify logs. Every WebView-using app on every device |
| 194 // is given a GUID, stored in this file in the app's data directory. | 196 // is given a GUID, stored in this file in the app's data directory. |
| 195 const FilePath guid_file_path = | 197 const FilePath guid_file_path = |
| 196 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); | 198 GetPath().Append(FILE_PATH_LITERAL("metrics_guid")); |
| 197 | 199 |
| 198 AwMetricsServiceClient::GetInstance()->Initialize( | 200 AwMetricsServiceClient::GetInstance()->Initialize( |
| 199 user_pref_service_.get(), | 201 user_pref_service_.get(), |
| 200 content::BrowserContext::GetDefaultStoragePartition(this)-> | 202 content::BrowserContext::GetDefaultStoragePartition(this)-> |
| 201 GetURLRequestContext(), | 203 GetURLRequestContext(), |
| 202 guid_file_path); | 204 guid_file_path); |
| 205 web_restriction_provider_.reset( |
| 206 new web_restrictions::WebRestrictionsClient()); |
| 207 pref_change_registrar_.Add( |
| 208 prefs::kWebRestrictionsAuthority, |
| 209 base::Bind(&AwBrowserContext::OnWebRestrictionsAuthorityChanged, |
| 210 base::Unretained(this))); |
| 211 web_restriction_provider_->SetAuthority( |
| 212 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
| 213 } |
| 214 |
| 215 void AwBrowserContext::OnWebRestrictionsAuthorityChanged() { |
| 216 web_restriction_provider_->SetAuthority( |
| 217 user_pref_service_->GetString(prefs::kWebRestrictionsAuthority)); |
| 203 } | 218 } |
| 204 | 219 |
| 205 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { | 220 void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) { |
| 206 DCHECK(visitedlink_master_); | 221 DCHECK(visitedlink_master_); |
| 207 visitedlink_master_->AddURLs(urls); | 222 visitedlink_master_->AddURLs(urls); |
| 208 } | 223 } |
| 209 | 224 |
| 210 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { | 225 AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() { |
| 211 if (!quota_manager_bridge_.get()) { | 226 if (!quota_manager_bridge_.get()) { |
| 212 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); | 227 quota_manager_bridge_ = native_factory_->CreateAwQuotaManagerBridge(this); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 236 new user_prefs::PrefRegistrySyncable(); | 251 new user_prefs::PrefRegistrySyncable(); |
| 237 // We only use the autocomplete feature of Autofill, which is controlled via | 252 // We only use the autocomplete feature of Autofill, which is controlled via |
| 238 // the manager_delegate. We don't use the rest of Autofill, which is why it is | 253 // the manager_delegate. We don't use the rest of Autofill, which is why it is |
| 239 // hardcoded as disabled here. | 254 // hardcoded as disabled here. |
| 240 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); | 255 pref_registry->RegisterBooleanPref(autofill::prefs::kAutofillEnabled, false); |
| 241 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); | 256 policy::URLBlacklistManager::RegisterProfilePrefs(pref_registry); |
| 242 | 257 |
| 243 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | 258 pref_registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); |
| 244 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 259 pref_registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 245 std::string()); | 260 std::string()); |
| 261 pref_registry->RegisterStringPref(prefs::kWebRestrictionsAuthority, |
| 262 std::string()); |
| 246 | 263 |
| 247 metrics::MetricsService::RegisterPrefs(pref_registry); | 264 metrics::MetricsService::RegisterPrefs(pref_registry); |
| 248 | 265 |
| 249 PrefServiceFactory pref_service_factory; | 266 PrefServiceFactory pref_service_factory; |
| 250 pref_service_factory.set_user_prefs(make_scoped_refptr( | 267 pref_service_factory.set_user_prefs(make_scoped_refptr( |
| 251 new InMemoryPrefStore())); | 268 new InMemoryPrefStore())); |
| 252 pref_service_factory.set_managed_prefs( | 269 pref_service_factory.set_managed_prefs( |
| 253 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( | 270 make_scoped_refptr(new policy::ConfigurationPolicyPrefStore( |
| 254 browser_policy_connector_->GetPolicyService(), | 271 browser_policy_connector_->GetPolicyService(), |
| 255 browser_policy_connector_->GetHandlerList(), | 272 browser_policy_connector_->GetHandlerList(), |
| 256 policy::POLICY_LEVEL_MANDATORY))); | 273 policy::POLICY_LEVEL_MANDATORY))); |
| 257 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); | 274 pref_service_factory.set_read_error_callback(base::Bind(&HandleReadError)); |
| 258 user_pref_service_ = pref_service_factory.Create(pref_registry); | 275 user_pref_service_ = pref_service_factory.Create(pref_registry); |
| 276 pref_change_registrar_.Init(user_pref_service_.get()); |
| 259 | 277 |
| 260 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); | 278 user_prefs::UserPrefs::Set(this, user_pref_service_.get()); |
| 261 } | 279 } |
| 262 | 280 |
| 263 std::unique_ptr<content::ZoomLevelDelegate> | 281 std::unique_ptr<content::ZoomLevelDelegate> |
| 264 AwBrowserContext::CreateZoomLevelDelegate( | 282 AwBrowserContext::CreateZoomLevelDelegate( |
| 265 const base::FilePath& partition_path) { | 283 const base::FilePath& partition_path) { |
| 266 return nullptr; | 284 return nullptr; |
| 267 } | 285 } |
| 268 | 286 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 return NULL; | 374 return NULL; |
| 357 } | 375 } |
| 358 | 376 |
| 359 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { | 377 policy::URLBlacklistManager* AwBrowserContext::GetURLBlacklistManager() { |
| 360 // Should not be called until the end of PreMainMessageLoopRun, where | 378 // Should not be called until the end of PreMainMessageLoopRun, where |
| 361 // blacklist_manager_ is initialized. | 379 // blacklist_manager_ is initialized. |
| 362 DCHECK(blacklist_manager_); | 380 DCHECK(blacklist_manager_); |
| 363 return blacklist_manager_.get(); | 381 return blacklist_manager_.get(); |
| 364 } | 382 } |
| 365 | 383 |
| 384 web_restrictions::WebRestrictionsClient* |
| 385 AwBrowserContext::GetWebRestrictionProvider() { |
| 386 DCHECK(web_restriction_provider_); |
| 387 return web_restriction_provider_.get(); |
| 388 } |
| 389 |
| 366 void AwBrowserContext::RebuildTable( | 390 void AwBrowserContext::RebuildTable( |
| 367 const scoped_refptr<URLEnumerator>& enumerator) { | 391 const scoped_refptr<URLEnumerator>& enumerator) { |
| 368 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client | 392 // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client |
| 369 // can change in the lifetime of this WebView and may not yet be set here. | 393 // can change in the lifetime of this WebView and may not yet be set here. |
| 370 // Therefore this initialization path is not used. | 394 // Therefore this initialization path is not used. |
| 371 enumerator->OnComplete(true); | 395 enumerator->OnComplete(true); |
| 372 } | 396 } |
| 373 | 397 |
| 374 } // namespace android_webview | 398 } // namespace android_webview |
| OLD | NEW |