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

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

Issue 10536066: android content shell bringup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync and merge Created 8 years, 6 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
« no previous file with comments | « content/public/common/file_chooser_params.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.content.browser.ContentView; 23 import org.chromium.content.browser.ContentView;
24 import org.chromium.content.browser.ContentViewClient;
24 25
25 /** 26 /**
26 * Container for the various UI components that make up a shell window. 27 * Container for the various UI components that make up a shell window.
27 */ 28 */
28 public class ShellView extends LinearLayout { 29 public class ShellView extends LinearLayout {
29 30
30 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 31 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
31 32
32 private int mNativeShellView; 33 private int mNativeShellView;
34 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow nstream.
33 private ContentView mContentView; 35 private ContentView mContentView;
34 private EditText mUrlTextView; 36 private EditText mUrlTextView;
35 private ImageButton mPrevButton; 37 private ImageButton mPrevButton;
36 private ImageButton mNextButton; 38 private ImageButton mNextButton;
37 39
38 private ClipDrawable mProgressDrawable; 40 private ClipDrawable mProgressDrawable;
39 41
40 /** 42 /**
41 * Constructor for inflating via XML. 43 * Constructor for inflating via XML.
42 */ 44 */
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 */ 139 */
138 @SuppressWarnings("unused") 140 @SuppressWarnings("unused")
139 @CalledByNative 141 @CalledByNative
140 private void initFromNativeTabContents(int nativeTabContents) { 142 private void initFromNativeTabContents(int nativeTabContents) {
141 // TODO(tedchoc): Pass along native tab contents. 143 // TODO(tedchoc): Pass along native tab contents.
142 mContentView = new ContentView(getContext()); 144 mContentView = new ContentView(getContext());
143 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew, 145 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew,
144 new FrameLayout.LayoutParams( 146 new FrameLayout.LayoutParams(
145 FrameLayout.LayoutParams.MATCH_PARENT, 147 FrameLayout.LayoutParams.MATCH_PARENT,
146 FrameLayout.LayoutParams.MATCH_PARENT)); 148 FrameLayout.LayoutParams.MATCH_PARENT));
149 mContentView.setContentViewClient(new ShellContentViewClient());
147 } 150 }
148 151
149 /** 152 /**
150 * @return The {@link ContentView} currently shown by this Shell. 153 * @return The {@link ContentView} currently shown by this Shell.
151 */ 154 */
152 public ContentView getContentView() { 155 public ContentView getContentView() {
153 return mContentView; 156 return mContentView;
154 } 157 }
155 158
156 private void setKeyboardVisibilityForUrl(boolean visible) { 159 private void setKeyboardVisibilityForUrl(boolean visible) {
157 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( 160 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice(
158 Context.INPUT_METHOD_SERVICE); 161 Context.INPUT_METHOD_SERVICE);
159 if (visible) { 162 if (visible) {
160 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 163 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
161 } else { 164 } else {
162 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 165 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
163 } 166 }
164 } 167 }
165 168
166 private native int nativeInit(); 169 private native int nativeInit();
170
171 private class ShellContentViewClient extends ContentViewClient {
172 private Runnable mClearProgressRunnable = new Runnable() {
173 @Override
174 public void run() {
175 mProgressDrawable.setLevel(0);
176 }
177 };
178
179 @Override
180 public void onUpdateUrl(String url) {
181 super.onUpdateUrl(url);
182 mUrlTextView.setText(url);
183 }
184
185 @Override
186 public void onLoadProgressChanged(final double progress) {
187 super.onLoadProgressChanged(progress);
188 removeCallbacks(mClearProgressRunnable);
189 mProgressDrawable.setLevel((int) (10000.0 * progress));
190 if (progress == 1.0) postDelayed(mClearProgressRunnable, COMPLETED_P ROGRESS_TIMEOUT_MS);
191 }
192
193 @Override
194 public void onTabCrash(int pid) {
195 super.onTabCrash(pid);
196 mProgressDrawable.setLevel(0);
197 }
198 }
167 } 199 }
OLDNEW
« no previous file with comments | « content/public/common/file_chooser_params.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698