| 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.chrome.testshell; | 5 package org.chromium.chrome.testshell; |
| 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.util.AttributeSet; | 9 import android.util.AttributeSet; |
| 10 import android.view.KeyEvent; | 10 import android.view.KeyEvent; |
| 11 import android.view.MotionEvent; | 11 import android.view.MotionEvent; |
| 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.ImageButton; | 16 import android.widget.ImageButton; |
| 17 import android.widget.LinearLayout; | 17 import android.widget.LinearLayout; |
| 18 import android.widget.TextView; | 18 import android.widget.TextView; |
| 19 import android.widget.TextView.OnEditorActionListener; | 19 import android.widget.TextView.OnEditorActionListener; |
| 20 | 20 |
| 21 import org.chromium.chrome.browser.EmptyTabObserver; | 21 import org.chromium.chrome.browser.EmptyTabObserver; |
| 22 import org.chromium.chrome.browser.TabBase; | 22 import org.chromium.chrome.browser.Tab; |
| 23 import org.chromium.chrome.browser.TabObserver; | 23 import org.chromium.chrome.browser.TabObserver; |
| 24 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; | 24 import org.chromium.chrome.browser.appmenu.AppMenuButtonHelper; |
| 25 import org.chromium.chrome.browser.appmenu.AppMenuHandler; | 25 import org.chromium.chrome.browser.appmenu.AppMenuHandler; |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * A Toolbar {@link View} that shows the URL and navigation buttons. | 28 * A Toolbar {@link View} that shows the URL and navigation buttons. |
| 29 */ | 29 */ |
| 30 public class TestShellToolbar extends LinearLayout { | 30 public class TestShellToolbar extends LinearLayout { |
| 31 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; | 31 private static final long COMPLETED_PROGRESS_TIMEOUT_MS = 200; |
| 32 | 32 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 /** | 49 /** |
| 50 * @param context The Context the view is running in. | 50 * @param context The Context the view is running in. |
| 51 * @param attrs The attributes of the XML tag that is inflating the view. | 51 * @param attrs The attributes of the XML tag that is inflating the view. |
| 52 */ | 52 */ |
| 53 public TestShellToolbar(Context context, AttributeSet attrs) { | 53 public TestShellToolbar(Context context, AttributeSet attrs) { |
| 54 super(context, attrs); | 54 super(context, attrs); |
| 55 } | 55 } |
| 56 | 56 |
| 57 /** | 57 /** |
| 58 * The toolbar will visually represent the state of {@code tab}. | 58 * The toolbar will visually represent the state of {@code tab}. |
| 59 * @param tab The TabBase that should be represented. | 59 * @param tab The Tab that should be represented. |
| 60 */ | 60 */ |
| 61 public void showTab(TestShellTab tab) { | 61 public void showTab(TestShellTab tab) { |
| 62 if (mTab != null) mTab.removeObserver(mTabObserver); | 62 if (mTab != null) mTab.removeObserver(mTabObserver); |
| 63 mTab = tab; | 63 mTab = tab; |
| 64 mTab.addObserver(mTabObserver); | 64 mTab.addObserver(mTabObserver); |
| 65 mUrlTextView.setText(mTab.getContentView().getUrl()); | 65 mUrlTextView.setText(mTab.getContentView().getUrl()); |
| 66 } | 66 } |
| 67 | 67 |
| 68 private void onUpdateUrl(String url) { | 68 private void onUpdateUrl(String url) { |
| 69 mUrlTextView.setText(url); | 69 mUrlTextView.setText(url); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 Context.INPUT_METHOD_SERVICE); | 140 Context.INPUT_METHOD_SERVICE); |
| 141 if (visible) { | 141 if (visible) { |
| 142 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); | 142 imm.showSoftInput(mUrlTextView, InputMethodManager.SHOW_IMPLICIT); |
| 143 } else { | 143 } else { |
| 144 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); | 144 imm.hideSoftInputFromWindow(mUrlTextView.getWindowToken(), 0); |
| 145 } | 145 } |
| 146 } | 146 } |
| 147 | 147 |
| 148 private class TabObserverImpl extends EmptyTabObserver { | 148 private class TabObserverImpl extends EmptyTabObserver { |
| 149 @Override | 149 @Override |
| 150 public void onLoadProgressChanged(TabBase tab, int progress) { | 150 public void onLoadProgressChanged(Tab tab, int progress) { |
| 151 if (tab == mTab) TestShellToolbar.this.onLoadProgressChanged(progres
s); | 151 if (tab == mTab) TestShellToolbar.this.onLoadProgressChanged(progres
s); |
| 152 } | 152 } |
| 153 | 153 |
| 154 @Override | 154 @Override |
| 155 public void onUpdateUrl(TabBase tab, String url) { | 155 public void onUpdateUrl(Tab tab, String url) { |
| 156 if (tab == mTab) TestShellToolbar.this.onUpdateUrl(url); | 156 if (tab == mTab) TestShellToolbar.this.onUpdateUrl(url); |
| 157 } | 157 } |
| 158 } | 158 } |
| 159 } | 159 } |
| OLD | NEW |