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

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

Issue 227653006: ContentView->ContentViewCore in Shell/ShellManager. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 8 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 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 25 matching lines...) Expand all
36 36
37 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; 37 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200;
38 38
39 private final Runnable mClearProgressRunnable = new Runnable() { 39 private final Runnable mClearProgressRunnable = new Runnable() {
40 @Override 40 @Override
41 public void run() { 41 public void run() {
42 mProgressDrawable.setLevel(0); 42 mProgressDrawable.setLevel(0);
43 } 43 }
44 }; 44 };
45 45
46 // TODO(jrg): a mContentView.destroy() call is needed, both upstream and dow nstream.
47 private ContentView mContentView; 46 private ContentView mContentView;
47 private ContentViewCore mContentViewCore;
48 private ContentViewClient mContentViewClient; 48 private ContentViewClient mContentViewClient;
49 private EditText mUrlTextView; 49 private EditText mUrlTextView;
50 private ImageButton mPrevButton; 50 private ImageButton mPrevButton;
51 private ImageButton mNextButton; 51 private ImageButton mNextButton;
52 52
53 private ClipDrawable mProgressDrawable; 53 private ClipDrawable mProgressDrawable;
54 54
55 private long mNativeShell; 55 private long mNativeShell;
56 private ContentViewRenderView mContentViewRenderView; 56 private ContentViewRenderView mContentViewRenderView;
57 private WindowAndroid mWindow; 57 private WindowAndroid mWindow;
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 return true; 153 return true;
154 } 154 }
155 }); 155 });
156 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() { 156 mUrlTextView.setOnFocusChangeListener(new OnFocusChangeListener() {
157 @Override 157 @Override
158 public void onFocusChange(View v, boolean hasFocus) { 158 public void onFocusChange(View v, boolean hasFocus) {
159 setKeyboardVisibilityForUrl(hasFocus); 159 setKeyboardVisibilityForUrl(hasFocus);
160 mNextButton.setVisibility(hasFocus ? GONE : VISIBLE); 160 mNextButton.setVisibility(hasFocus ? GONE : VISIBLE);
161 mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE); 161 mPrevButton.setVisibility(hasFocus ? GONE : VISIBLE);
162 if (!hasFocus) { 162 if (!hasFocus) {
163 mUrlTextView.setText(mContentView.getUrl()); 163 mUrlTextView.setText(mContentViewCore.getUrl());
164 } 164 }
165 } 165 }
166 }); 166 });
167 } 167 }
168 168
169 /** 169 /**
170 * Loads an URL. This will perform minimal amounts of sanitizing of the URL to attempt to 170 * Loads an URL. This will perform minimal amounts of sanitizing of the URL to attempt to
171 * make it valid. 171 * make it valid.
172 * 172 *
173 * @param url The URL to be loaded by the shell. 173 * @param url The URL to be loaded by the shell.
174 */ 174 */
175 public void loadUrl(String url) { 175 public void loadUrl(String url) {
176 if (url == null) return; 176 if (url == null) return;
177 177
178 if (TextUtils.equals(url, mContentView.getUrl())) { 178 if (TextUtils.equals(url, mContentViewCore.getUrl())) {
179 mContentView.getContentViewCore().reload(true); 179 mContentViewCore.reload(true);
180 } else { 180 } else {
181 mContentView.loadUrl(new LoadUrlParams(sanitizeUrl(url))); 181 mContentViewCore.loadUrl(new LoadUrlParams(sanitizeUrl(url)));
182 } 182 }
183 mUrlTextView.clearFocus(); 183 mUrlTextView.clearFocus();
184 // TODO(aurimas): Remove this when crbug.com/174541 is fixed. 184 // TODO(aurimas): Remove this when crbug.com/174541 is fixed.
185 mContentView.clearFocus(); 185 mContentView.clearFocus();
186 mContentView.requestFocus(); 186 mContentView.requestFocus();
187 } 187 }
188 188
189 /** 189 /**
190 * Given an URL, this performs minimal sanitizing to ensure it will be valid . 190 * Given an URL, this performs minimal sanitizing to ensure it will be valid .
191 * @param url The url to be sanitized. 191 * @param url The url to be sanitized.
192 * @return The sanitized URL. 192 * @return The sanitized URL.
193 */ 193 */
194 public static String sanitizeUrl(String url) { 194 public static String sanitizeUrl(String url) {
195 if (url == null) return url; 195 if (url == null) return url;
196 if (url.startsWith("www.") || url.indexOf(":") == -1) url = "http://" + url; 196 if (url.startsWith("www.") || url.indexOf(":") == -1) url = "http://" + url;
197 return url; 197 return url;
198 } 198 }
199 199
200 private void initializeNavigationButtons() { 200 private void initializeNavigationButtons() {
201 mPrevButton = (ImageButton) findViewById(R.id.prev); 201 mPrevButton = (ImageButton) findViewById(R.id.prev);
202 mPrevButton.setOnClickListener(new OnClickListener() { 202 mPrevButton.setOnClickListener(new OnClickListener() {
203 @Override 203 @Override
204 public void onClick(View v) { 204 public void onClick(View v) {
205 if (mContentView.canGoBack()) mContentView.goBack(); 205 if (mContentViewCore.canGoBack()) mContentViewCore.goBack();
206 } 206 }
207 }); 207 });
208 208
209 mNextButton = (ImageButton) findViewById(R.id.next); 209 mNextButton = (ImageButton) findViewById(R.id.next);
210 mNextButton.setOnClickListener(new OnClickListener() { 210 mNextButton.setOnClickListener(new OnClickListener() {
211 @Override 211 @Override
212 public void onClick(View v) { 212 public void onClick(View v) {
213 if (mContentView.canGoForward()) mContentView.goForward(); 213 if (mContentViewCore.canGoForward()) mContentViewCore.goForward( );
214 } 214 }
215 }); 215 });
216 } 216 }
217 217
218 @SuppressWarnings("unused") 218 @SuppressWarnings("unused")
219 @CalledByNative 219 @CalledByNative
220 private void onUpdateUrl(String url) { 220 private void onUpdateUrl(String url) {
221 mUrlTextView.setText(url); 221 mUrlTextView.setText(url);
222 } 222 }
223 223
(...skipping 21 matching lines...) Expand all
245 } 245 }
246 246
247 /** 247 /**
248 * Initializes the ContentView based on the native tab contents pointer pass ed in. 248 * Initializes the ContentView based on the native tab contents pointer pass ed in.
249 * @param nativeTabContents The pointer to the native tab contents object. 249 * @param nativeTabContents The pointer to the native tab contents object.
250 */ 250 */
251 @SuppressWarnings("unused") 251 @SuppressWarnings("unused")
252 @CalledByNative 252 @CalledByNative
253 private void initFromNativeTabContents(long nativeTabContents) { 253 private void initFromNativeTabContents(long nativeTabContents) {
254 mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow); 254 mContentView = ContentView.newInstance(getContext(), nativeTabContents, mWindow);
255 mContentView.setContentViewClient(mContentViewClient); 255 mContentViewCore = mContentView.getContentViewCore();
256 if (getParent() != null) mContentView.onShow(); 256 mContentViewCore.setContentViewClient(mContentViewClient);
257 if (mContentView.getUrl() != null) mUrlTextView.setText(mContentView.get Url()); 257
258 if (getParent() != null) mContentViewCore.onShow();
259 if (mContentViewCore.getUrl() != null) mUrlTextView.setText(mContentView Core.getUrl());
258 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew, 260 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(mContentVi ew,
259 new FrameLayout.LayoutParams( 261 new FrameLayout.LayoutParams(
260 FrameLayout.LayoutParams.MATCH_PARENT, 262 FrameLayout.LayoutParams.MATCH_PARENT,
261 FrameLayout.LayoutParams.MATCH_PARENT)); 263 FrameLayout.LayoutParams.MATCH_PARENT));
262 mContentView.requestFocus(); 264 mContentView.requestFocus();
263 mContentViewRenderView.setCurrentContentViewCore(mContentView.getContent ViewCore()); 265 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore);
264 } 266 }
265 267
266 /** 268 /**
267 * @return The {@link ContentView} currently shown by this Shell. 269 * @return The {@link ContentView} currently shown by this Shell.
268 */ 270 */
269 public ContentView getContentView() { 271 public ContentView getContentView() {
270 return mContentView; 272 return mContentView;
271 } 273 }
272 274
275 /**
276 * @return The {@link ContentViewCore} currently managing the view shown by this Shell.
277 */
278 public ContentViewCore getContentViewCore() {
279 return mContentViewCore;
280 }
281
273 private void setKeyboardVisibilityForUrl(boolean visible) { 282 private void setKeyboardVisibilityForUrl(boolean visible) {
274 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice( 283 InputMethodManager imm = (InputMethodManager) getContext().getSystemServ ice(
275 Context.INPUT_METHOD_SERVICE); 284 Context.INPUT_METHOD_SERVICE);
276 if (visible) { 285 if (visible) {
277 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); 286 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT);
278 } else { 287 } else {
279 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); 288 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0);
280 } 289 }
281 } 290 }
282 291
283 private static native void nativeCloseShell(long shellPtr); 292 private static native void nativeCloseShell(long shellPtr);
284 } 293 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698