| 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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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(mContentViewCore.getUrl()); | 163 mUrlTextView.setText(mContentViewCore.getWebContents().getUr
l()); |
| 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, mContentViewCore.getUrl())) { | 178 if (TextUtils.equals(url, mContentViewCore.getWebContents().getUrl())) { |
| 179 mContentViewCore.reload(true); | 179 mContentViewCore.reload(true); |
| 180 } else { | 180 } else { |
| 181 mContentViewCore.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 mContentViewCore.getContainerView().clearFocus(); | 185 mContentViewCore.getContainerView().clearFocus(); |
| 186 mContentViewCore.getContainerView().requestFocus(); | 186 mContentViewCore.getContainerView().requestFocus(); |
| 187 } | 187 } |
| 188 | 188 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 @SuppressWarnings("unused") | 251 @SuppressWarnings("unused") |
| 252 @CalledByNative | 252 @CalledByNative |
| 253 private void initFromNativeTabContents(long nativeWebContents) { | 253 private void initFromNativeTabContents(long nativeWebContents) { |
| 254 Context context = getContext(); | 254 Context context = getContext(); |
| 255 mContentViewCore = new ContentViewCore(context); | 255 mContentViewCore = new ContentViewCore(context); |
| 256 ContentView cv = ContentView.newInstance(context, mContentViewCore); | 256 ContentView cv = ContentView.newInstance(context, mContentViewCore); |
| 257 mContentViewCore.initialize(cv, cv, nativeWebContents, mWindow); | 257 mContentViewCore.initialize(cv, cv, nativeWebContents, mWindow); |
| 258 mContentViewCore.setContentViewClient(mContentViewClient); | 258 mContentViewCore.setContentViewClient(mContentViewClient); |
| 259 | 259 |
| 260 if (getParent() != null) mContentViewCore.onShow(); | 260 if (getParent() != null) mContentViewCore.onShow(); |
| 261 if (mContentViewCore.getUrl() != null) mUrlTextView.setText(mContentView
Core.getUrl()); | 261 if (mContentViewCore.getWebContents().getUrl() != null) { |
| 262 mUrlTextView.setText(mContentViewCore.getWebContents().getUrl()); |
| 263 } |
| 262 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, | 264 ((FrameLayout) findViewById(R.id.contentview_holder)).addView(cv, |
| 263 new FrameLayout.LayoutParams( | 265 new FrameLayout.LayoutParams( |
| 264 FrameLayout.LayoutParams.MATCH_PARENT, | 266 FrameLayout.LayoutParams.MATCH_PARENT, |
| 265 FrameLayout.LayoutParams.MATCH_PARENT)); | 267 FrameLayout.LayoutParams.MATCH_PARENT)); |
| 266 cv.requestFocus(); | 268 cv.requestFocus(); |
| 267 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); | 269 mContentViewRenderView.setCurrentContentViewCore(mContentViewCore); |
| 268 } | 270 } |
| 269 | 271 |
| 270 /** | 272 /** |
| 271 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa
llowed | 273 * Enable/Disable navigation(Prev/Next) button if navigation is allowed/disa
llowed |
| (...skipping 26 matching lines...) Expand all Loading... |
| 298 Context.INPUT_METHOD_SERVICE); | 300 Context.INPUT_METHOD_SERVICE); |
| 299 if (visible) { | 301 if (visible) { |
| 300 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 302 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 301 } else { | 303 } else { |
| 302 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 304 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 303 } | 305 } |
| 304 } | 306 } |
| 305 | 307 |
| 306 private static native void nativeCloseShell(long shellPtr); | 308 private static native void nativeCloseShell(long shellPtr); |
| 307 } | 309 } |
| OLD | NEW |