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

Side by Side Diff: content/shell/android/java/src/org/chromium/content_shell/Shell.java

Issue 10916160: Upstreaming SelectFileDialog for Android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 3 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 | Annotate | Revision Log
OLDNEW
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_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;
11 import android.view.KeyEvent; 11 import android.view.KeyEvent;
12 import android.view.View; 12 import android.view.View;
13 import android.view.inputmethod.EditorInfo; 13 import android.view.inputmethod.EditorInfo;
14 import android.view.inputmethod.InputMethodManager; 14 import android.view.inputmethod.InputMethodManager;
15 import android.widget.EditText; 15 import android.widget.EditText;
16 import android.widget.FrameLayout; 16 import android.widget.FrameLayout;
17 import android.widget.ImageButton; 17 import android.widget.ImageButton;
18 import android.widget.LinearLayout; 18 import android.widget.LinearLayout;
19 import android.widget.TextView; 19 import android.widget.TextView;
20 import android.widget.TextView.OnEditorActionListener; 20 import android.widget.TextView.OnEditorActionListener;
21 21
22 import org.chromium.base.CalledByNative; 22 import org.chromium.base.CalledByNative;
23 import org.chromium.base.JNINamespace; 23 import org.chromium.base.JNINamespace;
24 import org.chromium.content.browser.ContentView; 24 import org.chromium.content.browser.ContentView;
25 import org.chromium.content.browser.LoadUrlParams; 25 import org.chromium.content.browser.LoadUrlParams;
26 import org.chromium.ui.gfx.NativeWindow;
26 27
27 /** 28 /**
28 * Container for the various UI components that make up a shell window. 29 * Container for the various UI components that make up a shell window.
29 */ 30 */
30 @JNINamespace("content") 31 @JNINamespace("content")
31 public class Shell extends LinearLayout { 32 public class Shell extends LinearLayout {
32 33
33 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 34 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
34 35
35 private Runnable mClearProgressRunnable = new Runnable() { 36 private Runnable mClearProgressRunnable = new Runnable() {
36 @Override 37 @Override
37 public void run() { 38 public void run() {
38 mProgressDrawable.setLevel(0); 39 mProgressDrawable.setLevel(0);
39 } 40 }
40 }; 41 };
41 42
42 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow nstream. 43 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow nstream.
43 private ContentView mContentView; 44 private ContentView mContentView;
44 private EditText mUrlTextView; 45 private EditText mUrlTextView;
45 private ImageButton mPrevButton; 46 private ImageButton mPrevButton;
46 private ImageButton mNextButton; 47 private ImageButton mNextButton;
47 48
48 private ClipDrawable mProgressDrawable; 49 private ClipDrawable mProgressDrawable;
49 50
50 private View mSurfaceView; 51 private View mSurfaceView;
52 private NativeWindow mWindow;
51 53
52 /** 54 /**
53 * Constructor for inflating via XML. 55 * Constructor for inflating via XML.
54 */ 56 */
55 public Shell(Context context, AttributeSet attrs) { 57 public Shell(Context context, AttributeSet attrs) {
56 super(context, attrs); 58 super(context, attrs);
57 } 59 }
58 60
59 /** 61 /**
60 * Set the SurfaceView being renderered to as soon as it is available. 62 * Set the SurfaceView being renderered to as soon as it is available.
61 */ 63 */
62 public void setSurfaceView(View surfaceView) { 64 public void setSurfaceView(View surfaceView) {
63 mSurfaceView = surfaceView; 65 mSurfaceView = surfaceView;
64 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mSurfaceVi ew, 66 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mSurfaceVi ew,
65 new FrameLayout.LayoutParams( 67 new FrameLayout.LayoutParams(
66 FrameLayout.LayoutParams.MATCH_PARENT, 68 FrameLayout.LayoutParams.MATCH_PARENT,
67 FrameLayout.LayoutParams.MATCH_PARENT)); 69 FrameLayout.LayoutParams.MATCH_PARENT));
68 } 70 }
69 71
72 /**
73 * @param window The owning window for this shell.
74 */
75 public void setWindow(NativeWindow window) {
76 mWindow = window;
77 }
78
70 @Override 79 @Override
71 protected void onFinishInflate() { 80 protected void onFinishInflate() {
72 super.onFinishInflate(); 81 super.onFinishInflate();
73 82
74 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und(); 83 mProgressDrawable = (ClipDrawable) findViewById(R.id.toolbar).getBackgro und();
75 initializeUrlField(); 84 initializeUrlField();
76 initializeNavigationButtons(); 85 initializeNavigationButtons();
77 } 86 }
78 87
79 private void initializeUrlField() { 88 private void initializeUrlField() {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 } 175 }
167 176
168 /** 177 /**
169 * Initializes the ContentView based on the native tab contents pointer pass ed in. 178 * Initializes the ContentView based on the native tab contents pointer pass ed in.
170 * @param nativeTabContents The pointer to the native tab contents object. 179 * @param nativeTabContents The pointer to the native tab contents object.
171 */ 180 */
172 @SuppressWarnings("unused") 181 @SuppressWarnings("unused")
173 @CalledByNative 182 @CalledByNative
174 private void initFromNativeTabContents(int nativeTabContents) { 183 private void initFromNativeTabContents(int nativeTabContents) {
175 mContentView = ContentView.newInstance( 184 mContentView = ContentView.newInstance(
176 getContext(), nativeTabContents, ContentView.PERSONALITY_CHROME) ; 185 getContext(), nativeTabContents, mWindow, ContentView.PERSONALIT Y_CHROME);
177 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get Url()); 186 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get Url());
178 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew, 187 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew,
179 new FrameLayout.LayoutParams( 188 new FrameLayout.LayoutParams(
180 FrameLayout.LayoutParams.MATCH_PARENT, 189 FrameLayout.LayoutParams.MATCH_PARENT,
181 FrameLayout.LayoutParams.MATCH_PARENT)); 190 FrameLayout.LayoutParams.MATCH_PARENT));
182 mContentView.requestFocus(); 191 mContentView.requestFocus();
183 } 192 }
184 193
185 /** 194 /**
186 * @return The {@link ContentView} currently shown by this Shell. 195 * @return The {@link ContentView} currently shown by this Shell.
187 */ 196 */
188 public ContentView getContentView() { 197 public ContentView getContentView() {
189 return mContentView; 198 return mContentView;
190 } 199 }
191 200
192 private void setKeyboardVisibilityForUrl(boolean visible) { 201 private void setKeyboardVisibilityForUrl(boolean visible) {
193 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( 202 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice(
194 Context.INPUT_METHOD_SERVICE); 203 Context.INPUT_METHOD_SERVICE);
195 if (visible) { 204 if (visible) {
196 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 205 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
197 } else { 206 } else {
198 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 207 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
199 } 208 }
200 } 209 }
201 } 210 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698