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

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

Issue 2243753002: Prevent thread assertion for HTC mail apk (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: addressed more comments Created 4 years, 4 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;
11 import android.content.Intent; 11 import android.content.Intent;
12 import android.content.SharedPreferences; 12 import android.content.SharedPreferences;
13 import android.content.pm.PackageInfo; 13 import android.content.pm.PackageInfo;
14 import android.content.pm.PackageManager; 14 import android.content.pm.PackageManager;
15 import android.content.pm.PackageManager.NameNotFoundException;
15 import android.net.Uri; 16 import android.net.Uri;
16 import android.os.Build; 17 import android.os.Build;
17 import android.os.Looper; 18 import android.os.Looper;
18 import android.os.Process; 19 import android.os.Process;
19 import android.os.StrictMode; 20 import android.os.StrictMode;
20 import android.util.Log; 21 import android.util.Log;
21 import android.webkit.CookieManager; 22 import android.webkit.CookieManager;
22 import android.webkit.GeolocationPermissions; 23 import android.webkit.GeolocationPermissions;
23 import android.webkit.WebStorage; 24 import android.webkit.WebStorage;
24 import android.webkit.WebView; 25 import android.webkit.WebView;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 return AwContentsClient.parseFileChooserResult(resultCod e, intent); 476 return AwContentsClient.parseFileChooserResult(resultCod e, intent);
476 } 477 }
477 }; 478 };
478 } 479 }
479 } 480 }
480 return mStaticMethods; 481 return mStaticMethods;
481 } 482 }
482 483
483 @Override 484 @Override
484 public WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess) { 485 public WebViewProvider createWebView(WebView webView, WebView.PrivateAccess privateAccess) {
485 return new WebViewChromium(this, webView, privateAccess); 486 return new WebViewChromium(this, webView, privateAccess, isHtcMail(webVi ew.getContext()));
486 } 487 }
487 488
489 // Check this as a workaround for https://crbug.com/622151.
490 private boolean isHtcMail(Context context) {
491 if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) return false;
492 final String htcMailPackageId = "com.htc.android.mail";
493 if (!htcMailPackageId.equals(context.getPackageName())) return false;
494 try {
495 PackageInfo packageInfo =
496 context.getPackageManager().getPackageInfo(htcMailPackageId, 0);
497 if (packageInfo == null) return false;
498 // These values are provided by HTC.
499 if ((Build.VERSION.SDK_INT < Build.VERSION_CODES.M
500 && packageInfo.versionCode < 864021756)
501 || packageInfo.versionCode < 866001861) {
502 Log.w(TAG, "Disabling thread check in WebView (http://crbug.com/ 622151). "
503 + "APK name: " + htcMailPackageId + ", versionCode: "
504 + packageInfo.versionCode);
505 return true;
506 }
507 } catch (NameNotFoundException e) {
508 // Ignore this exception and return false.
509 }
510 return false;
511 }
512
513
488 @Override 514 @Override
489 public GeolocationPermissions getGeolocationPermissions() { 515 public GeolocationPermissions getGeolocationPermissions() {
490 synchronized (mLock) { 516 synchronized (mLock) {
491 if (mGeolocationPermissions == null) { 517 if (mGeolocationPermissions == null) {
492 ensureChromiumStartedLocked(true); 518 ensureChromiumStartedLocked(true);
493 AwGeolocationPermissions awGelocationPermissions = ThreadUtils.r unningOnUiThread() 519 AwGeolocationPermissions awGelocationPermissions = ThreadUtils.r unningOnUiThread()
494 ? getBrowserContextOnUiThread().getGeolocationPermission s() 520 ? getBrowserContextOnUiThread().getGeolocationPermission s()
495 : runOnUiThreadBlocking(new Callable<AwGeolocationPermis sions>() { 521 : runOnUiThreadBlocking(new Callable<AwGeolocationPermis sions>() {
496 @Override 522 @Override
497 public AwGeolocationPermissions call() { 523 public AwGeolocationPermissions call() {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
561 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase); 587 mWebViewDatabase = new WebViewDatabaseAdapter(this, awDatabase);
562 } 588 }
563 } 589 }
564 return mWebViewDatabase; 590 return mWebViewDatabase;
565 } 591 }
566 592
567 WebViewDelegate getWebViewDelegate() { 593 WebViewDelegate getWebViewDelegate() {
568 return mWebViewDelegate; 594 return mWebViewDelegate;
569 } 595 }
570 } 596 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698