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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/LocationBarLayout.java

Issue 2900463002: [Home] Add some NTP UI polish (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/phone/SimpleAnimationLayout.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 updateOmniboxResultsContainer(); 1100 updateOmniboxResultsContainer();
1101 if (hasFocus) updateFadingBackgroundView(true); 1101 if (hasFocus) updateFadingBackgroundView(true);
1102 } 1102 }
1103 1103
1104 /** 1104 /**
1105 * Make a zero suggest request if: 1105 * Make a zero suggest request if:
1106 * - Native is loaded. 1106 * - Native is loaded.
1107 * - The URL bar has focus. 1107 * - The URL bar has focus.
1108 * - The current tab is not incognito. 1108 * - The current tab is not incognito.
1109 * - Chrome Home is disabled.
1110 */ 1109 */
1111 private void startZeroSuggest() { 1110 private void startZeroSuggest() {
1112 // Reset "edited" state in the omnibox if zero suggest is triggered -- n ew edits 1111 // Reset "edited" state in the omnibox if zero suggest is triggered -- n ew edits
1113 // now count as a new session. 1112 // now count as a new session.
1114 mHasStartedNewOmniboxEditSession = false; 1113 mHasStartedNewOmniboxEditSession = false;
1115 mNewOmniboxEditSessionTimestamp = -1; 1114 mNewOmniboxEditSessionTimestamp = -1;
1116 Tab currentTab = getCurrentTab(); 1115 Tab currentTab = getCurrentTab();
1117 if (mNativeInitialized && mUrlHasFocus && currentTab != null) { 1116 if (mNativeInitialized && mUrlHasFocus && currentTab != null) {
1118 mAutocomplete.startZeroSuggest(currentTab.getProfile(), 1117 mAutocomplete.startZeroSuggest(currentTab.getProfile(),
1119 mUrlBar.getTextWithAutocomplete(), mToolbarDataProvider.getC urrentUrl(), 1118 mUrlBar.getTextWithAutocomplete(), mToolbarDataProvider.getC urrentUrl(),
(...skipping 24 matching lines...) Expand all
1144 startZeroSuggest(); 1143 startZeroSuggest();
1145 } else { 1144 } else {
1146 assert mRequestSuggestions == null : "Multiple omnibox requests in f light."; 1145 assert mRequestSuggestions == null : "Multiple omnibox requests in f light.";
1147 mRequestSuggestions = new Runnable() { 1146 mRequestSuggestions = new Runnable() {
1148 @Override 1147 @Override
1149 public void run() { 1148 public void run() {
1150 String textWithoutAutocomplete = mUrlBar.getTextWithoutAutoc omplete(); 1149 String textWithoutAutocomplete = mUrlBar.getTextWithoutAutoc omplete();
1151 1150
1152 boolean preventAutocomplete = textDeleted || !mUrlBar.should Autocomplete(); 1151 boolean preventAutocomplete = textDeleted || !mUrlBar.should Autocomplete();
1153 mRequestSuggestions = null; 1152 mRequestSuggestions = null;
1154 if (getCurrentTab() == null) return; 1153
1155 mAutocomplete.start( 1154 if (getCurrentTab() == null
1156 getCurrentTab().getProfile(), 1155 && (mBottomSheet == null || mToolbarDataProvider.isI ncognito())) {
1157 getCurrentTab().getUrl(), 1156 return;
1158 textWithoutAutocomplete, preventAutocomplete); 1157 }
1158
1159 // If the bottom sheet is not null, the current tab will be null when the
1160 // NTP UI is showing. Use the original profile rather than t he tab profile
1161 // in that scenario.
1162 Profile profile = getCurrentTab() != null
1163 ? getCurrentTab().getProfile()
1164 : Profile.getLastUsedProfile().getOriginalProfile();
1165 String url = getCurrentTab() != null ? getCurrentTab().getUr l()
1166 : UrlConstants.NTP_URL;
1167 mAutocomplete.start(profile, url, textWithoutAutocomplete, p reventAutocomplete);
1159 } 1168 }
1160 }; 1169 };
1161 if (mNativeInitialized) { 1170 if (mNativeInitialized) {
1162 postDelayed(mRequestSuggestions, OMNIBOX_SUGGESTION_START_DELAY_ MS); 1171 postDelayed(mRequestSuggestions, OMNIBOX_SUGGESTION_START_DELAY_ MS);
1163 } else { 1172 } else {
1164 mDeferredNativeRunnables.add(mRequestSuggestions); 1173 mDeferredNativeRunnables.add(mRequestSuggestions);
1165 } 1174 }
1166 } 1175 }
1167 1176
1168 // Occasionally, was seeing the selection in the URL not being cleared d uring 1177 // Occasionally, was seeing the selection in the URL not being cleared d uring
(...skipping 698 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 return; 1876 return;
1868 } 1877 }
1869 1878
1870 setUrlBarText(query, null); 1879 setUrlBarText(query, null);
1871 mUrlBar.setSelection(0, mUrlBar.getText().length()); 1880 mUrlBar.setSelection(0, mUrlBar.getText().length());
1872 setUrlBarFocus(true); 1881 setUrlBarFocus(true);
1873 stopAutocomplete(false); 1882 stopAutocomplete(false);
1874 if (getCurrentTab() != null) { 1883 if (getCurrentTab() != null) {
1875 mAutocomplete.start( 1884 mAutocomplete.start(
1876 getCurrentTab().getProfile(), getCurrentTab().getUrl(), quer y, false); 1885 getCurrentTab().getProfile(), getCurrentTab().getUrl(), quer y, false);
1886 } else if (mBottomSheet != null && !mToolbarDataProvider.isIncognito()) {
1887 mAutocomplete.start(Profile.getLastUsedProfile().getOriginalProfile( ),
1888 UrlConstants.NTP_URL, query, false);
1877 } 1889 }
1878 post(new Runnable() { 1890 post(new Runnable() {
1879 @Override 1891 @Override
1880 public void run() { 1892 public void run() {
1881 UiUtils.showKeyboard(mUrlBar); 1893 UiUtils.showKeyboard(mUrlBar);
1882 } 1894 }
1883 }); 1895 });
1884 } 1896 }
1885 1897
1886 /** 1898 /**
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
2004 } else { 2016 } else {
2005 postDelayed(mShowSuggestions, ToolbarPhone.URL_FOCUS_CHANGE_ANIM ATION_DURATION_MS); 2017 postDelayed(mShowSuggestions, ToolbarPhone.URL_FOCUS_CHANGE_ANIM ATION_DURATION_MS);
2006 } 2018 }
2007 } 2019 }
2008 2020
2009 // Update the navigation button to show the default suggestion's icon. 2021 // Update the navigation button to show the default suggestion's icon.
2010 updateNavigationButton(); 2022 updateNavigationButton();
2011 2023
2012 if (mNativeInitialized 2024 if (mNativeInitialized
2013 && !CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_I NSTANT) 2025 && !CommandLine.getInstance().hasSwitch(ChromeSwitches.DISABLE_I NSTANT)
2014 && PrivacyPreferencesManager.getInstance().shouldPrerender()) { 2026 && PrivacyPreferencesManager.getInstance().shouldPrerender()
2027 && getCurrentTab() != null) {
2015 mOmniboxPrerender.prerenderMaybe( 2028 mOmniboxPrerender.prerenderMaybe(
2016 userText, 2029 userText,
2017 getOriginalUrl(), 2030 getOriginalUrl(),
2018 mAutocomplete.getCurrentNativeAutocompleteResult(), 2031 mAutocomplete.getCurrentNativeAutocompleteResult(),
2019 getCurrentTab().getProfile(), 2032 getCurrentTab().getProfile(),
2020 getCurrentTab()); 2033 getCurrentTab());
2021 } 2034 }
2022 } 2035 }
2023 2036
2024 @Override 2037 @Override
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
2512 public void setTitleToPageTitle() { } 2525 public void setTitleToPageTitle() { }
2513 2526
2514 @Override 2527 @Override
2515 public void setShowTitle(boolean showTitle) { } 2528 public void setShowTitle(boolean showTitle) { }
2516 2529
2517 @Override 2530 @Override
2518 public boolean mustQueryUrlBarLocationForSuggestions() { 2531 public boolean mustQueryUrlBarLocationForSuggestions() {
2519 return DeviceFormFactor.isTablet(); 2532 return DeviceFormFactor.isTablet();
2520 } 2533 }
2521 } 2534 }
OLDNEW
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/compositor/layouts/phone/SimpleAnimationLayout.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698