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

Side by Side Diff: chrome/android/java/src/org/chromium/chrome/browser/contextualsearch/ContextualSearchManager.java

Issue 1736203002: [Contextual Search] Add metrics for Resolve and View timing (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Switched to using a separate timer. Created 4 years, 9 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
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.contextualsearch; 5 package org.chromium.chrome.browser.contextualsearch;
6 6
7 import android.text.TextUtils; 7 import android.text.TextUtils;
8 import android.view.View; 8 import android.view.View;
9 import android.view.ViewGroup; 9 import android.view.ViewGroup;
10 import android.view.ViewTreeObserver; 10 import android.view.ViewTreeObserver;
(...skipping 695 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 } else if (!isHttpFailureCode(responseCode)) { 706 } else if (!isHttpFailureCode(responseCode)) {
707 message = displayText; 707 message = displayText;
708 } else if (!mPolicy.shouldShowErrorCodeInBar()) { 708 } else if (!mPolicy.shouldShowErrorCodeInBar()) {
709 message = mSelectionController.getSelectedText(); 709 message = mSelectionController.getSelectedText();
710 doLiteralSearch = true; 710 doLiteralSearch = true;
711 } else { 711 } else {
712 message = mActivity.getResources().getString( 712 message = mActivity.getResources().getString(
713 R.string.contextual_search_error, responseCode); 713 R.string.contextual_search_error, responseCode);
714 doLiteralSearch = true; 714 doLiteralSearch = true;
715 } 715 }
716 mSearchPanel.onSearchTermResolutionResponse(message); 716 mSearchPanel.onSearchTermResolved(message);
717 717
718 // If there was an error, fall back onto a literal search for the select ion. 718 // If there was an error, fall back onto a literal search for the select ion.
719 // Since we're showing the panel, there must be a selection. 719 // Since we're showing the panel, there must be a selection.
720 if (doLiteralSearch) { 720 if (doLiteralSearch) {
721 searchTerm = mSelectionController.getSelectedText(); 721 searchTerm = mSelectionController.getSelectedText();
722 alternateTerm = null; 722 alternateTerm = null;
723 doPreventPreload = true; 723 doPreventPreload = true;
724 } 724 }
725 if (!TextUtils.isEmpty(searchTerm)) { 725 if (!TextUtils.isEmpty(searchTerm)) {
726 // TODO(donnd): Instead of preloading, we should prefetch (ie the UR L should not 726 // TODO(donnd): Instead of preloading, we should prefetch (ie the UR L should not
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 if (isExternalUrl) { 837 if (isExternalUrl) {
838 onExternalNavigation(url); 838 onExternalNavigation(url);
839 } 839 }
840 } 840 }
841 841
842 @Override 842 @Override
843 public void onMainFrameNavigation(String url, boolean isExternalUrl, boo lean isFailure) { 843 public void onMainFrameNavigation(String url, boolean isExternalUrl, boo lean isFailure) {
844 if (!isExternalUrl) { 844 if (!isExternalUrl) {
845 // Could be just prefetching, check if that failed. 845 // Could be just prefetching, check if that failed.
846 onContextualSearchRequestNavigation(isFailure); 846 onContextualSearchRequestNavigation(isFailure);
847
848 // Record metrics for when the prefetched results became viewabl e.
849 if (mSearchRequest != null && mSearchRequest.wasPrefetch()) {
850 boolean didResolve =
851 mPolicy.shouldPreviousTapResolve(mNetworkCommunicato r.getBasePageUrl());
852 mSearchPanel.onPanelNavigatedToPrefetchedSearch(didResolve);
853 }
847 } 854 }
848 } 855 }
849 856
850 @Override 857 @Override
851 public void onContentLoadStarted(String url) { 858 public void onContentLoadStarted(String url) {
852 mDidPromoteSearchNavigation = false; 859 mDidPromoteSearchNavigation = false;
853 } 860 }
854 861
855 @Override 862 @Override
856 public void onContentLoadFinished() { 863 public void onContentLoadFinished() {
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 // If the request object is null that means that a Contextual Search has just started 1095 // If the request object is null that means that a Contextual Search has just started
1089 // and the Search Term Resolution response hasn't arrived yet. In this c ase, promoting 1096 // and the Search Term Resolution response hasn't arrived yet. In this c ase, promoting
1090 // the Panel to a Tab will result in creating a new tab with URL about:b lank. To prevent 1097 // the Panel to a Tab will result in creating a new tab with URL about:b lank. To prevent
1091 // this problem, we are ignoring tap gestures in the Search Bar if we do n't know what 1098 // this problem, we are ignoring tap gestures in the Search Bar if we do n't know what
1092 // to search for. 1099 // to search for.
1093 if (mSearchRequest != null 1100 if (mSearchRequest != null
1094 && mSearchPanel.getContentViewCore() != null 1101 && mSearchPanel.getContentViewCore() != null
1095 && mSearchPanel.getContentViewCore().getWebContents() != null) { 1102 && mSearchPanel.getContentViewCore().getWebContents() != null) {
1096 String url = getContentViewUrl(mSearchPanel.getContentViewCore()); 1103 String url = getContentViewUrl(mSearchPanel.getContentViewCore());
1097 1104
1098 // If it's a search URL, formats it so the SearchBox becomes visible . 1105 // If it's a search URL, format it so the SearchBox becomes visible.
1099 if (mSearchRequest.isContextualSearchUrl(url)) { 1106 if (mSearchRequest.isContextualSearchUrl(url)) {
1100 url = mSearchRequest.getSearchUrlForPromotion(); 1107 url = mSearchRequest.getSearchUrlForPromotion();
1101 } 1108 }
1102 1109
1103 if (url != null) { 1110 if (url != null) {
1104 mTabPromotionDelegate.createContextualSearchTab(url); 1111 mTabPromotionDelegate.createContextualSearchTab(url);
1105 mSearchPanel.closePanel(StateChangeReason.TAB_PROMOTION, false); 1112 mSearchPanel.closePanel(StateChangeReason.TAB_PROMOTION, false);
1106 } 1113 }
1107 } 1114 }
1108 mIsPromotingToTab = false; 1115 mIsPromotingToTab = false;
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1260 boolean maySendBasePageUrl); 1267 boolean maySendBasePageUrl);
1261 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager, 1268 protected native void nativeGatherSurroundingText(long nativeContextualSearc hManager,
1262 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore, 1269 String selection, boolean useResolvedSearchTerm, ContentViewCore bas eContentViewCore,
1263 boolean maySendBasePageUrl); 1270 boolean maySendBasePageUrl);
1264 private native void nativeEnableContextualSearchJsApiForOverlay( 1271 private native void nativeEnableContextualSearchJsApiForOverlay(
1265 long nativeContextualSearchManager, ContentViewCore overlayContentVi ewCore); 1272 long nativeContextualSearchManager, ContentViewCore overlayContentVi ewCore);
1266 // Don't call these directly, instead call the private methods that cache th e results. 1273 // Don't call these directly, instead call the private methods that cache th e results.
1267 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager); 1274 private native String nativeGetTargetLanguage(long nativeContextualSearchMan ager);
1268 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager); 1275 private native String nativeGetAcceptLanguages(long nativeContextualSearchMa nager);
1269 } 1276 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698