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

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

Issue 2787963003: WebView: Refactor PlatformServiceBridge.getInstance (Closed)
Patch Set: hoist getOrCreateInstance call and simplify tests Created 3 years, 8 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.Manifest;
8 import android.app.ActivityManager; 8 import android.app.ActivityManager;
9 import android.content.ComponentCallbacks2; 9 import android.content.ComponentCallbacks2;
10 import android.content.Context; 10 import android.content.Context;
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 395
396 try { 396 try {
397 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali zed(); 397 LibraryLoader.get(LibraryProcessType.PROCESS_WEBVIEW).ensureInitiali zed();
398 } catch (ProcessInitException e) { 398 } catch (ProcessInitException e) {
399 throw new RuntimeException("Error initializing WebView library", e); 399 throw new RuntimeException("Error initializing WebView library", e);
400 } 400 }
401 401
402 PathService.override(PathService.DIR_MODULE, "/system/lib/"); 402 PathService.override(PathService.DIR_MODULE, "/system/lib/");
403 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks"); 403 PathService.override(DIR_RESOURCE_PAKS_ANDROID, "/system/framework/webvi ew/paks");
404 404
405 final Context context = ContextUtils.getApplicationContext();
406 // Future calls to PlatformServiceBridge.getInstance() rely on it having been created here.
407 PlatformServiceBridge.getOrCreateInstance(context);
408
405 // Make sure that ResourceProvider is initialized before starting the br owser process. 409 // Make sure that ResourceProvider is initialized before starting the br owser process.
406 final PackageInfo webViewPackageInfo = WebViewFactory.getLoadedPackageIn fo(); 410 final PackageInfo webViewPackageInfo = WebViewFactory.getLoadedPackageIn fo();
407 final String webViewPackageName = webViewPackageInfo.packageName; 411 final String webViewPackageName = webViewPackageInfo.packageName;
408 final Context context = ContextUtils.getApplicationContext();
409 setUpResources(webViewPackageInfo, context); 412 setUpResources(webViewPackageInfo, context);
410 initPlatSupportLibrary(); 413 initPlatSupportLibrary();
411 doNetworkInitializations(context); 414 doNetworkInitializations(context);
412 final boolean isExternalService = true; 415 final boolean isExternalService = true;
413 AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, isExt ernalService); 416 AwBrowserProcess.configureChildProcessLauncher(webViewPackageName, isExt ernalService);
414 AwBrowserProcess.start(); 417 AwBrowserProcess.start();
415 418
416 final boolean enableMinidumpUploadingForTesting = CommandLine.getInstanc e().hasSwitch( 419 final boolean enableMinidumpUploadingForTesting = CommandLine.getInstanc e().hasSwitch(
417 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH); 420 CommandLineUtil.CRASH_UPLOADS_ENABLED_FOR_TESTING_SWITCH);
418 if (enableMinidumpUploadingForTesting) { 421 if (enableMinidumpUploadingForTesting) {
419 AwBrowserProcess.handleMinidumps(webViewPackageName, true /* enabled */); 422 AwBrowserProcess.handleMinidumps(webViewPackageName, true /* enabled */);
420 } 423 }
421 424
422 // Actions conditioned on whether the Android Checkbox is toggled on 425 // Future calls to PlatformServiceBridge.getInstance() rely on it having been created here.
gsennton 2017/04/05 15:21:13 This comment doesn't fit here anymore?
paulmiller 2017/04/05 17:02:39 Done.
423 PlatformServiceBridge.getInstance(context) 426 PlatformServiceBridge.getInstance().queryMetricsSetting(new ValueCallbac k<Boolean>() {
424 .queryMetricsSetting(new ValueCallback<Boolean>() { 427 // Actions conditioned on whether the Android Checkbox is toggled on
425 public void onReceiveValue(Boolean enabled) { 428 public void onReceiveValue(Boolean enabled) {
426 ThreadUtils.assertOnUiThread(); 429 ThreadUtils.assertOnUiThread();
427 AwMetricsServiceClient.setConsentSetting(context, enable d); 430 AwMetricsServiceClient.setConsentSetting(context, enabled);
428 431
429 if (!enableMinidumpUploadingForTesting) { 432 if (!enableMinidumpUploadingForTesting) {
430 AwBrowserProcess.handleMinidumps(webViewPackageName, enabled); 433 AwBrowserProcess.handleMinidumps(webViewPackageName, enabled );
431 } 434 }
432 } 435 }
433 }); 436 });
434 437
435 if (CommandLineUtil.isBuildDebuggable()) { 438 if (CommandLineUtil.isBuildDebuggable()) {
436 setWebContentsDebuggingEnabled(true); 439 setWebContentsDebuggingEnabled(true);
437 } 440 }
438 441
439 TraceEvent.setATraceEnabled(mWebViewDelegate.isTraceTagEnabled()); 442 TraceEvent.setATraceEnabled(mWebViewDelegate.isTraceTagEnabled());
440 mWebViewDelegate.setOnTraceEnabledChangeListener( 443 mWebViewDelegate.setOnTraceEnabledChangeListener(
441 new WebViewDelegate.OnTraceEnabledChangeListener() { 444 new WebViewDelegate.OnTraceEnabledChangeListener() {
442 @Override 445 @Override
443 public void onTraceEnabledChange(boolean enabled) { 446 public void onTraceEnabledChange(boolean enabled) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 WebViewDelegate getWebViewDelegate() { 694 WebViewDelegate getWebViewDelegate() {
692 return mWebViewDelegate; 695 return mWebViewDelegate;
693 } 696 }
694 697
695 // The method to support unreleased Android. 698 // The method to support unreleased Android.
696 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV iew, 699 WebViewContentsClientAdapter createWebViewContentsClientAdapter(WebView webV iew,
697 Context context) { 700 Context context) {
698 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega te); 701 return new WebViewContentsClientAdapter(webView, context, mWebViewDelega te);
699 } 702 }
700 } 703 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698