WebViewChromiumFactoryProvider.java revision a6f2939f98aeaf67533a7fd3f5c999f207451f1c
146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)/* 246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * Copyright (C) 2012 The Android Open Source Project 346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * 446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * Licensed under the Apache License, Version 2.0 (the "License"); 546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * you may not use this file except in compliance with the License. 646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * You may obtain a copy of the License at 746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * 846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * http://www.apache.org/licenses/LICENSE-2.0 946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * 1046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * Unless required by applicable law or agreed to in writing, software 1146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * distributed under the License is distributed on an "AS IS" BASIS, 1246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * See the License for the specific language governing permissions and 1446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) * limitations under the License. 1546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) */ 1646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 1746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)package com.android.webview.chromium; 1846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 1946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.app.ActivityThread; 2046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.content.Context; 21009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsenimport android.content.SharedPreferences; 22970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixonimport android.os.Build; 2346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.os.Looper; 2446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.CookieManager; 2546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.GeolocationPermissions; 2646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebIconDatabase; 2746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebStorage; 2846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebView; 2946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebViewDatabase; 3046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebViewFactoryProvider; 3146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import android.webkit.WebViewProvider; 3246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 33aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsenimport org.chromium.android_webview.AwBrowserContext; 34f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixonimport org.chromium.android_webview.AwBrowserProcess; 35a2b0d0b4d6d1ff22fbb1329e358e1cc0a112aab3Jonathan Dixonimport org.chromium.android_webview.AwContents; 36d5f17bbd8703a56ac084a64b1ce2f673f67bd72dKristian Monsenimport org.chromium.android_webview.AwCookieManager; 3709e718bac5900c84b8402b774d306dca7f7fdf09Selim Gurunimport org.chromium.android_webview.AwFormDatabase; 38009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsenimport org.chromium.android_webview.AwGeolocationPermissions; 395d20093562806fbce9cc0d3eb4a411ed6c5ce1c0Bo Liuimport org.chromium.android_webview.AwQuotaManagerBridge; 40d6b56ff89338d0b3a6ba0cb413b1fe559d6284e0Mikhail Naganovimport org.chromium.android_webview.AwSettings; 4146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import org.chromium.base.PathService; 427b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixonimport org.chromium.base.ThreadUtils; 437b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixonimport org.chromium.content.app.LibraryLoader; 4446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import org.chromium.content.browser.ContentViewStatics; 4546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)import org.chromium.content.browser.ResourceExtractor; 46970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixonimport org.chromium.content.common.CommandLine; 47970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixonimport org.chromium.content.common.ProcessInitException; 4846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 4946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)public class WebViewChromiumFactoryProvider implements WebViewFactoryProvider { 5046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 5146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) private final Object mLock = new Object(); 5246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 53009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsen private static final String CHROMIUM_PREFS_NAME = "WebViewChromiumPrefs"; 547962d3fa1b66ed25aba03a2d48f6c47528d7d95cPrimiano Tucci private static final String COMMAND_LINE_FILE = "/data/local/tmp/webview-command-line"; 55009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsen 5646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) // Initialization guarded by mLock. 57aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen private AwBrowserContext mBrowserContext; 58aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private Statics mStaticMethods; 59aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private GeolocationPermissionsAdapter mGeolocationPermissions; 60aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private CookieManagerAdapter mCookieManager; 61aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private WebIconDatabaseAdapter mWebIconDatabase; 62aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private WebStorageAdapter mWebStorage; 63aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon private WebViewDatabaseAdapter mWebViewDatabase; 6446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 659aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // Read/write protected by mLock. 669aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon private boolean mStarted; 67f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon 6811f7c1b02e49a6a8eaec26111f08edec45feb01aTorne (Richard Coles) public WebViewChromiumFactoryProvider() { 69f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon // Load chromium library. 70f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon AwBrowserProcess.loadLibrary(); 71a2b0d0b4d6d1ff22fbb1329e358e1cc0a112aab3Jonathan Dixon // Load glue-layer support library. 72a2b0d0b4d6d1ff22fbb1329e358e1cc0a112aab3Jonathan Dixon System.loadLibrary("webviewchromium_plat_support"); 73f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon } 74f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon 75f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon private void initPlatSupportLibrary() { 769aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon DrawGLFunctor.setChromiumAwDrawGLFunction(AwContents.getAwDrawGLFunction()); 779aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon AwContents.setAwDrawSWFunctionTable(GraphicsUtils.getDrawSWFunctionTable()); 78c5cde8c18df853e11d1ec528508fd0fe2e742d5cKaan Baloglu AwContents.setAwDrawGLFunctionTable(GraphicsUtils.getDrawGLFunctionTable()); 79a2b0d0b4d6d1ff22fbb1329e358e1cc0a112aab3Jonathan Dixon } 80a2b0d0b4d6d1ff22fbb1329e358e1cc0a112aab3Jonathan Dixon 81f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon private void ensureChromiumStartedLocked() { 8246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) assert Thread.holdsLock(mLock); 8346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 849aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon if (mStarted) { 859aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon return; 869aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon } 873053d8bc3be48b0cbc6f33e1975c03a10ac303a5Jonathan Dixon 889aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // We must post to the UI thread to cover the case that the user 899aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // has invoked Chromium startup by using the (thread-safe) 909aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // CookieManager rather than creating a WebView. 917b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon ThreadUtils.runOnUiThreadBlocking(new Runnable() { 927b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon @Override 937b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon public void run() { 947962d3fa1b66ed25aba03a2d48f6c47528d7d95cPrimiano Tucci if (Build.IS_DEBUGGABLE) { 957962d3fa1b66ed25aba03a2d48f6c47528d7d95cPrimiano Tucci CommandLine.initFromFile(COMMAND_LINE_FILE); 9649ff1a6656a115852ee45955985f791429e23527Primiano Tucci } else { 9749ff1a6656a115852ee45955985f791429e23527Primiano Tucci CommandLine.init(null); 98970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon } 99970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon 100970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon // TODO: currently in a relase build the DCHECKs only log. We either need to insall 101970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon // a report handler with SetLogReportHandler to make them assert, or else compile 102970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon // them out of the build altogether (b/8284203). Either way, so long they're 103970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon // compiled in, we may as unconditionally enable them here. 104970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon CommandLine.getInstance().appendSwitch("enable-dcheck"); 105970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon 1069aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // We don't need to extract any paks because for WebView, they are 1079aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // in the system image. 1089aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon ResourceExtractor.setMandatoryPaksToExtract(""); 1099aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon 110979b73ce2c37f98f70f482489b3977876ea2e6faKristian Monsen try { 111979b73ce2c37f98f70f482489b3977876ea2e6faKristian Monsen LibraryLoader.ensureInitialized(); 112970a2065df4f96ceaa9bc38d82caea9221dfa4c9Jonathan Dixon } catch(ProcessInitException e) { 113c3716ed7c818292fad946647afe3a230cc743fcbBen Murdoch throw new RuntimeException("Error initializing WebView library", e); 114979b73ce2c37f98f70f482489b3977876ea2e6faKristian Monsen } 1157b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon 1167b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon PathService.override(PathService.DIR_MODULE, "/system/lib/"); 1177b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon // TODO: DIR_RESOURCE_PAKS_ANDROID needs to live somewhere sensible, 1187b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon // inlined here for simplicity setting up the HTMLViewer demo. Unfortunately 1197b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon // it can't go into base.PathService, as the native constant it refers to 1207b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon // lives in the ui/ layer. See ui/base/ui_base_paths.h 1217b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon final int DIR_RESOURCE_PAKS_ANDROID = 3003; 1227b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon PathService.override(DIR_RESOURCE_PAKS_ANDROID, 1237b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon "/system/framework/webview/paks"); 1247b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon 125f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon AwBrowserProcess.start(ActivityThread.currentApplication()); 126f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon initPlatSupportLibrary(); 1277b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon } 1287b77b2fb0f7148bc31e23cabadb234231699ff93Jonathan Dixon }); 1299aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon mStarted = true; 13046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 13146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 13246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 13346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public Statics getStatics() { 13446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) synchronized (mLock) { 13546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) if (mStaticMethods == null) { 1369aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon // TODO: Optimization potential: most these methods only need the native library 137f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon // loaded and initialized, not the entire browser process started. 138f3e3e4e6b6c5798f435c1d14379edeb479e3b25dJonathan Dixon // See also http://b/7009882 1399aa44b4e29be9f4b271edb3f4d438d806d4cc176Jonathan Dixon ensureChromiumStartedLocked(); 14046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) mStaticMethods = new WebViewFactoryProvider.Statics() { 14146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 14246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public String findAddress(String addr) { 14346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) return ContentViewStatics.findAddress(addr); 14446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 14546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 14646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 14746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public void setPlatformNotificationsEnabled(boolean enable) { 14846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) // noop 14946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 15046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 151f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon @Override 15246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public String getDefaultUserAgent(Context context) { 153d6b56ff89338d0b3a6ba0cb413b1fe559d6284e0Mikhail Naganov return AwSettings.getDefaultUserAgent(); 15446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 15546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) }; 15646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 15746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 15846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) return mStaticMethods; 15946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 16046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 16146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 16246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess) { 16346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) assert Looper.myLooper() == Looper.getMainLooper(); 164aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen AwBrowserContext browserContext; 16546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) synchronized (mLock) { 166f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 16746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) ResourceProvider.registerResources(webView.getContext()); 168aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen browserContext = getBrowserContextLocked(); 16946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 1708166110add693878f19ab0551c630a22caa2e30cKristian Monsen // Make sure GeolocationPermissions is created before creating a webview 1718166110add693878f19ab0551c630a22caa2e30cKristian Monsen getGeolocationPermissions(); 172aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen return new WebViewChromium(webView, privateAccess, browserContext); 17346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 17446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 17546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 17646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public GeolocationPermissions getGeolocationPermissions() { 177009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsen synchronized (mLock) { 178aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon if (mGeolocationPermissions == null) { 179f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 18050a184c1e058bc62f659fb80e09e7507ef13d6c9Jonathan Dixon mGeolocationPermissions = new GeolocationPermissionsAdapter( 181aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen getBrowserContextLocked().getGeolocationPermissions()); 182009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsen } 183009ed27511c4606dcd16b352489b2d3f70b4b513Kristian Monsen } 184ff2704e614eb490baea0acb5c8ab22e061033694Kristian Monsen return mGeolocationPermissions; 18546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 18646f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 187aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen private AwBrowserContext getBrowserContextLocked() { 188aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen assert Thread.holdsLock(mLock); 189aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen assert mStarted; 190aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen if (mBrowserContext == null) { 191aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen mBrowserContext = new AwBrowserContext( 192aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen ActivityThread.currentApplication().getSharedPreferences( 193aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen CHROMIUM_PREFS_NAME, Context.MODE_PRIVATE)); 194aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen } 195aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen return mBrowserContext; 196aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen } 197aa8b39f3e3f208586f3750d7278f1239a09ebd32Kristian Monsen 19846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 19946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public CookieManager getCookieManager() { 20046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) synchronized (mLock) { 201aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon if (mCookieManager == null) { 202f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 203d5f17bbd8703a56ac084a64b1ce2f673f67bd72dKristian Monsen mCookieManager = new CookieManagerAdapter(new AwCookieManager()); 20446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 20546f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 206aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon return mCookieManager; 20746f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 20846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 20946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 21046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public WebIconDatabase getWebIconDatabase() { 211aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon synchronized (mLock) { 212aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon if (mWebIconDatabase == null) { 213f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 214aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon mWebIconDatabase = new WebIconDatabaseAdapter(); 215aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon } 216aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon } 217aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon return mWebIconDatabase; 21846f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 21946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 22046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 22146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public WebStorage getWebStorage() { 222aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon synchronized (mLock) { 223aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon if (mWebStorage == null) { 224f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 2255d20093562806fbce9cc0d3eb4a411ed6c5ce1c0Bo Liu mWebStorage = new WebStorageAdapter(AwQuotaManagerBridge.getInstance()); 226aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon } 227aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon } 228aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon return mWebStorage; 22946f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 23046f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) 23146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) @Override 23246f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) public WebViewDatabase getWebViewDatabase(Context context) { 23346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) synchronized (mLock) { 234aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon if (mWebViewDatabase == null) { 235f0f355514e4420755c15491fe3b21a2eeaa42654Jonathan Dixon ensureChromiumStartedLocked(); 236a6f2939f98aeaf67533a7fd3f5c999f207451f1cSelim Gurun AwBrowserContext browserContext = getBrowserContextLocked(); 237a6f2939f98aeaf67533a7fd3f5c999f207451f1cSelim Gurun mWebViewDatabase = new WebViewDatabaseAdapter( 238a6f2939f98aeaf67533a7fd3f5c999f207451f1cSelim Gurun browserContext.getFormDatabase(), 239a6f2939f98aeaf67533a7fd3f5c999f207451f1cSelim Gurun browserContext.getHttpAuthDatabase(context)); 240aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon } 24146f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 242aadb04e4198e1f0dce390e9434cb189603b8e713Jonathan Dixon return mWebViewDatabase; 24346f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles) } 24446f104289826e85ba76a1a2139d7ecc7daca07b1Torne (Richard Coles)} 245