aw_browser_context.cc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570
  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
  3. // found in the LICENSE file.
  4. #include "android_webview/browser/aw_browser_context.h"
  5. #include <memory>
  6. #include <string>
  7. #include <utility>
  8. #include "android_webview/browser/aw_browser_process.h"
  9. #include "android_webview/browser/aw_content_browser_client.h"
  10. #include "android_webview/browser/aw_download_manager_delegate.h"
  11. #include "android_webview/browser/aw_form_database_service.h"
  12. #include "android_webview/browser/aw_permission_manager.h"
  13. #include "android_webview/browser/aw_quota_manager_bridge.h"
  14. #include "android_webview/browser/aw_resource_context.h"
  15. #include "android_webview/browser/aw_web_ui_controller_factory.h"
  16. #include "android_webview/browser/cookie_manager.h"
  17. #include "android_webview/browser/metrics/aw_metrics_service_client.h"
  18. #include "android_webview/browser/network_service/net_helpers.h"
  19. #include "android_webview/browser/safe_browsing/aw_safe_browsing_allowlist_manager.h"
  20. #include "android_webview/browser_jni_headers/AwBrowserContext_jni.h"
  21. #include "android_webview/common/aw_features.h"
  22. #include "android_webview/common/aw_switches.h"
  23. #include "android_webview/common/crash_reporter/crash_keys.h"
  24. #include "base/base_paths_posix.h"
  25. #include "base/bind.h"
  26. #include "base/command_line.h"
  27. #include "base/feature_list.h"
  28. #include "base/files/file_util.h"
  29. #include "base/path_service.h"
  30. #include "base/task/single_thread_task_runner.h"
  31. #include "components/autofill/core/browser/autocomplete_history_manager.h"
  32. #include "components/autofill/core/common/autofill_prefs.h"
  33. #include "components/cdm/browser/media_drm_storage_impl.h"
  34. #include "components/crash/core/common/crash_key.h"
  35. #include "components/download/public/common/in_progress_download_manager.h"
  36. #include "components/keyed_service/core/simple_key_map.h"
  37. #include "components/policy/core/browser/browser_policy_connector_base.h"
  38. #include "components/policy/core/browser/configuration_policy_pref_store.h"
  39. #include "components/policy/core/browser/url_blocklist_manager.h"
  40. #include "components/pref_registry/pref_registry_syncable.h"
  41. #include "components/prefs/in_memory_pref_store.h"
  42. #include "components/prefs/json_pref_store.h"
  43. #include "components/prefs/pref_registry_simple.h"
  44. #include "components/prefs/pref_service.h"
  45. #include "components/prefs/pref_service_factory.h"
  46. #include "components/prefs/segregated_pref_store.h"
  47. #include "components/profile_metrics/browser_profile_type.h"
  48. #include "components/safe_browsing/core/common/safe_browsing_prefs.h"
  49. #include "components/url_formatter/url_fixer.h"
  50. #include "components/user_prefs/user_prefs.h"
  51. #include "components/visitedlink/browser/visitedlink_writer.h"
  52. #include "content/public/browser/browser_task_traits.h"
  53. #include "content/public/browser/browser_thread.h"
  54. #include "content/public/browser/download_request_utils.h"
  55. #include "content/public/browser/ssl_host_state_delegate.h"
  56. #include "content/public/browser/storage_partition.h"
  57. #include "content/public/browser/web_contents.h"
  58. #include "content/public/browser/zoom_level_delegate.h"
  59. #include "media/mojo/buildflags.h"
  60. #include "net/http/http_util.h"
  61. #include "net/proxy_resolution/proxy_config_service_android.h"
  62. #include "net/proxy_resolution/proxy_resolution_service.h"
  63. #include "services/cert_verifier/public/mojom/cert_verifier_service_factory.mojom.h"
  64. #include "services/network/public/mojom/network_context.mojom.h"
  65. using base::FilePath;
  66. using content::BrowserThread;
  67. namespace android_webview {
  68. namespace {
  69. const void* const kDownloadManagerDelegateKey = &kDownloadManagerDelegateKey;
  70. AwBrowserContext* g_browser_context = NULL;
  71. crash_reporter::CrashKeyString<1> g_web_view_compat_crash_key(
  72. crash_keys::kWeblayerWebViewCompatMode);
  73. // Empty method to skip origin security check as DownloadManager will set its
  74. // own method.
  75. bool IgnoreOriginSecurityCheck(const GURL& url) {
  76. return true;
  77. }
  78. void MigrateProfileData(base::FilePath cache_path,
  79. base::FilePath context_storage_path) {
  80. TRACE_EVENT0("startup", "MigrateProfileData");
  81. FilePath old_cache_path;
  82. base::PathService::Get(base::DIR_CACHE, &old_cache_path);
  83. old_cache_path = old_cache_path.DirName().Append(
  84. FILE_PATH_LITERAL("org.chromium.android_webview"));
  85. if (base::PathExists(old_cache_path)) {
  86. bool success = base::CreateDirectory(cache_path);
  87. if (success)
  88. success &= base::Move(old_cache_path, cache_path);
  89. DCHECK(success);
  90. }
  91. base::FilePath old_context_storage_path;
  92. base::PathService::Get(base::DIR_ANDROID_APP_DATA, &old_context_storage_path);
  93. if (!base::PathExists(context_storage_path)) {
  94. base::CreateDirectory(context_storage_path);
  95. }
  96. auto migrate_context_storage_data = [&old_context_storage_path,
  97. &context_storage_path](auto& suffix) {
  98. FilePath old_file = old_context_storage_path.Append(suffix);
  99. if (base::PathExists(old_file)) {
  100. FilePath new_file = context_storage_path.Append(suffix);
  101. if (base::PathExists(new_file)) {
  102. bool success =
  103. base::Move(new_file, new_file.AddExtension(".partial-migration"));
  104. DCHECK(success);
  105. }
  106. bool success = base::Move(old_file, new_file);
  107. DCHECK(success);
  108. }
  109. };
  110. // These were handled in the initial migration
  111. migrate_context_storage_data("Web Data");
  112. migrate_context_storage_data("Web Data-journal");
  113. migrate_context_storage_data("GPUCache");
  114. migrate_context_storage_data("blob_storage");
  115. migrate_context_storage_data("Session Storage");
  116. // These were missed in the initial migration
  117. migrate_context_storage_data("File System");
  118. migrate_context_storage_data("IndexedDB");
  119. migrate_context_storage_data("Local Storage");
  120. migrate_context_storage_data("QuotaManager");
  121. migrate_context_storage_data("QuotaManager-journal");
  122. migrate_context_storage_data("Service Worker");
  123. migrate_context_storage_data("VideoDecodeStats");
  124. migrate_context_storage_data("databases");
  125. migrate_context_storage_data("shared_proto_db");
  126. migrate_context_storage_data("webrtc_event_logs");
  127. }
  128. } // namespace
  129. AwBrowserContext::AwBrowserContext()
  130. : context_storage_path_(GetContextStoragePath()),
  131. simple_factory_key_(GetPath(), IsOffTheRecord()) {
  132. DCHECK(!g_browser_context);
  133. TRACE_EVENT0("startup", "AwBrowserContext::AwBrowserContext");
  134. profile_metrics::SetBrowserProfileType(
  135. this, profile_metrics::BrowserProfileType::kRegular);
  136. g_web_view_compat_crash_key.Set("0");
  137. if (IsDefaultBrowserContext()) {
  138. MigrateProfileData(GetCacheDir(), GetContextStoragePath());
  139. }
  140. g_browser_context = this;
  141. SimpleKeyMap::GetInstance()->Associate(this, &simple_factory_key_);
  142. CreateUserPrefService();
  143. visitedlink_writer_ =
  144. std::make_unique<visitedlink::VisitedLinkWriter>(this, this, false);
  145. visitedlink_writer_->Init();
  146. form_database_service_ =
  147. std::make_unique<AwFormDatabaseService>(context_storage_path_);
  148. EnsureResourceContextInitialized();
  149. // This constructor is entered during the creation of ContentBrowserClient,
  150. // before browser threads are created. Therefore any checks to enforce
  151. // threading (such as BrowserThread::CurrentlyOn()) will fail here.
  152. }
  153. AwBrowserContext::~AwBrowserContext() {
  154. DCHECK_EQ(this, g_browser_context);
  155. NotifyWillBeDestroyed();
  156. SimpleKeyMap::GetInstance()->Dissociate(this);
  157. ShutdownStoragePartitions();
  158. g_browser_context = NULL;
  159. }
  160. // static
  161. AwBrowserContext* AwBrowserContext::GetDefault() {
  162. // TODO(joth): rather than store in a global here, lookup this instance
  163. // from the Java-side peer.
  164. return g_browser_context;
  165. }
  166. // static
  167. AwBrowserContext* AwBrowserContext::FromWebContents(
  168. content::WebContents* web_contents) {
  169. // This is safe; this is the only implementation of the browser context.
  170. return static_cast<AwBrowserContext*>(web_contents->GetBrowserContext());
  171. }
  172. base::FilePath AwBrowserContext::GetCacheDir() {
  173. FilePath cache_path;
  174. if (!base::PathService::Get(base::DIR_CACHE, &cache_path)) {
  175. NOTREACHED() << "Failed to get app cache directory for Android WebView";
  176. }
  177. cache_path = cache_path.Append(FILE_PATH_LITERAL("Default"))
  178. .Append(FILE_PATH_LITERAL("HTTP Cache"));
  179. return cache_path;
  180. }
  181. base::FilePath AwBrowserContext::GetPrefStorePath() {
  182. FilePath pref_store_path;
  183. base::PathService::Get(base::DIR_ANDROID_APP_DATA, &pref_store_path);
  184. // TODO(amalova): Assign a proper file path for non-default profiles
  185. // when we support multiple profiles
  186. pref_store_path =
  187. pref_store_path.Append(FILE_PATH_LITERAL("Default/Preferences"));
  188. return pref_store_path;
  189. }
  190. base::FilePath AwBrowserContext::GetCookieStorePath() {
  191. return GetCookieManager()->GetCookieStorePath();
  192. }
  193. // static
  194. base::FilePath AwBrowserContext::GetContextStoragePath() {
  195. base::FilePath user_data_dir;
  196. if (!base::PathService::Get(base::DIR_ANDROID_APP_DATA, &user_data_dir)) {
  197. NOTREACHED() << "Failed to get app data directory for Android WebView";
  198. }
  199. user_data_dir = user_data_dir.Append(FILE_PATH_LITERAL("Default"));
  200. return user_data_dir;
  201. }
  202. // static
  203. void AwBrowserContext::RegisterPrefs(PrefRegistrySimple* registry) {
  204. safe_browsing::RegisterProfilePrefs(registry);
  205. // Register the Autocomplete Data Retention Policy pref.
  206. // The default value '0' represents the latest Chrome major version on which
  207. // the retention policy ran. By setting it to a low default value, we're
  208. // making sure it runs now (as it only runs once per major version).
  209. registry->RegisterIntegerPref(
  210. autofill::prefs::kAutocompleteLastVersionRetentionPolicy, 0);
  211. // We only use the autocomplete feature of Autofill, which is controlled via
  212. // the manager_delegate. We don't use the rest of Autofill, which is why it is
  213. // hardcoded as disabled here.
  214. // TODO(crbug.com/873740): The following also disables autocomplete.
  215. // Investigate what the intended behavior is.
  216. registry->RegisterBooleanPref(autofill::prefs::kAutofillProfileEnabled,
  217. false);
  218. registry->RegisterBooleanPref(autofill::prefs::kAutofillCreditCardEnabled,
  219. false);
  220. #if BUILDFLAG(ENABLE_MOJO_CDM)
  221. cdm::MediaDrmStorageImpl::RegisterProfilePrefs(registry);
  222. #endif
  223. }
  224. void AwBrowserContext::CreateUserPrefService() {
  225. TRACE_EVENT0("startup", "AwBrowserContext::CreateUserPrefService");
  226. auto pref_registry = base::MakeRefCounted<user_prefs::PrefRegistrySyncable>();
  227. RegisterPrefs(pref_registry.get());
  228. PrefServiceFactory pref_service_factory;
  229. std::set<std::string> persistent_prefs;
  230. // Persisted to avoid having to provision MediaDrm every time the
  231. // application tries to play protected content after restart.
  232. persistent_prefs.insert(cdm::prefs::kMediaDrmStorage);
  233. pref_service_factory.set_user_prefs(base::MakeRefCounted<SegregatedPrefStore>(
  234. base::MakeRefCounted<InMemoryPrefStore>(),
  235. base::MakeRefCounted<JsonPrefStore>(GetPrefStorePath()),
  236. std::move(persistent_prefs)));
  237. policy::URLBlocklistManager::RegisterProfilePrefs(pref_registry.get());
  238. AwBrowserPolicyConnector* browser_policy_connector =
  239. AwBrowserProcess::GetInstance()->browser_policy_connector();
  240. pref_service_factory.set_managed_prefs(
  241. base::MakeRefCounted<policy::ConfigurationPolicyPrefStore>(
  242. browser_policy_connector,
  243. browser_policy_connector->GetPolicyService(),
  244. browser_policy_connector->GetHandlerList(),
  245. policy::POLICY_LEVEL_MANDATORY));
  246. user_pref_service_ = pref_service_factory.Create(pref_registry);
  247. if (IsDefaultBrowserContext()) {
  248. MigrateLocalStatePrefs();
  249. }
  250. user_prefs::UserPrefs::Set(this, user_pref_service_.get());
  251. }
  252. void AwBrowserContext::MigrateLocalStatePrefs() {
  253. PrefService* local_state = AwBrowserProcess::GetInstance()->local_state();
  254. if (!local_state->HasPrefPath(cdm::prefs::kMediaDrmStorage)) {
  255. return;
  256. }
  257. user_pref_service_->Set(cdm::prefs::kMediaDrmStorage,
  258. local_state->GetValue(cdm::prefs::kMediaDrmStorage));
  259. local_state->ClearPref(cdm::prefs::kMediaDrmStorage);
  260. }
  261. // static
  262. std::vector<std::string> AwBrowserContext::GetAuthSchemes() {
  263. // In Chrome this is configurable via the AuthSchemes policy. For WebView
  264. // there is no interest to have it available so far.
  265. std::vector<std::string> supported_schemes = {"basic", "digest", "ntlm",
  266. "negotiate"};
  267. return supported_schemes;
  268. }
  269. void AwBrowserContext::AddVisitedURLs(const std::vector<GURL>& urls) {
  270. DCHECK(visitedlink_writer_);
  271. visitedlink_writer_->AddURLs(urls);
  272. }
  273. AwQuotaManagerBridge* AwBrowserContext::GetQuotaManagerBridge() {
  274. if (!quota_manager_bridge_.get()) {
  275. quota_manager_bridge_ = AwQuotaManagerBridge::Create(this);
  276. }
  277. return quota_manager_bridge_.get();
  278. }
  279. void AwBrowserContext::SetWebLayerRunningInSameProcess(JNIEnv* env) {
  280. g_web_view_compat_crash_key.Set("1");
  281. }
  282. AwFormDatabaseService* AwBrowserContext::GetFormDatabaseService() {
  283. return form_database_service_.get();
  284. }
  285. autofill::AutocompleteHistoryManager*
  286. AwBrowserContext::GetAutocompleteHistoryManager() {
  287. if (!autocomplete_history_manager_) {
  288. autocomplete_history_manager_ =
  289. std::make_unique<autofill::AutocompleteHistoryManager>();
  290. autocomplete_history_manager_->Init(
  291. form_database_service_->get_autofill_webdata_service(),
  292. user_pref_service_.get(), IsOffTheRecord());
  293. }
  294. return autocomplete_history_manager_.get();
  295. }
  296. CookieManager* AwBrowserContext::GetCookieManager() {
  297. // TODO(amalova): create cookie manager for non-default profile
  298. return CookieManager::GetInstance();
  299. }
  300. base::FilePath AwBrowserContext::GetPath() {
  301. return context_storage_path_;
  302. }
  303. bool AwBrowserContext::IsOffTheRecord() {
  304. // Android WebView does not support off the record profile yet.
  305. return false;
  306. }
  307. content::ResourceContext* AwBrowserContext::GetResourceContext() {
  308. if (!resource_context_) {
  309. resource_context_ = std::make_unique<AwResourceContext>();
  310. }
  311. return resource_context_.get();
  312. }
  313. content::DownloadManagerDelegate*
  314. AwBrowserContext::GetDownloadManagerDelegate() {
  315. if (!GetUserData(kDownloadManagerDelegateKey)) {
  316. SetUserData(kDownloadManagerDelegateKey,
  317. std::make_unique<AwDownloadManagerDelegate>());
  318. }
  319. return static_cast<AwDownloadManagerDelegate*>(
  320. GetUserData(kDownloadManagerDelegateKey));
  321. }
  322. content::BrowserPluginGuestManager* AwBrowserContext::GetGuestManager() {
  323. return NULL;
  324. }
  325. storage::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() {
  326. // Intentionally returning NULL as 'Extensions' and 'Apps' not supported.
  327. return NULL;
  328. }
  329. content::PlatformNotificationService*
  330. AwBrowserContext::GetPlatformNotificationService() {
  331. return nullptr;
  332. }
  333. content::PushMessagingService* AwBrowserContext::GetPushMessagingService() {
  334. // TODO(johnme): Support push messaging in WebView.
  335. return NULL;
  336. }
  337. content::StorageNotificationService*
  338. AwBrowserContext::GetStorageNotificationService() {
  339. return nullptr;
  340. }
  341. content::SSLHostStateDelegate* AwBrowserContext::GetSSLHostStateDelegate() {
  342. if (!ssl_host_state_delegate_.get()) {
  343. ssl_host_state_delegate_ = std::make_unique<AwSSLHostStateDelegate>();
  344. }
  345. return ssl_host_state_delegate_.get();
  346. }
  347. content::PermissionControllerDelegate*
  348. AwBrowserContext::GetPermissionControllerDelegate() {
  349. if (!permission_manager_.get())
  350. permission_manager_ = std::make_unique<AwPermissionManager>();
  351. return permission_manager_.get();
  352. }
  353. content::ClientHintsControllerDelegate*
  354. AwBrowserContext::GetClientHintsControllerDelegate() {
  355. return nullptr;
  356. }
  357. content::BackgroundFetchDelegate*
  358. AwBrowserContext::GetBackgroundFetchDelegate() {
  359. return nullptr;
  360. }
  361. content::BackgroundSyncController*
  362. AwBrowserContext::GetBackgroundSyncController() {
  363. return nullptr;
  364. }
  365. content::BrowsingDataRemoverDelegate*
  366. AwBrowserContext::GetBrowsingDataRemoverDelegate() {
  367. return nullptr;
  368. }
  369. content::ReduceAcceptLanguageControllerDelegate*
  370. AwBrowserContext::GetReduceAcceptLanguageControllerDelegate() {
  371. return nullptr;
  372. }
  373. download::InProgressDownloadManager*
  374. AwBrowserContext::RetriveInProgressDownloadManager() {
  375. return new download::InProgressDownloadManager(
  376. nullptr, base::FilePath(), nullptr,
  377. base::BindRepeating(&IgnoreOriginSecurityCheck),
  378. base::BindRepeating(&content::DownloadRequestUtils::IsURLSafe),
  379. /*wake_lock_provider_binder*/ base::NullCallback());
  380. }
  381. std::unique_ptr<content::ZoomLevelDelegate>
  382. AwBrowserContext::CreateZoomLevelDelegate(
  383. const base::FilePath& partition_path) {
  384. return nullptr;
  385. }
  386. void AwBrowserContext::RebuildTable(
  387. const scoped_refptr<URLEnumerator>& enumerator) {
  388. // Android WebView rebuilds from WebChromeClient.getVisitedHistory. The client
  389. // can change in the lifetime of this WebView and may not yet be set here.
  390. // Therefore this initialization path is not used.
  391. enumerator->OnComplete(true);
  392. }
  393. void AwBrowserContext::SetExtendedReportingAllowed(bool allowed) {
  394. user_pref_service_->SetBoolean(
  395. ::prefs::kSafeBrowsingExtendedReportingOptInAllowed, allowed);
  396. }
  397. // TODO(amalova): Make sure NetworkContextParams is configured correctly when
  398. // off-the-record
  399. void AwBrowserContext::ConfigureNetworkContextParams(
  400. bool in_memory,
  401. const base::FilePath& relative_partition_path,
  402. network::mojom::NetworkContextParams* context_params,
  403. cert_verifier::mojom::CertVerifierCreationParams*
  404. cert_verifier_creation_params) {
  405. context_params->user_agent = android_webview::GetUserAgent();
  406. // TODO(ntfschr): set this value to a proper value based on the user's
  407. // preferred locales (http://crbug.com/898555). For now, set this to
  408. // "en-US,en" instead of "en-us,en", since Android guarantees region codes
  409. // will be uppercase.
  410. context_params->accept_language =
  411. net::HttpUtil::GenerateAcceptLanguageHeader("en-US,en");
  412. // HTTP cache
  413. context_params->http_cache_enabled = true;
  414. context_params->http_cache_max_size = GetHttpCacheSize();
  415. context_params->http_cache_directory = GetCacheDir();
  416. // WebView should persist and restore cookies between app sessions (including
  417. // session cookies).
  418. context_params->file_paths = network::mojom::NetworkContextFilePaths::New();
  419. base::FilePath cookie_path = AwBrowserContext::GetCookieStorePath();
  420. context_params->file_paths->data_directory = cookie_path.DirName();
  421. context_params->file_paths->cookie_database_name = cookie_path.BaseName();
  422. context_params->restore_old_session_cookies = true;
  423. context_params->persist_session_cookies = true;
  424. context_params->cookie_manager_params =
  425. network::mojom::CookieManagerParams::New();
  426. context_params->cookie_manager_params->allow_file_scheme_cookies =
  427. GetCookieManager()->GetAllowFileSchemeCookies();
  428. context_params->cookie_manager_params->cookie_access_delegate_type =
  429. base::CommandLine::ForCurrentProcess()->HasSwitch(
  430. switches::kWebViewEnableModernCookieSameSite)
  431. ? network::mojom::CookieAccessDelegateType::ALWAYS_NONLEGACY
  432. : network::mojom::CookieAccessDelegateType::ALWAYS_LEGACY;
  433. context_params->initial_ssl_config = network::mojom::SSLConfig::New();
  434. // Allow SHA-1 to be used for locally-installed trust anchors, as WebView
  435. // should behave like the Android system would.
  436. context_params->initial_ssl_config->sha1_local_anchors_enabled = true;
  437. // Do not enforce the Legacy Symantec PKI policies outlined in
  438. // https://security.googleblog.com/2017/09/chromes-plan-to-distrust-symantec.html,
  439. // defer to the Android system.
  440. context_params->initial_ssl_config->symantec_enforcement_disabled = true;
  441. // Do not enforce Legacy TLS removal if support is still enabled.
  442. if (base::FeatureList::IsEnabled(
  443. android_webview::features::kWebViewLegacyTlsSupport)) {
  444. context_params->initial_ssl_config->version_min =
  445. network::mojom::SSLVersion::kTLS1;
  446. }
  447. // WebView does not currently support Certificate Transparency
  448. // (http://crbug.com/921750).
  449. context_params->enforce_chrome_ct_policy = false;
  450. context_params->enable_brotli = base::FeatureList::IsEnabled(
  451. android_webview::features::kWebViewBrotliSupport);
  452. context_params->check_clear_text_permitted =
  453. AwContentBrowserClient::get_check_cleartext_permitted();
  454. // Add proxy settings
  455. AwProxyConfigMonitor::GetInstance()->AddProxyToNetworkContextParams(
  456. context_params);
  457. }
  458. base::android::ScopedJavaLocalRef<jobject> JNI_AwBrowserContext_GetDefaultJava(
  459. JNIEnv* env) {
  460. return g_browser_context->GetJavaBrowserContext();
  461. }
  462. base::android::ScopedJavaLocalRef<jobject>
  463. AwBrowserContext::GetJavaBrowserContext() {
  464. if (!obj_) {
  465. JNIEnv* env = base::android::AttachCurrentThread();
  466. obj_ = Java_AwBrowserContext_create(env, reinterpret_cast<intptr_t>(this),
  467. IsDefaultBrowserContext());
  468. }
  469. return base::android::ScopedJavaLocalRef<jobject>(obj_);
  470. }
  471. jlong AwBrowserContext::GetQuotaManagerBridge(JNIEnv* env) {
  472. return reinterpret_cast<intptr_t>(GetQuotaManagerBridge());
  473. }
  474. } // namespace android_webview