| 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 | 172 |
| 173 /** | 173 /** |
| 174 * The text shown in the URL bar (user text + inline autocomplete) after the
most recent set of | 174 * The text shown in the URL bar (user text + inline autocomplete) after the
most recent set of |
| 175 * omnibox suggestions was received. When the user presses enter in the omni
box, this value is | 175 * omnibox suggestions was received. When the user presses enter in the omni
box, this value is |
| 176 * compared to the URL bar text to determine whether the first suggestion is
still valid. | 176 * compared to the URL bar text to determine whether the first suggestion is
still valid. |
| 177 */ | 177 */ |
| 178 private String mUrlTextAfterSuggestionsReceived; | 178 private String mUrlTextAfterSuggestionsReceived; |
| 179 | 179 |
| 180 private boolean mIgnoreOmniboxItemSelection = true; | 180 private boolean mIgnoreOmniboxItemSelection = true; |
| 181 | 181 |
| 182 // True if we are showing the search query instead of the url. | |
| 183 private boolean mQueryInTheOmnibox = false; | |
| 184 | |
| 185 private String mOriginalUrl = ""; | 182 private String mOriginalUrl = ""; |
| 186 | 183 |
| 187 private WindowAndroid mWindowAndroid; | 184 private WindowAndroid mWindowAndroid; |
| 188 private WindowDelegate mWindowDelegate; | 185 private WindowDelegate mWindowDelegate; |
| 189 | 186 |
| 190 private Runnable mRequestSuggestions; | 187 private Runnable mRequestSuggestions; |
| 191 | 188 |
| 192 private ViewGroup mOmniboxResultsContainer; | 189 private ViewGroup mOmniboxResultsContainer; |
| 193 private ObjectAnimator mFadeInOmniboxBackgroundAnimator; | 190 private ObjectAnimator mFadeInOmniboxBackgroundAnimator; |
| 194 private ObjectAnimator mFadeOutOmniboxBackgroundAnimator; | 191 private ObjectAnimator mFadeOutOmniboxBackgroundAnimator; |
| (...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 } | 923 } |
| 927 | 924 |
| 928 if (getToolbarDataProvider().isUsingBrandColor()) { | 925 if (getToolbarDataProvider().isUsingBrandColor()) { |
| 929 updateVisualsForState(); | 926 updateVisualsForState(); |
| 930 if (mUrlHasFocus) mUrlBar.selectAll(); | 927 if (mUrlHasFocus) mUrlBar.selectAll(); |
| 931 } | 928 } |
| 932 | 929 |
| 933 changeLocationBarIcon( | 930 changeLocationBarIcon( |
| 934 (!DeviceFormFactor.isTablet(getContext()) || !hasFocus) && isSec
urityButtonShown()); | 931 (!DeviceFormFactor.isTablet(getContext()) || !hasFocus) && isSec
urityButtonShown()); |
| 935 mUrlBar.setCursorVisible(hasFocus); | 932 mUrlBar.setCursorVisible(hasFocus); |
| 936 if (mQueryInTheOmnibox) mUrlBar.setSelection(mUrlBar.getSelectionEnd()); | |
| 937 | 933 |
| 938 if (!mUrlFocusedWithoutAnimations) handleUrlFocusAnimation(hasFocus); | 934 if (!mUrlFocusedWithoutAnimations) handleUrlFocusAnimation(hasFocus); |
| 939 | 935 |
| 940 if (hasFocus && currentTab != null && !currentTab.isIncognito()) { | 936 if (hasFocus && currentTab != null && !currentTab.isIncognito()) { |
| 941 if (mNativeInitialized | 937 if (mNativeInitialized |
| 942 && TemplateUrlService.getInstance().isDefaultSearchEngineGoo
gle()) { | 938 && TemplateUrlService.getInstance().isDefaultSearchEngineGoo
gle()) { |
| 943 GeolocationHeader.primeLocationForGeoHeader(getContext()); | 939 GeolocationHeader.primeLocationForGeoHeader(getContext()); |
| 944 } else { | 940 } else { |
| 945 mDeferredNativeRunnables.add(new Runnable() { | 941 mDeferredNativeRunnables.add(new Runnable() { |
| 946 @Override | 942 @Override |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1001 // Reset "edited" state in the omnibox if zero suggest is triggered -- n
ew edits | 997 // Reset "edited" state in the omnibox if zero suggest is triggered -- n
ew edits |
| 1002 // now count as a new session. | 998 // now count as a new session. |
| 1003 mHasStartedNewOmniboxEditSession = false; | 999 mHasStartedNewOmniboxEditSession = false; |
| 1004 mNewOmniboxEditSessionTimestamp = -1; | 1000 mNewOmniboxEditSessionTimestamp = -1; |
| 1005 Tab currentTab = getCurrentTab(); | 1001 Tab currentTab = getCurrentTab(); |
| 1006 if (mNativeInitialized | 1002 if (mNativeInitialized |
| 1007 && mUrlHasFocus | 1003 && mUrlHasFocus |
| 1008 && currentTab != null | 1004 && currentTab != null |
| 1009 && !currentTab.isIncognito()) { | 1005 && !currentTab.isIncognito()) { |
| 1010 mAutocomplete.startZeroSuggest(currentTab.getProfile(), mUrlBar.getQ
ueryText(), | 1006 mAutocomplete.startZeroSuggest(currentTab.getProfile(), mUrlBar.getQ
ueryText(), |
| 1011 currentTab.getUrl(), mQueryInTheOmnibox, mUrlFocusedFromFake
box); | 1007 currentTab.getUrl(), mUrlFocusedFromFakebox); |
| 1012 } | 1008 } |
| 1013 } | 1009 } |
| 1014 | 1010 |
| 1015 @Override | 1011 @Override |
| 1016 public void onTextChangedForAutocomplete(final boolean textDeleted) { | 1012 public void onTextChangedForAutocomplete(final boolean textDeleted) { |
| 1017 cancelPendingAutocompleteStart(); | 1013 cancelPendingAutocompleteStart(); |
| 1018 | 1014 |
| 1019 updateButtonVisibility(); | 1015 updateButtonVisibility(); |
| 1020 updateNavigationButton(); | 1016 updateNavigationButton(); |
| 1021 | 1017 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1065 @Override | 1061 @Override |
| 1066 public void setDefaultTextEditActionModeCallback(ToolbarActionModeCallback c
allback) { | 1062 public void setDefaultTextEditActionModeCallback(ToolbarActionModeCallback c
allback) { |
| 1067 mDefaultActionModeCallbackForTextEdit = callback; | 1063 mDefaultActionModeCallbackForTextEdit = callback; |
| 1068 } | 1064 } |
| 1069 | 1065 |
| 1070 /** | 1066 /** |
| 1071 * If query in the omnibox, sets UrlBar's ActionModeCallback to show copy ur
l button. Else, | 1067 * If query in the omnibox, sets UrlBar's ActionModeCallback to show copy ur
l button. Else, |
| 1072 * it is set to the default one. | 1068 * it is set to the default one. |
| 1073 */ | 1069 */ |
| 1074 private void updateCustomSelectionActionModeCallback() { | 1070 private void updateCustomSelectionActionModeCallback() { |
| 1075 if (mQueryInTheOmnibox) { | 1071 mUrlBar.setCustomSelectionActionModeCallback(mDefaultActionModeCallbackF
orTextEdit); |
| 1076 mUrlBar.setCustomSelectionActionModeCallback( | |
| 1077 mActionModeController.getActionModeCallback()); | |
| 1078 } else { | |
| 1079 mUrlBar.setCustomSelectionActionModeCallback(mDefaultActionModeCallb
ackForTextEdit); | |
| 1080 } | |
| 1081 } | 1072 } |
| 1082 | 1073 |
| 1083 @Override | 1074 @Override |
| 1084 public void requestUrlFocusFromFakebox(String pastedText) { | 1075 public void requestUrlFocusFromFakebox(String pastedText) { |
| 1085 mUrlFocusedFromFakebox = true; | 1076 mUrlFocusedFromFakebox = true; |
| 1086 if (mUrlHasFocus && mUrlFocusedWithoutAnimations) { | 1077 if (mUrlHasFocus && mUrlFocusedWithoutAnimations) { |
| 1087 handleUrlFocusAnimation(mUrlHasFocus); | 1078 handleUrlFocusAnimation(mUrlHasFocus); |
| 1088 } else { | 1079 } else { |
| 1089 setUrlBarFocus(true); | 1080 setUrlBarFocus(true); |
| 1090 } | 1081 } |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 } | 1145 } |
| 1155 | 1146 |
| 1156 // Updates the navigation button based on the URL string | 1147 // Updates the navigation button based on the URL string |
| 1157 private void updateNavigationButton() { | 1148 private void updateNavigationButton() { |
| 1158 boolean isTablet = DeviceFormFactor.isTablet(getContext()); | 1149 boolean isTablet = DeviceFormFactor.isTablet(getContext()); |
| 1159 NavigationButtonType type = NavigationButtonType.EMPTY; | 1150 NavigationButtonType type = NavigationButtonType.EMPTY; |
| 1160 if (isTablet && !mSuggestionItems.isEmpty()) { | 1151 if (isTablet && !mSuggestionItems.isEmpty()) { |
| 1161 // If there are suggestions showing, show the icon for the default s
uggestion. | 1152 // If there are suggestions showing, show the icon for the default s
uggestion. |
| 1162 type = suggestionTypeToNavigationButtonType( | 1153 type = suggestionTypeToNavigationButtonType( |
| 1163 mSuggestionItems.get(0).getSuggestion()); | 1154 mSuggestionItems.get(0).getSuggestion()); |
| 1164 } else if (mQueryInTheOmnibox) { | |
| 1165 type = NavigationButtonType.MAGNIFIER; | |
| 1166 } else if (!mUrlHasFocus && getCurrentTab() != null && getCurrentTab().i
sOfflinePage()) { | 1155 } else if (!mUrlHasFocus && getCurrentTab() != null && getCurrentTab().i
sOfflinePage()) { |
| 1167 type = NavigationButtonType.OFFLINE; | 1156 type = NavigationButtonType.OFFLINE; |
| 1168 } else if (isTablet) { | 1157 } else if (isTablet) { |
| 1169 type = NavigationButtonType.PAGE; | 1158 type = NavigationButtonType.PAGE; |
| 1170 } | 1159 } |
| 1171 | 1160 |
| 1172 if (type != mNavigationButtonType) setNavigationButtonType(type); | 1161 if (type != mNavigationButtonType) setNavigationButtonType(type); |
| 1173 } | 1162 } |
| 1174 | 1163 |
| 1175 /** | |
| 1176 * @return Whether the query is shown in the omnibox instead of the url. | |
| 1177 */ | |
| 1178 public boolean showingQueryInTheOmnibox() { | |
| 1179 return mQueryInTheOmnibox; | |
| 1180 } | |
| 1181 | |
| 1182 private int getSecurityLevel() { | 1164 private int getSecurityLevel() { |
| 1183 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; | 1165 if (getCurrentTab() == null) return ConnectionSecurityLevel.NONE; |
| 1184 return getCurrentTab().getSecurityLevel(); | 1166 return getCurrentTab().getSecurityLevel(); |
| 1185 } | 1167 } |
| 1186 | 1168 |
| 1187 /** | 1169 /** |
| 1188 * Determines the icon that should be displayed for the current security lev
el. | 1170 * Determines the icon that should be displayed for the current security lev
el. |
| 1189 * @param securityLevel The security level for which the resource will be re
turned. | 1171 * @param securityLevel The security level for which the resource will be re
turned. |
| 1190 * @param usingLightTheme Whether light themed security assets should be use
d. | 1172 * @param usingLightTheme Whether light themed security assets should be use
d. |
| 1191 * @return The resource ID of the icon that should be displayed, 0 if no ico
n should show. | 1173 * @return The resource ID of the icon that should be displayed, 0 if no ico
n should show. |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1206 assert false; | 1188 assert false; |
| 1207 } | 1189 } |
| 1208 return 0; | 1190 return 0; |
| 1209 } | 1191 } |
| 1210 | 1192 |
| 1211 /** | 1193 /** |
| 1212 * Updates the security icon displayed in the LocationBar. | 1194 * Updates the security icon displayed in the LocationBar. |
| 1213 */ | 1195 */ |
| 1214 @Override | 1196 @Override |
| 1215 public void updateSecurityIcon(int securityLevel) { | 1197 public void updateSecurityIcon(int securityLevel) { |
| 1216 if (mQueryInTheOmnibox) { | |
| 1217 if (securityLevel == ConnectionSecurityLevel.SECURE | |
| 1218 || securityLevel == ConnectionSecurityLevel.EV_SECURE) { | |
| 1219 securityLevel = ConnectionSecurityLevel.NONE; | |
| 1220 } else if (securityLevel == ConnectionSecurityLevel.SECURITY_WARNING | |
| 1221 || securityLevel == ConnectionSecurityLevel.SECURITY_ERROR)
{ | |
| 1222 setUrlToPageUrl(); | |
| 1223 } | |
| 1224 } | |
| 1225 int id = getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsSch
eme()); | 1198 int id = getSecurityIconResource(securityLevel, !shouldEmphasizeHttpsSch
eme()); |
| 1226 // ImageView#setImageResource is no-op if given resource is the current
one. | 1199 // ImageView#setImageResource is no-op if given resource is the current
one. |
| 1227 if (id == 0) { | 1200 if (id == 0) { |
| 1228 mSecurityButton.setImageDrawable(null); | 1201 mSecurityButton.setImageDrawable(null); |
| 1229 } else { | 1202 } else { |
| 1230 mSecurityButton.setImageResource(id); | 1203 mSecurityButton.setImageResource(id); |
| 1231 } | 1204 } |
| 1232 | 1205 |
| 1233 boolean shouldEmphasizeHttpsScheme = shouldEmphasizeHttpsScheme(); | 1206 boolean shouldEmphasizeHttpsScheme = shouldEmphasizeHttpsScheme(); |
| 1234 if (mSecurityIconType == securityLevel | 1207 if (mSecurityIconType == securityLevel |
| 1235 && mIsEmphasizingHttpsScheme == shouldEmphasizeHttpsScheme) { | 1208 && mIsEmphasizingHttpsScheme == shouldEmphasizeHttpsScheme) { |
| 1236 return; | 1209 return; |
| 1237 } | 1210 } |
| 1238 mSecurityIconType = securityLevel; | 1211 mSecurityIconType = securityLevel; |
| 1239 | 1212 |
| 1240 if (securityLevel == ConnectionSecurityLevel.NONE) { | 1213 if (securityLevel == ConnectionSecurityLevel.NONE) { |
| 1241 updateSecurityButton(false); | 1214 updateSecurityButton(false); |
| 1242 } else { | 1215 } else { |
| 1243 updateSecurityButton(true); | 1216 updateSecurityButton(true); |
| 1244 } | 1217 } |
| 1245 // Since we emphasize the schema of the URL based on the security type,
we need to | 1218 // Since we emphasize the schema of the URL based on the security type,
we need to |
| 1246 // refresh the emphasis. | 1219 // refresh the emphasis. |
| 1247 mUrlBar.deEmphasizeUrl(); | 1220 mUrlBar.deEmphasizeUrl(); |
| 1248 emphasizeUrl(); | 1221 emphasizeUrl(); |
| 1249 mIsEmphasizingHttpsScheme = shouldEmphasizeHttpsScheme; | 1222 mIsEmphasizingHttpsScheme = shouldEmphasizeHttpsScheme; |
| 1250 } | 1223 } |
| 1251 | 1224 |
| 1252 private void emphasizeUrl() { | 1225 private void emphasizeUrl() { |
| 1253 if (!mQueryInTheOmnibox) mUrlBar.emphasizeUrl(); | 1226 mUrlBar.emphasizeUrl(); |
| 1254 } | 1227 } |
| 1255 | 1228 |
| 1256 @Override | 1229 @Override |
| 1257 public boolean shouldEmphasizeHttpsScheme() { | 1230 public boolean shouldEmphasizeHttpsScheme() { |
| 1258 int securityLevel = getSecurityLevel(); | 1231 int securityLevel = getSecurityLevel(); |
| 1259 if (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR | 1232 if (securityLevel == ConnectionSecurityLevel.SECURITY_ERROR |
| 1260 || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING | 1233 || securityLevel == ConnectionSecurityLevel.SECURITY_WARNING |
| 1261 || securityLevel == ConnectionSecurityLevel.SECURITY_POLICY_WARN
ING) { | 1234 || securityLevel == ConnectionSecurityLevel.SECURITY_POLICY_WARN
ING) { |
| 1262 return true; | 1235 return true; |
| 1263 } | 1236 } |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1604 * @param selectedIndex The index of the chosen omnibox suggestion. | 1577 * @param selectedIndex The index of the chosen omnibox suggestion. |
| 1605 * @return The url to navigate to. | 1578 * @return The url to navigate to. |
| 1606 */ | 1579 */ |
| 1607 private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int
selectedIndex) { | 1580 private String updateSuggestionUrlIfNeeded(OmniboxSuggestion suggestion, int
selectedIndex) { |
| 1608 // Only called once we have suggestions, and don't have a listener thoug
h which we can | 1581 // Only called once we have suggestions, and don't have a listener thoug
h which we can |
| 1609 // receive suggestions until the native side is ready, so this is safe | 1582 // receive suggestions until the native side is ready, so this is safe |
| 1610 assert mNativeInitialized | 1583 assert mNativeInitialized |
| 1611 : "updateSuggestionUrlIfNeeded called before native initializati
on"; | 1584 : "updateSuggestionUrlIfNeeded called before native initializati
on"; |
| 1612 | 1585 |
| 1613 String updatedUrl = null; | 1586 String updatedUrl = null; |
| 1614 // Only replace URL queries for corpus search refinements, this does not
work well | 1587 if (suggestion.getType() != OmniboxSuggestionType.VOICE_SUGGEST) { |
| 1615 // for regular web searches. | |
| 1616 // TODO(mariakhomenko): improve efficiency by just checking whether corp
us exists. | |
| 1617 if (mQueryInTheOmnibox && !suggestion.isUrlSuggestion() | |
| 1618 && !TextUtils.isEmpty(mToolbarDataProvider.getCorpusChipText()))
{ | |
| 1619 String query = suggestion.getFillIntoEdit(); | |
| 1620 Tab currentTab = getCurrentTab(); | |
| 1621 if (currentTab != null && !TextUtils.isEmpty(currentTab.getUrl()) | |
| 1622 && !TextUtils.isEmpty(query)) { | |
| 1623 updatedUrl = TemplateUrlService.getInstance().replaceSearchTerms
InUrl( | |
| 1624 query, currentTab.getUrl()); | |
| 1625 } | |
| 1626 } else if (suggestion.getType() != OmniboxSuggestionType.VOICE_SUGGEST)
{ | |
| 1627 // TODO(mariakhomenko): Ideally we want to update match destination
URL with new aqs | 1588 // TODO(mariakhomenko): Ideally we want to update match destination
URL with new aqs |
| 1628 // for query in the omnibox and voice suggestions, but it's currentl
y difficult to do. | 1589 // for query in the omnibox and voice suggestions, but it's currentl
y difficult to do. |
| 1629 long elapsedTimeSinceInputChange = mNewOmniboxEditSessionTimestamp >
0 | 1590 long elapsedTimeSinceInputChange = mNewOmniboxEditSessionTimestamp >
0 |
| 1630 ? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTim
estamp) : -1; | 1591 ? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTim
estamp) : -1; |
| 1631 updatedUrl = mAutocomplete.updateMatchDestinationUrlWithQueryFormula
tionTime( | 1592 updatedUrl = mAutocomplete.updateMatchDestinationUrlWithQueryFormula
tionTime( |
| 1632 selectedIndex, elapsedTimeSinceInputChange); | 1593 selectedIndex, elapsedTimeSinceInputChange); |
| 1633 } | 1594 } |
| 1634 | 1595 |
| 1635 return updatedUrl == null ? suggestion.getUrl() : updatedUrl; | 1596 return updatedUrl == null ? suggestion.getUrl() : updatedUrl; |
| 1636 } | 1597 } |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1997 if (mUrlFocusedWithoutAnimations && !NewTabPage.isNTPUrl(url)) { | 1958 if (mUrlFocusedWithoutAnimations && !NewTabPage.isNTPUrl(url)) { |
| 1998 // If we did not run the focus animations, then the user has not
typed any text. | 1959 // If we did not run the focus animations, then the user has not
typed any text. |
| 1999 // So, clear the focus and accept whatever URL the page is curre
ntly attempting to | 1960 // So, clear the focus and accept whatever URL the page is curre
ntly attempting to |
| 2000 // display. | 1961 // display. |
| 2001 setUrlBarFocus(false); | 1962 setUrlBarFocus(false); |
| 2002 } else { | 1963 } else { |
| 2003 return; | 1964 return; |
| 2004 } | 1965 } |
| 2005 } | 1966 } |
| 2006 | 1967 |
| 2007 mQueryInTheOmnibox = false; | |
| 2008 | |
| 2009 if (getCurrentTab() == null) { | 1968 if (getCurrentTab() == null) { |
| 2010 setUrlBarText("", null); | 1969 setUrlBarText("", null); |
| 2011 return; | 1970 return; |
| 2012 } | 1971 } |
| 2013 | 1972 |
| 2014 // Profile may be null if switching to a tab that has not yet been initi
alized. | 1973 // Profile may be null if switching to a tab that has not yet been initi
alized. |
| 2015 Profile profile = getCurrentTab().getProfile(); | 1974 Profile profile = getCurrentTab().getProfile(); |
| 2016 if (profile != null) mOmniboxPrerender.clear(profile); | 1975 if (profile != null) mOmniboxPrerender.clear(profile); |
| 2017 | 1976 |
| 2018 mOriginalUrl = url; | 1977 mOriginalUrl = url; |
| 2019 | 1978 |
| 2020 if (NativePageFactory.isNativePageUrl(url, getCurrentTab().isIncognito()
) | 1979 if (NativePageFactory.isNativePageUrl(url, getCurrentTab().isIncognito()
) |
| 2021 || NewTabPage.isNTPUrl(url)) { | 1980 || NewTabPage.isNTPUrl(url)) { |
| 2022 // Don't show anything for Chrome URLs. | 1981 // Don't show anything for Chrome URLs. |
| 2023 setUrlBarText(null, ""); | 1982 setUrlBarText(null, ""); |
| 2024 return; | 1983 return; |
| 2025 } | 1984 } |
| 2026 | 1985 |
| 2027 boolean showingQuery = false; | 1986 if (setUrlBarText(url, mToolbarDataProvider.getText())) { |
| 2028 String displayText = mToolbarDataProvider.getText(); | |
| 2029 if (!TextUtils.isEmpty(displayText) && mToolbarDataProvider.wouldReplace
URL()) { | |
| 2030 if (getSecurityLevel() == ConnectionSecurityLevel.SECURITY_ERROR) { | |
| 2031 assert false : "Search terms should not be shown for https error
pages."; | |
| 2032 displayText = url; | |
| 2033 } else { | |
| 2034 url = displayText.trim(); | |
| 2035 showingQuery = true; | |
| 2036 mQueryInTheOmnibox = true; | |
| 2037 } | |
| 2038 } | |
| 2039 | |
| 2040 if (setUrlBarText(url, displayText)) { | |
| 2041 mUrlBar.deEmphasizeUrl(); | 1987 mUrlBar.deEmphasizeUrl(); |
| 2042 emphasizeUrl(); | 1988 emphasizeUrl(); |
| 2043 } | 1989 } |
| 2044 if (showingQuery) { | |
| 2045 updateNavigationButton(); | |
| 2046 } | |
| 2047 updateCustomSelectionActionModeCallback(); | 1990 updateCustomSelectionActionModeCallback(); |
| 2048 } | 1991 } |
| 2049 | 1992 |
| 2050 /** | 1993 /** |
| 2051 * Gets the URL of the web page in the tab. When displaying offline page it
gets the URL of the | 1994 * Gets the URL of the web page in the tab. When displaying offline page it
gets the URL of the |
| 2052 * original page. | 1995 * original page. |
| 2053 */ | 1996 */ |
| 2054 private String getOnlineUrlFromTab() { | 1997 private String getOnlineUrlFromTab() { |
| 2055 Tab currentTab = getCurrentTab(); | 1998 Tab currentTab = getCurrentTab(); |
| 2056 if (currentTab == null) return ""; | 1999 if (currentTab == null) return ""; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2076 private void loadUrlFromOmniboxMatch(String url, int transition, int matchPo
sition, int type) { | 2019 private void loadUrlFromOmniboxMatch(String url, int transition, int matchPo
sition, int type) { |
| 2077 // loadUrl modifies AutocompleteController's state clearing the native | 2020 // loadUrl modifies AutocompleteController's state clearing the native |
| 2078 // AutocompleteResults needed by onSuggestionsSelected. Therefore, | 2021 // AutocompleteResults needed by onSuggestionsSelected. Therefore, |
| 2079 // loadUrl should should be invoked last. | 2022 // loadUrl should should be invoked last. |
| 2080 Tab currentTab = getCurrentTab(); | 2023 Tab currentTab = getCurrentTab(); |
| 2081 String currentPageUrl = currentTab != null ? currentTab.getUrl() : ""; | 2024 String currentPageUrl = currentTab != null ? currentTab.getUrl() : ""; |
| 2082 WebContents webContents = currentTab != null ? currentTab.getWebContents
() : null; | 2025 WebContents webContents = currentTab != null ? currentTab.getWebContents
() : null; |
| 2083 long elapsedTimeSinceModified = mNewOmniboxEditSessionTimestamp > 0 | 2026 long elapsedTimeSinceModified = mNewOmniboxEditSessionTimestamp > 0 |
| 2084 ? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTimesta
mp) : -1; | 2027 ? (SystemClock.elapsedRealtime() - mNewOmniboxEditSessionTimesta
mp) : -1; |
| 2085 mAutocomplete.onSuggestionSelected(matchPosition, type, currentPageUrl, | 2028 mAutocomplete.onSuggestionSelected(matchPosition, type, currentPageUrl, |
| 2086 mQueryInTheOmnibox, mUrlFocusedFromFakebox, elapsedTimeSinceModi
fied, | 2029 mUrlFocusedFromFakebox, elapsedTimeSinceModified, mUrlBar.getAut
ocompleteLength(), |
| 2087 mUrlBar.getAutocompleteLength(), webContents); | 2030 webContents); |
| 2088 loadUrl(url, transition); | 2031 loadUrl(url, transition); |
| 2089 } | 2032 } |
| 2090 | 2033 |
| 2091 private void loadUrl(String url, int transition) { | 2034 private void loadUrl(String url, int transition) { |
| 2092 Tab currentTab = getCurrentTab(); | 2035 Tab currentTab = getCurrentTab(); |
| 2093 | 2036 |
| 2094 // The code of the rest of this class ensures that this can't be called
until the native | 2037 // The code of the rest of this class ensures that this can't be called
until the native |
| 2095 // side is initialized | 2038 // side is initialized |
| 2096 assert mNativeInitialized : "Loading URL before native side initialized"
; | 2039 assert mNativeInitialized : "Loading URL before native side initialized"
; |
| 2097 | 2040 |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2446 public View getContainerView() { | 2389 public View getContainerView() { |
| 2447 return this; | 2390 return this; |
| 2448 } | 2391 } |
| 2449 | 2392 |
| 2450 @Override | 2393 @Override |
| 2451 public void setTitleToPageTitle() { } | 2394 public void setTitleToPageTitle() { } |
| 2452 | 2395 |
| 2453 @Override | 2396 @Override |
| 2454 public void setShowTitle(boolean showTitle) { } | 2397 public void setShowTitle(boolean showTitle) { } |
| 2455 } | 2398 } |
| OLD | NEW |