| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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.browser.omnibox; | 5 package org.chromium.chrome.browser.omnibox; |
| 6 | 6 |
| 7 import static org.chromium.chrome.browser.toolbar.ToolbarPhone.URL_FOCUS_CHANGE_
ANIMATION_DURATION_MS; | 7 import static org.chromium.chrome.browser.toolbar.ToolbarPhone.URL_FOCUS_CHANGE_
ANIMATION_DURATION_MS; |
| 8 | 8 |
| 9 import android.Manifest; | 9 import android.Manifest; |
| 10 import android.animation.Animator; | 10 import android.animation.Animator; |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 // set the text to the suggestion again. | 327 // set the text to the suggestion again. |
| 328 setUrlBarText("", null); | 328 setUrlBarText("", null); |
| 329 mUrlBar.setText(selectedItem.getSuggestion().getFillIntoEdit()); | 329 mUrlBar.setText(selectedItem.getSuggestion().getFillIntoEdit()); |
| 330 mSuggestionList.setSelection(0); | 330 mSuggestionList.setSelection(0); |
| 331 mUrlBar.setSelection(mUrlBar.getText().length()); | 331 mUrlBar.setSelection(mUrlBar.getText().length()); |
| 332 return true; | 332 return true; |
| 333 } else if (KeyNavigationUtil.isEnter(event) | 333 } else if (KeyNavigationUtil.isEnter(event) |
| 334 && LocationBarLayout.this.getVisibility() == VISIBLE) { | 334 && LocationBarLayout.this.getVisibility() == VISIBLE) { |
| 335 UiUtils.hideKeyboard(mUrlBar); | 335 UiUtils.hideKeyboard(mUrlBar); |
| 336 mSuggestionSelectionInProgress = true; | 336 mSuggestionSelectionInProgress = true; |
| 337 final String urlText = mUrlBar.getQueryText(); | 337 final String urlText = mUrlBar.getTextWithAutocomplete(); |
| 338 if (mNativeInitialized) { | 338 if (mNativeInitialized) { |
| 339 findMatchAndLoadUrl(urlText); | 339 findMatchAndLoadUrl(urlText); |
| 340 } else { | 340 } else { |
| 341 mDeferredNativeRunnables.add(new Runnable() { | 341 mDeferredNativeRunnables.add(new Runnable() { |
| 342 @Override | 342 @Override |
| 343 public void run() { | 343 public void run() { |
| 344 findMatchAndLoadUrl(urlText); | 344 findMatchAndLoadUrl(urlText); |
| 345 } | 345 } |
| 346 }); | 346 }); |
| 347 } | 347 } |
| (...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1060 }); | 1060 }); |
| 1061 } | 1061 } |
| 1062 } | 1062 } |
| 1063 | 1063 |
| 1064 if (mNativeInitialized) { | 1064 if (mNativeInitialized) { |
| 1065 startZeroSuggest(); | 1065 startZeroSuggest(); |
| 1066 } else { | 1066 } else { |
| 1067 mDeferredNativeRunnables.add(new Runnable() { | 1067 mDeferredNativeRunnables.add(new Runnable() { |
| 1068 @Override | 1068 @Override |
| 1069 public void run() { | 1069 public void run() { |
| 1070 if (TextUtils.isEmpty(mUrlBar.getQueryText())) { | 1070 if (TextUtils.isEmpty(mUrlBar.getTextWithAutocomplete())) { |
| 1071 startZeroSuggest(); | 1071 startZeroSuggest(); |
| 1072 } | 1072 } |
| 1073 } | 1073 } |
| 1074 }); | 1074 }); |
| 1075 } | 1075 } |
| 1076 | 1076 |
| 1077 if (!hasFocus) { | 1077 if (!hasFocus) { |
| 1078 mHasStartedNewOmniboxEditSession = false; | 1078 mHasStartedNewOmniboxEditSession = false; |
| 1079 mNewOmniboxEditSessionTimestamp = -1; | 1079 mNewOmniboxEditSessionTimestamp = -1; |
| 1080 } | 1080 } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1108 * - The current tab is not incognito. | 1108 * - The current tab is not incognito. |
| 1109 * - Chrome Home is disabled. | 1109 * - Chrome Home is disabled. |
| 1110 */ | 1110 */ |
| 1111 private void startZeroSuggest() { | 1111 private void startZeroSuggest() { |
| 1112 // Reset "edited" state in the omnibox if zero suggest is triggered -- n
ew edits | 1112 // Reset "edited" state in the omnibox if zero suggest is triggered -- n
ew edits |
| 1113 // now count as a new session. | 1113 // now count as a new session. |
| 1114 mHasStartedNewOmniboxEditSession = false; | 1114 mHasStartedNewOmniboxEditSession = false; |
| 1115 mNewOmniboxEditSessionTimestamp = -1; | 1115 mNewOmniboxEditSessionTimestamp = -1; |
| 1116 Tab currentTab = getCurrentTab(); | 1116 Tab currentTab = getCurrentTab(); |
| 1117 if (mNativeInitialized && mUrlHasFocus && currentTab != null) { | 1117 if (mNativeInitialized && mUrlHasFocus && currentTab != null) { |
| 1118 mAutocomplete.startZeroSuggest(currentTab.getProfile(), mUrlBar.getQ
ueryText(), | 1118 mAutocomplete.startZeroSuggest(currentTab.getProfile(), |
| 1119 mToolbarDataProvider.getCurrentUrl(), mUrlFocusedFromFakebox
); | 1119 mUrlBar.getTextWithAutocomplete(), mToolbarDataProvider.getC
urrentUrl(), |
| 1120 mUrlFocusedFromFakebox); |
| 1120 } | 1121 } |
| 1121 } | 1122 } |
| 1122 | 1123 |
| 1123 @Override | 1124 @Override |
| 1124 public void onTextChangedForAutocomplete(final boolean textDeleted) { | 1125 public void onTextChangedForAutocomplete(final boolean textDeleted) { |
| 1125 cancelPendingAutocompleteStart(); | 1126 cancelPendingAutocompleteStart(); |
| 1126 | 1127 |
| 1127 updateButtonVisibility(); | 1128 updateButtonVisibility(); |
| 1128 updateNavigationButton(); | 1129 updateNavigationButton(); |
| 1129 | 1130 |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1886 * Whether {@code v} is a view (location icon, verbose status, ...) which ca
n be clicked to | 1887 * Whether {@code v} is a view (location icon, verbose status, ...) which ca
n be clicked to |
| 1887 * show the Page Info popup. | 1888 * show the Page Info popup. |
| 1888 */ | 1889 */ |
| 1889 private boolean shouldShowPageInfoForView(View v) { | 1890 private boolean shouldShowPageInfoForView(View v) { |
| 1890 return v == mSecurityButton || v == mNavigationButton || v == mVerboseSt
atusTextView; | 1891 return v == mSecurityButton || v == mNavigationButton || v == mVerboseSt
atusTextView; |
| 1891 } | 1892 } |
| 1892 | 1893 |
| 1893 @Override | 1894 @Override |
| 1894 public void onClick(View v) { | 1895 public void onClick(View v) { |
| 1895 if (v == mDeleteButton) { | 1896 if (v == mDeleteButton) { |
| 1896 if (!TextUtils.isEmpty(mUrlBar.getQueryText())) { | 1897 if (!TextUtils.isEmpty(mUrlBar.getTextWithAutocomplete())) { |
| 1897 setUrlBarText("", null); | 1898 setUrlBarText("", null); |
| 1898 hideSuggestions(); | 1899 hideSuggestions(); |
| 1899 updateButtonVisibility(); | 1900 updateButtonVisibility(); |
| 1900 } | 1901 } |
| 1901 | 1902 |
| 1902 startZeroSuggest(); | 1903 startZeroSuggest(); |
| 1903 return; | 1904 return; |
| 1904 } else if (!mUrlHasFocus && shouldShowPageInfoForView(v)) { | 1905 } else if (!mUrlHasFocus && shouldShowPageInfoForView(v)) { |
| 1905 Tab currentTab = getCurrentTab(); | 1906 Tab currentTab = getCurrentTab(); |
| 1906 if (currentTab != null && currentTab.getWebContents() != null) { | 1907 if (currentTab != null && currentTab.getWebContents() != null) { |
| (...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2511 public void setTitleToPageTitle() { } | 2512 public void setTitleToPageTitle() { } |
| 2512 | 2513 |
| 2513 @Override | 2514 @Override |
| 2514 public void setShowTitle(boolean showTitle) { } | 2515 public void setShowTitle(boolean showTitle) { } |
| 2515 | 2516 |
| 2516 @Override | 2517 @Override |
| 2517 public boolean mustQueryUrlBarLocationForSuggestions() { | 2518 public boolean mustQueryUrlBarLocationForSuggestions() { |
| 2518 return DeviceFormFactor.isTablet(); | 2519 return DeviceFormFactor.isTablet(); |
| 2519 } | 2520 } |
| 2520 } | 2521 } |
| OLD | NEW |