OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_shell; | 5 package org.chromium.content_shell; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.graphics.drawable.ClipDrawable; | 8 import android.graphics.drawable.ClipDrawable; |
9 import android.text.TextUtils; | 9 import android.text.TextUtils; |
10 import android.util.AttributeSet; | 10 import android.util.AttributeSet; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 }; | 42 }; |
43 | 43 |
44 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow
nstream. | 44 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow
nstream. |
45 private ContentView mContentView; | 45 private ContentView mContentView; |
46 private EditText mUrlTextView; | 46 private EditText mUrlTextView; |
47 private ImageButton mPrevButton; | 47 private ImageButton mPrevButton; |
48 private ImageButton mNextButton; | 48 private ImageButton mNextButton; |
49 | 49 |
50 private ClipDrawable mProgressDrawable; | 50 private ClipDrawable mProgressDrawable; |
51 | 51 |
52 private long mNativeShell; | |
53 private ContentViewRenderView mContentViewRenderView; | 52 private ContentViewRenderView mContentViewRenderView; |
54 private WindowAndroid mWindow; | 53 private WindowAndroid mWindow; |
55 | 54 |
56 private boolean mLoading = false; | 55 private boolean mLoading = false; |
57 | 56 |
58 /** | 57 /** |
59 * Constructor for inflating via XML. | 58 * Constructor for inflating via XML. |
60 */ | 59 */ |
61 public Shell(Context context, AttributeSet attrs) { | 60 public Shell(Context context, AttributeSet attrs) { |
62 super(context, attrs); | 61 super(context, attrs); |
(...skipping 11 matching lines...) Expand all Loading... |
74 } else { | 73 } else { |
75 contentViewHolder.addView(contentViewRenderView, | 74 contentViewHolder.addView(contentViewRenderView, |
76 new FrameLayout.LayoutParams( | 75 new FrameLayout.LayoutParams( |
77 FrameLayout.LayoutParams.MATCH_PARENT, | 76 FrameLayout.LayoutParams.MATCH_PARENT, |
78 FrameLayout.LayoutParams.MATCH_PARENT)); | 77 FrameLayout.LayoutParams.MATCH_PARENT)); |
79 } | 78 } |
80 mContentViewRenderView = contentViewRenderView; | 79 mContentViewRenderView = contentViewRenderView; |
81 } | 80 } |
82 | 81 |
83 /** | 82 /** |
84 * Initializes the Shell for use. | |
85 * | |
86 * @param nativeShell The pointer to the native Shell object. | |
87 * @param window The owning window for this shell. | 83 * @param window The owning window for this shell. |
88 */ | 84 */ |
89 public void initialize(long nativeShell, WindowAndroid window) { | 85 public void setWindow(WindowAndroid window) { |
90 mNativeShell = nativeShell; | |
91 mWindow = window; | 86 mWindow = window; |
92 } | 87 } |
93 | 88 |
94 /** | 89 /** |
95 * Closes the shell and cleans up the native instance, which will handle des
troying all | |
96 * dependencies. | |
97 */ | |
98 public void close() { | |
99 if (mNativeShell == 0) return; | |
100 nativeCloseShell(mNativeShell); | |
101 } | |
102 | |
103 @CalledByNative | |
104 private void onNativeDestroyed() { | |
105 mWindow = null; | |
106 mNativeShell = 0; | |
107 mContentView.destroy(); | |
108 } | |
109 | |
110 /** | |
111 * @return Whether the Shell has been destroyed. | |
112 * @see #onNativeDestroyed() | |
113 */ | |
114 public boolean isDestroyed() { | |
115 return mNativeShell == 0; | |
116 } | |
117 | |
118 /** | |
119 * @return Whether or not the Shell is loading content. | 90 * @return Whether or not the Shell is loading content. |
120 */ | 91 */ |
121 public boolean isLoading() { | 92 public boolean isLoading() { |
122 return mLoading; | 93 return mLoading; |
123 } | 94 } |
124 | 95 |
125 @Override | 96 @Override |
126 protected void onFinishInflate() { | 97 protected void onFinishInflate() { |
127 super.onFinishInflate(); | 98 super.onFinishInflate(); |
128 | 99 |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 | 235 |
265 private void setKeyboardVisibilityForUrl(boolean visible) { | 236 private void setKeyboardVisibilityForUrl(boolean visible) { |
266 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( | 237 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ
ice( |
267 Context.INPUT_METHOD_SERVICE); | 238 Context.INPUT_METHOD_SERVICE); |
268 if (visible) { | 239 if (visible) { |
269 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 240 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
270 } else { | 241 } else { |
271 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 242 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
272 } | 243 } |
273 } | 244 } |
274 | |
275 private static native void nativeCloseShell(long shellPtr); | |
276 } | 245 } |
OLD | NEW |