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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java

Issue 2963393002: Do not process incoming intents to the search activity if promo is needed. (Closed)
Patch Set: Fix tests Created 3 years, 5 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 | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchActivityTest.java » ('j') | 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/searchwidget/SearchActivityLocationBarLayout.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
index 995ffa48db9cfa6ee44a93f5ed59a1b5d89fad45..39705708fee6692a798e19d98d39803a9c62272e 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/searchwidget/SearchActivityLocationBarLayout.java
@@ -31,12 +31,13 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
}
private Delegate mDelegate;
- private boolean mShowSuggestions;
+ private boolean mPendingSearchPromoDecision;
+ private boolean mPendingBeginQuery;
public SearchActivityLocationBarLayout(Context context, AttributeSet attrs) {
super(context, attrs, R.layout.location_bar_base);
setUrlBarFocusable(true);
- mShowSuggestions = !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
+ mPendingSearchPromoDecision = LocaleManager.getInstance().needToCheckForSearchEnginePromo();
}
/** Set the {@link Delegate}. */
@@ -69,14 +70,15 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
public void onNativeLibraryReady() {
super.onNativeLibraryReady();
setAutocompleteProfile(Profile.getLastUsedProfile().getOriginalProfile());
+
+ mPendingSearchPromoDecision = LocaleManager.getInstance().needToCheckForSearchEnginePromo();
setShowCachedZeroSuggestResults(true);
- mShowSuggestions = !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
}
@Override
public void onSuggestionsReceived(
List<OmniboxSuggestion> newSuggestions, String inlineAutocompleteText) {
- if (!mShowSuggestions) return;
+ if (mPendingSearchPromoDecision) return;
super.onSuggestionsReceived(newSuggestions, inlineAutocompleteText);
}
@@ -85,11 +87,39 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
SearchWidgetProvider.updateCachedVoiceSearchAvailability(isVoiceSearchEnabled());
if (isVoiceSearchIntent && mUrlBar.isFocused()) onUrlFocusChange(true);
if (!TextUtils.isEmpty(mUrlBar.getText())) onTextChangedForAutocomplete();
- mShowSuggestions = true;
+
+ assert !LocaleManager.getInstance().needToCheckForSearchEnginePromo();
+ mPendingSearchPromoDecision = false;
+
+ if (mPendingBeginQuery) {
+ beginQueryInternal(isVoiceSearchIntent);
+ mPendingBeginQuery = false;
+ }
}
/** Begins a new query. */
void beginQuery(boolean isVoiceSearchIntent) {
+ // Clear the text regardless of the promo decision. This allows the user to enter text
+ // before native has been initialized and have it not be cleared one the delayed beginQuery
+ // logic is performed.
+ mUrlBar.setIgnoreTextChangesForAutocomplete(true);
+ mUrlBar.setUrl("", null);
+ mUrlBar.setIgnoreTextChangesForAutocomplete(false);
+
+ mUrlBar.setCursorVisible(true);
+ mUrlBar.setSelection(0, mUrlBar.getText().length());
+
+ if (mPendingSearchPromoDecision) {
+ mPendingBeginQuery = true;
+ return;
+ }
+
+ beginQueryInternal(isVoiceSearchIntent);
+ }
+
+ private void beginQueryInternal(boolean isVoiceSearchIntent) {
+ assert !mPendingSearchPromoDecision;
+
if (isVoiceSearchEnabled() && isVoiceSearchIntent) {
startVoiceRecognition();
} else {
@@ -105,14 +135,8 @@ public class SearchActivityLocationBarLayout extends LocationBarLayout {
}
private void focusTextBox() {
- if (mNativeInitialized) onUrlFocusChange(true);
+ if (!mUrlBar.hasFocus()) mUrlBar.requestFocus();
- mUrlBar.setIgnoreTextChangesForAutocomplete(true);
- mUrlBar.setUrl("", null);
- mUrlBar.setIgnoreTextChangesForAutocomplete(false);
-
- mUrlBar.setCursorVisible(true);
- mUrlBar.setSelection(0, mUrlBar.getText().length());
new Handler().post(new Runnable() {
@Override
public void run() {
« no previous file with comments | « no previous file | chrome/android/javatests/src/org/chromium/chrome/browser/searchwidget/SearchActivityTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698