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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java

Issue 1628513002: Add proper null checks to android's find in page UI behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindResultBar.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java
index c1bd42325fb32eeb98d29f37e02f7bc07e306c8f..724d16acd3ac0420c8fea7eadb7c31a46776b88a 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindToolbar.java
@@ -220,6 +220,8 @@ public class FindToolbar extends LinearLayout
mFindQuery.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
+ if (mFindInPageBridge == null) return;
+
mAccessibilityDidActivateResult = false;
setPrevNextEnabled(s.length() > 0);
@@ -260,6 +262,8 @@ public class FindToolbar extends LinearLayout
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (event != null && event.getAction() == KeyEvent.ACTION_UP) return false;
+ if (mFindInPageBridge == null) return false;
+
// Only trigger a new find if the text was set programmatically.
// Otherwise just revisit the current active match.
if (mSearchKeyShouldTriggerSearch) {
@@ -308,6 +312,8 @@ public class FindToolbar extends LinearLayout
}
private void hideKeyboardAndStartFinding(boolean forward) {
+ if (mFindInPageBridge == null) return;
+
final String findQuery = mFindQuery.getText().toString();
if (findQuery.length() == 0) return;
@@ -370,6 +376,8 @@ public class FindToolbar extends LinearLayout
public void onFindResult(FindNotificationDetails result) {
if (mResultBar != null) mResultBar.mWaitingForActivateAck = false;
+ assert mFindInPageBridge != null;
+
if ((result.activeMatchOrdinal == -1 || result.numberOfMatches == 1)
&& !result.finalUpdate) {
// Wait until activeMatchOrdinal has been determined (is no longer
@@ -571,6 +579,7 @@ public class FindToolbar extends LinearLayout
}
mFindInPageBridge.destroy();
+ mFindInPageBridge = null;
mActive = false;
}
@@ -605,6 +614,8 @@ public class FindToolbar extends LinearLayout
* Restores the last text searched in this tab, or the global last search.
*/
private void initializeFindText() {
+ assert mFindInPageBridge != null;
+
mSettingFindTextProgrammatically = true;
String findText = null;
if (mSettingFindTextProgrammatically) {
@@ -631,6 +642,8 @@ public class FindToolbar extends LinearLayout
private void setResultsBarVisibility(boolean visibility) {
if (visibility && mResultBar == null && mCurrentTab != null
&& mCurrentTab.getContentViewCore() != null) {
+ assert mFindInPageBridge != null;
+
mResultBar = new FindResultBar(getContext(), mCurrentTab, mFindInPageBridge);
} else if (!visibility) {
if (mResultBar != null) {
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/widget/findinpage/FindResultBar.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698