Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: android_webview/glue/java/src/com/android/webview/chromium/WebViewChromiumFactoryProvider.java

Issue 1659363003: [Android WebView] Implement support for Network Information API and enable it. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove logging Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 package com.android.webview.chromium; 5 package com.android.webview.chromium;
6 6
7 import android.Manifest;
7 import android.app.ActivityManager; 8 import android.app.ActivityManager;
8 import android.content.ComponentCallbacks2; 9 import android.content.ComponentCallbacks2;
9 import android.content.Context; 10 import android.content.Context;
10 import android.content.Intent; 11 import android.content.Intent;
11 import android.content.SharedPreferences; 12 import android.content.SharedPreferences;
12 import android.content.pm.PackageInfo; 13 import android.content.pm.PackageInfo;
14 import android.content.pm.PackageManager;
13 import android.net.Uri; 15 import android.net.Uri;
14 import android.os.Build; 16 import android.os.Build;
15 import android.os.Looper; 17 import android.os.Looper;
18 import android.os.Process;
16 import android.os.StrictMode; 19 import android.os.StrictMode;
17 import android.util.Log; 20 import android.util.Log;
18 import android.webkit.CookieManager; 21 import android.webkit.CookieManager;
19 import android.webkit.GeolocationPermissions; 22 import android.webkit.GeolocationPermissions;
20 import android.webkit.WebStorage; 23 import android.webkit.WebStorage;
21 import android.webkit.WebView; 24 import android.webkit.WebView;
22 import android.webkit.WebViewDatabase; 25 import android.webkit.WebViewDatabase;
23 import android.webkit.WebViewFactory; 26 import android.webkit.WebViewFactory;
24 import android.webkit.WebViewFactoryProvider; 27 import android.webkit.WebViewFactoryProvider;
25 import android.webkit.WebViewProvider; 28 import android.webkit.WebViewProvider;
26 29
27 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate; 30 import com.android.webview.chromium.WebViewDelegateFactory.WebViewDelegate;
28 31
29 import org.chromium.android_webview.AwBrowserContext; 32 import org.chromium.android_webview.AwBrowserContext;
30 import org.chromium.android_webview.AwBrowserProcess; 33 import org.chromium.android_webview.AwBrowserProcess;
31 import org.chromium.android_webview.AwContents; 34 import org.chromium.android_webview.AwContents;
32 import org.chromium.android_webview.AwContentsClient; 35 import org.chromium.android_webview.AwContentsClient;
33 import org.chromium.android_webview.AwContentsStatics; 36 import org.chromium.android_webview.AwContentsStatics;
34 import org.chromium.android_webview.AwCookieManager; 37 import org.chromium.android_webview.AwCookieManager;
35 import org.chromium.android_webview.AwDataReductionProxyManager; 38 import org.chromium.android_webview.AwDataReductionProxyManager;
36 import org.chromium.android_webview.AwDevToolsServer; 39 import org.chromium.android_webview.AwDevToolsServer;
40 import org.chromium.android_webview.AwNetworkChangeNotifierRegistrationPolicy;
37 import org.chromium.android_webview.AwQuotaManagerBridge; 41 import org.chromium.android_webview.AwQuotaManagerBridge;
38 import org.chromium.android_webview.AwResource; 42 import org.chromium.android_webview.AwResource;
39 import org.chromium.android_webview.AwSettings; 43 import org.chromium.android_webview.AwSettings;
40 import org.chromium.android_webview.R; 44 import org.chromium.android_webview.R;
41 import org.chromium.base.CommandLine; 45 import org.chromium.base.CommandLine;
42 import org.chromium.base.ContextUtils; 46 import org.chromium.base.ContextUtils;
43 import org.chromium.base.MemoryPressureListener; 47 import org.chromium.base.MemoryPressureListener;
44 import org.chromium.base.PathService; 48 import org.chromium.base.PathService;
45 import org.chromium.base.PathUtils; 49 import org.chromium.base.PathUtils;
46 import org.chromium.base.ThreadUtils; 50 import org.chromium.base.ThreadUtils;
47 import org.chromium.base.TraceEvent; 51 import org.chromium.base.TraceEvent;
48 import org.chromium.base.annotations.SuppressFBWarnings; 52 import org.chromium.base.annotations.SuppressFBWarnings;
49 import org.chromium.base.library_loader.LibraryLoader; 53 import org.chromium.base.library_loader.LibraryLoader;
50 import org.chromium.base.library_loader.LibraryProcessType; 54 import org.chromium.base.library_loader.LibraryProcessType;
51 import org.chromium.base.library_loader.ProcessInitException; 55 import org.chromium.base.library_loader.ProcessInitException;
52 import org.chromium.content.browser.ContentViewStatics; 56 import org.chromium.content.browser.ContentViewStatics;
57 import org.chromium.net.NetworkChangeNotifier;
53 import org.chromium.ui.base.ResourceBundle; 58 import org.chromium.ui.base.ResourceBundle;
54 59
55 import java.io.File; 60 import java.io.File;
56 import java.lang.ref.WeakReference; 61 import java.lang.ref.WeakReference;
57 import java.util.ArrayList; 62 import java.util.ArrayList;
58 63
59 /** 64 /**
60 * Entry point to the WebView. The system framework talks to this class to get i nstances of the 65 * Entry point to the WebView. The system framework talks to this class to get i nstances of the
61 * implementation classes. 66 * implementation classes.
62 */ 67 */
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 169 }
165 } 170 }
166 } 171 }
167 172
168 private void initPlatSupportLibrary() { 173 private void initPlatSupportLibrary() {
169 DrawGLFunctor.setChromiumAwDrawGLFunction(AwContents.getAwDrawGLFunction ()); 174 DrawGLFunctor.setChromiumAwDrawGLFunction(AwContents.getAwDrawGLFunction ());
170 AwContents.setAwDrawSWFunctionTable(GraphicsUtils.getDrawSWFunctionTable ()); 175 AwContents.setAwDrawSWFunctionTable(GraphicsUtils.getDrawSWFunctionTable ());
171 AwContents.setAwDrawGLFunctionTable(GraphicsUtils.getDrawGLFunctionTable ()); 176 AwContents.setAwDrawGLFunctionTable(GraphicsUtils.getDrawGLFunctionTable ());
172 } 177 }
173 178
179 private void initNetworkChangeNotifier(Context applicationContext) {
180 if (applicationContext.checkPermission(Manifest.permission.ACCESS_NETWOR K_STATE,
181 Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_G RANTED) {
182 NetworkChangeNotifier.init(applicationContext);
183 NetworkChangeNotifier.setAutoDetectConnectivityState(
184 new AwNetworkChangeNotifierRegistrationPolicy());
185 }
186 }
187
174 private void ensureChromiumStartedLocked(boolean onMainThread) { 188 private void ensureChromiumStartedLocked(boolean onMainThread) {
175 assert Thread.holdsLock(mLock); 189 assert Thread.holdsLock(mLock);
176 190
177 if (mStarted) { // Early-out for the common case. 191 if (mStarted) { // Early-out for the common case.
178 return; 192 return;
179 } 193 }
180 194
181 Looper looper = !onMainThread ? Looper.myLooper() : Looper.getMainLooper (); 195 Looper looper = !onMainThread ? Looper.myLooper() : Looper.getMainLooper ();
182 Log.v(TAG, "Binding Chromium to " 196 Log.v(TAG, "Binding Chromium to "
183 + (Looper.getMainLooper().equals(looper) ? "main" : "bac kground") 197 + (Looper.getMainLooper().equals(looper) ? "main" : "bac kground")
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 } 248 }
235 249
236 PathService.override(PathService.DIR_MODULE, "/system/lib/"); 250 PathService.override(PathService.DIR_MODULE, "/system/lib/");
237 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks"); 251 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks");
238 252
239 // Make sure that ResourceProvider is initialized before starting the br owser process. 253 // Make sure that ResourceProvider is initialized before starting the br owser process.
240 final String webViewPackageName = WebViewFactory.getLoadedPackageInfo(). packageName; 254 final String webViewPackageName = WebViewFactory.getLoadedPackageInfo(). packageName;
241 setUpResources(webViewPackageName, context); 255 setUpResources(webViewPackageName, context);
242 ResourceBundle.initializeLocalePaks(context, R.array.locale_paks); 256 ResourceBundle.initializeLocalePaks(context, R.array.locale_paks);
243 initPlatSupportLibrary(); 257 initPlatSupportLibrary();
258 initNetworkChangeNotifier(context);
244 final int extraBindFlags = 0; 259 final int extraBindFlags = 0;
245 AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, extra BindFlags); 260 AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, extra BindFlags);
246 AwBrowserProcess.start(context); 261 AwBrowserProcess.start(context);
247 262
248 if (isBuildDebuggable()) { 263 if (isBuildDebuggable()) {
249 setWebContentsDebuggingEnabled(true); 264 setWebContentsDebuggingEnabled(true);
250 } 265 }
251 266
252 TraceEvent.setATraceEnabled(mWebViewDelegate.isTraceTagEnabled()); 267 TraceEvent.setATraceEnabled(mWebViewDelegate.isTraceTagEnabled());
253 mWebViewDelegate.setOnTraceEnabledChangeListener( 268 mWebViewDelegate.setOnTraceEnabledChangeListener(
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 browserContext.getHttpAuthDatabase(context)); 472 browserContext.getHttpAuthDatabase(context));
458 } 473 }
459 } 474 }
460 return mWebViewDatabase; 475 return mWebViewDatabase;
461 } 476 }
462 477
463 WebViewDelegate getWebViewDelegate() { 478 WebViewDelegate getWebViewDelegate() {
464 return mWebViewDelegate; 479 return mWebViewDelegate;
465 } 480 }
466 } 481 }
OLDNEW
« no previous file with comments | « android_webview/glue/glue.gni ('k') | android_webview/java/src/org/chromium/android_webview/AwContents.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698