Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 org.chromium.android_webview; | 5 package org.chromium.android_webview; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.pm.ActivityInfo; | 8 import android.content.pm.ActivityInfo; |
| 9 import android.graphics.Bitmap; | 9 import android.graphics.Bitmap; |
| 10 import android.graphics.Picture; | 10 import android.graphics.Picture; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 48 private AwWebContentsObserver mWebContentsObserver; | 48 private AwWebContentsObserver mWebContentsObserver; |
| 49 | 49 |
| 50 private AwContentViewClient mContentViewClient = new AwContentViewClient(); | 50 private AwContentViewClient mContentViewClient = new AwContentViewClient(); |
| 51 | 51 |
| 52 // Last background color reported from the renderer. Holds the sentinal valu e INVALID_COLOR | 52 // Last background color reported from the renderer. Holds the sentinal valu e INVALID_COLOR |
| 53 // if not valid. | 53 // if not valid. |
| 54 private int mCachedRendererBackgroundColor = INVALID_COLOR; | 54 private int mCachedRendererBackgroundColor = INVALID_COLOR; |
| 55 | 55 |
| 56 private static final int INVALID_COLOR = 0; | 56 private static final int INVALID_COLOR = 0; |
| 57 | 57 |
| 58 private AwSettings mSettings; | |
|
joth
2013/11/01 19:37:33
probably cleaner to push this in as a member of th
| |
| 59 | |
| 58 public AwContentsClient() { | 60 public AwContentsClient() { |
| 59 this(Looper.myLooper()); | 61 this(Looper.myLooper()); |
| 60 } | 62 } |
| 61 | 63 |
| 62 // Alllow injection of the callback thread, for testing. | 64 // Alllow injection of the callback thread, for testing. |
| 63 public AwContentsClient(Looper looper) { | 65 public AwContentsClient(Looper looper) { |
| 64 mCallbackHelper = new AwContentsClientCallbackHelper(looper, this); | 66 mCallbackHelper = new AwContentsClientCallbackHelper(looper, this); |
| 65 } | 67 } |
| 66 | 68 |
| 67 class AwWebContentsObserver extends WebContentsObserverAndroid { | 69 class AwWebContentsObserver extends WebContentsObserverAndroid { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 128 | 130 |
| 129 @Override | 131 @Override |
| 130 public boolean shouldOverrideKeyEvent(KeyEvent event) { | 132 public boolean shouldOverrideKeyEvent(KeyEvent event) { |
| 131 return AwContentsClient.this.shouldOverrideKeyEvent(event); | 133 return AwContentsClient.this.shouldOverrideKeyEvent(event); |
| 132 } | 134 } |
| 133 | 135 |
| 134 @Override | 136 @Override |
| 135 final public ContentVideoViewClient getContentVideoViewClient() { | 137 final public ContentVideoViewClient getContentVideoViewClient() { |
| 136 return new AwContentVideoViewClient(); | 138 return new AwContentVideoViewClient(); |
| 137 } | 139 } |
| 140 | |
| 141 @Override | |
| 142 public boolean shouldBlockMediaRequest(String url) { | |
| 143 if (mSettings != null) | |
|
qinmin
2013/10/31 16:41:26
nit: I thought java coding style needs {} for if s
Ben Murdoch
2013/10/31 17:26:56
nit: could make this one line
return mSettings ==
| |
| 144 return mSettings.getBlockNetworkLoads(); | |
| 145 else | |
| 146 return true; | |
|
mkosiba (inactive)
2013/10/31 17:05:14
why is blocking the default? Did WebViewClassic be
joth
2013/11/01 19:37:33
I think the choice is arbitrary - it's not meaning
| |
| 147 } | |
| 138 } | 148 } |
| 139 | 149 |
| 140 final void installWebContentsObserver(ContentViewCore contentViewCore) { | 150 final void installWebContentsObserver(ContentViewCore contentViewCore, AwSet tings settings) { |
|
mkosiba (inactive)
2013/10/31 17:05:14
method doesn't do what it says anymore. Maybe add
| |
| 141 if (mWebContentsObserver != null) { | 151 if (mWebContentsObserver != null) { |
| 142 mWebContentsObserver.detachFromWebContents(); | 152 mWebContentsObserver.detachFromWebContents(); |
| 143 } | 153 } |
| 144 mWebContentsObserver = new AwWebContentsObserver(contentViewCore); | 154 mWebContentsObserver = new AwWebContentsObserver(contentViewCore); |
| 155 mSettings = settings; | |
| 145 } | 156 } |
| 146 | 157 |
| 147 private class AwContentVideoViewClient implements ContentVideoViewClient { | 158 private class AwContentVideoViewClient implements ContentVideoViewClient { |
| 148 @Override | 159 @Override |
| 149 public void onShowCustomView(View view) { | 160 public void onShowCustomView(View view) { |
| 150 WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomVi ewCallback() { | 161 WebChromeClient.CustomViewCallback cb = new WebChromeClient.CustomVi ewCallback() { |
| 151 @Override | 162 @Override |
| 152 public void onCustomViewHidden() { | 163 public void onCustomViewHidden() { |
| 153 ContentVideoView contentVideoView = ContentVideoView.getCont entVideoView(); | 164 ContentVideoView contentVideoView = ContentVideoView.getCont entVideoView(); |
| 154 if (contentVideoView != null) | 165 if (contentVideoView != null) |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 297 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, | 308 public abstract void onFindResultReceived(int activeMatchOrdinal, int number OfMatches, |
| 298 boolean isDoneCounting); | 309 boolean isDoneCounting); |
| 299 | 310 |
| 300 /** | 311 /** |
| 301 * Called whenever there is a new content picture available. | 312 * Called whenever there is a new content picture available. |
| 302 * @param picture New picture. | 313 * @param picture New picture. |
| 303 */ | 314 */ |
| 304 public abstract void onNewPicture(Picture picture); | 315 public abstract void onNewPicture(Picture picture); |
| 305 | 316 |
| 306 } | 317 } |
| OLD | NEW |