| 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.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.content.res.Configuration; | 8 import android.content.res.Configuration; |
| 9 import android.graphics.Canvas; | 9 import android.graphics.Canvas; |
| 10 import android.os.Build; | 10 import android.os.Build; |
| 11 import android.util.AttributeSet; | 11 import android.util.AttributeSet; |
| 12 import android.view.KeyEvent; | 12 import android.view.KeyEvent; |
| 13 import android.view.MotionEvent; | 13 import android.view.MotionEvent; |
| 14 import android.view.View; | 14 import android.view.View; |
| 15 import android.view.accessibility.AccessibilityEvent; | 15 import android.view.accessibility.AccessibilityEvent; |
| 16 import android.view.accessibility.AccessibilityNodeInfo; | 16 import android.view.accessibility.AccessibilityNodeInfo; |
| 17 import android.view.inputmethod.EditorInfo; | 17 import android.view.inputmethod.EditorInfo; |
| 18 import android.view.inputmethod.InputConnection; | 18 import android.view.inputmethod.InputConnection; |
| 19 import android.webkit.DownloadListener; | 19 import android.webkit.DownloadListener; |
| 20 import android.widget.FrameLayout; | 20 import android.widget.FrameLayout; |
| 21 | 21 |
| 22 import org.chromium.content.browser.ContentViewCore; | 22 import org.chromium.content.browser.ContentViewCore; |
| 23 import org.chromium.ui.gfx.NativeWindow; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * The containing view for {@link ContentViewCore} that exists in the Android UI
hierarchy and | 26 * The containing view for {@link ContentViewCore} that exists in the Android UI
hierarchy and |
| 26 * exposes the various {@link View} functionality to it. | 27 * exposes the various {@link View} functionality to it. |
| 27 * | 28 * |
| 28 * TODO(joth): Remove any methods overrides from this class that were added for
WebView | 29 * TODO(joth): Remove any methods overrides from this class that were added for
WebView |
| 29 * compatibility. | 30 * compatibility. |
| 30 */ | 31 */ |
| 31 public class ContentView extends FrameLayout implements ContentViewCore.Internal
AccessDelegate { | 32 public class ContentView extends FrameLayout implements ContentViewCore.Internal
AccessDelegate { |
| 32 | 33 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 return ContentViewCore.initChromiumBrowserProcess(context, maxRendererPr
ocesses); | 90 return ContentViewCore.initChromiumBrowserProcess(context, maxRendererPr
ocesses); |
| 90 } | 91 } |
| 91 | 92 |
| 92 private ContentViewCore mContentViewCore; | 93 private ContentViewCore mContentViewCore; |
| 93 | 94 |
| 94 /** | 95 /** |
| 95 * Creates an instance of a ContentView. | 96 * Creates an instance of a ContentView. |
| 96 * @param context The Context the view is running in, through which it can | 97 * @param context The Context the view is running in, through which it can |
| 97 * access the current theme, resources, etc. | 98 * access the current theme, resources, etc. |
| 98 * @param nativeWebContents A pointer to the native web contents. | 99 * @param nativeWebContents A pointer to the native web contents. |
| 100 * @param nativeWindow An instance of the NativeWindow. |
| 99 * @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONAL
ITY_VIEW}. | 101 * @param personality One of {@link #PERSONALITY_CHROME} or {@link #PERSONAL
ITY_VIEW}. |
| 100 * @return A ContentView instance. | 102 * @return A ContentView instance. |
| 101 */ | 103 */ |
| 102 public static ContentView newInstance(Context context, int nativeWebContents
, int personality) { | 104 public static ContentView newInstance(Context context, int nativeWebContents
, |
| 103 return newInstance(context, nativeWebContents, null, android.R.attr.webV
iewStyle, | 105 NativeWindow nativeWindow, int personality) { |
| 104 personality); | 106 return newInstance(context, nativeWebContents, nativeWindow, null, |
| 107 android.R.attr.webViewStyle, personality); |
| 105 } | 108 } |
| 106 | 109 |
| 107 /** | 110 /** |
| 108 * Creates an instance of a ContentView. | 111 * Creates an instance of a ContentView. |
| 109 * @param context The Context the view is running in, through which it can | 112 * @param context The Context the view is running in, through which it can |
| 110 * access the current theme, resources, etc. | 113 * access the current theme, resources, etc. |
| 111 * @param nativeWebContents A pointer to the native web contents. | 114 * @param nativeWebContents A pointer to the native web contents. |
| 115 * @param nativeWindow An instance of the NativeWindow. |
| 112 * @param attrs The attributes of the XML tag that is inflating the view. | 116 * @param attrs The attributes of the XML tag that is inflating the view. |
| 113 * @return A ContentView instance. | 117 * @return A ContentView instance. |
| 114 */ | 118 */ |
| 115 public static ContentView newInstance(Context context, int nativeWebContents
, | 119 public static ContentView newInstance(Context context, int nativeWebContents
, |
| 116 AttributeSet attrs) { | 120 NativeWindow nativeWindow, AttributeSet attrs) { |
| 117 // TODO(klobag): use the WebViewStyle as the default style for now. It e
nables scrollbar. | 121 // TODO(klobag): use the WebViewStyle as the default style for now. It e
nables scrollbar. |
| 118 // When ContentView is moved to framework, we can define its own style i
n the res. | 122 // When ContentView is moved to framework, we can define its own style i
n the res. |
| 119 return newInstance(context, nativeWebContents, attrs, android.R.attr.web
ViewStyle); | 123 return newInstance(context, nativeWebContents, nativeWindow, attrs, |
| 124 android.R.attr.webViewStyle); |
| 120 } | 125 } |
| 121 | 126 |
| 122 /** | 127 /** |
| 123 * Creates an instance of a ContentView. | 128 * Creates an instance of a ContentView. |
| 124 * @param context The Context the view is running in, through which it can | 129 * @param context The Context the view is running in, through which it can |
| 125 * access the current theme, resources, etc. | 130 * access the current theme, resources, etc. |
| 126 * @param nativeWebContents A pointer to the native web contents. | 131 * @param nativeWebContents A pointer to the native web contents. |
| 132 * @param nativeWindow An instance of the NativeWindow. |
| 127 * @param attrs The attributes of the XML tag that is inflating the view. | 133 * @param attrs The attributes of the XML tag that is inflating the view. |
| 128 * @param defStyle The default style to apply to this view. | 134 * @param defStyle The default style to apply to this view. |
| 129 * @return A ContentView instance. | 135 * @return A ContentView instance. |
| 130 */ | 136 */ |
| 131 public static ContentView newInstance(Context context, int nativeWebContents
, | 137 public static ContentView newInstance(Context context, int nativeWebContents
, |
| 132 AttributeSet attrs, int defStyle) { | 138 NativeWindow nativeWindow, AttributeSet attrs, int defStyle) { |
| 133 return newInstance(context, nativeWebContents, attrs, defStyle, PERSONAL
ITY_VIEW); | 139 return newInstance(context, nativeWebContents, nativeWindow, attrs, defS
tyle, |
| 140 PERSONALITY_VIEW); |
| 134 } | 141 } |
| 135 | 142 |
| 136 private static ContentView newInstance(Context context, int nativeWebContent
s, | 143 private static ContentView newInstance(Context context, int nativeWebContent
s, |
| 137 AttributeSet attrs, int defStyle, int personality) { | 144 NativeWindow nativeWindow, AttributeSet attrs, int defStyle, int per
sonality) { |
| 138 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { | 145 if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) { |
| 139 return new ContentView(context, nativeWebContents, attrs, defStyle,
personality); | 146 return new ContentView(context, nativeWebContents, nativeWindow, att
rs, defStyle, |
| 147 personality); |
| 140 } else { | 148 } else { |
| 141 return new JellyBeanContentView(context, nativeWebContents, attrs, d
efStyle, | 149 return new JellyBeanContentView(context, nativeWebContents, nativeWi
ndow, attrs, |
| 142 personality); | 150 defStyle, personality); |
| 143 } | 151 } |
| 144 } | 152 } |
| 145 | 153 |
| 146 protected ContentView(Context context, int nativeWebContents, AttributeSet a
ttrs, int defStyle, | 154 protected ContentView(Context context, int nativeWebContents, NativeWindow n
ativeWindow, |
| 147 int personality) { | 155 AttributeSet attrs, int defStyle, int personality) { |
| 148 super(context, attrs, defStyle); | 156 super(context, attrs, defStyle); |
| 149 | 157 |
| 150 mContentViewCore = new ContentViewCore(context, personality); | 158 mContentViewCore = new ContentViewCore(context, personality); |
| 151 mContentViewCore.initialize(this, this, true, nativeWebContents, false); | 159 mContentViewCore.initialize(this, this, true, nativeWebContents, nativeW
indow, false); |
| 152 } | 160 } |
| 153 | 161 |
| 154 /** | 162 /** |
| 155 * @return The core component of the ContentView that handles JNI communicat
ion. Should only be | 163 * @return The core component of the ContentView that handles JNI communicat
ion. Should only be |
| 156 * used for passing to native. | 164 * used for passing to native. |
| 157 */ | 165 */ |
| 158 public ContentViewCore getContentViewCore() { | 166 public ContentViewCore getContentViewCore() { |
| 159 return mContentViewCore; | 167 return mContentViewCore; |
| 160 } | 168 } |
| 161 | 169 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 599 |
| 592 @Override | 600 @Override |
| 593 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { | 601 public boolean super_awakenScrollBars(int startDelay, boolean invalidate) { |
| 594 return super.awakenScrollBars(startDelay, invalidate); | 602 return super.awakenScrollBars(startDelay, invalidate); |
| 595 } | 603 } |
| 596 | 604 |
| 597 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 605 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 598 // End Implementation of ContentViewCore.InternalAccessDelega
te // | 606 // End Implementation of ContentViewCore.InternalAccessDelega
te // |
| 599 ////////////////////////////////////////////////////////////////////////////
/////////////////// | 607 ////////////////////////////////////////////////////////////////////////////
/////////////////// |
| 600 } | 608 } |
| OLD | NEW |