| 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.compositor.bottombar.contextualsearch; | 5 package org.chromium.chrome.browser.compositor.bottombar.contextualsearch; |
| 6 | 6 |
| 7 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; | 7 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.PanelState; |
| 8 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
Reason; | 8 import org.chromium.chrome.browser.compositor.bottombar.OverlayPanel.StateChange
Reason; |
| 9 import org.chromium.chrome.browser.contextualsearch.ContextualSearchBlacklist.Bl
acklistReason; | 9 import org.chromium.chrome.browser.contextualsearch.ContextualSearchBlacklist.Bl
acklistReason; |
| 10 import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics; | 10 import org.chromium.chrome.browser.contextualsearch.ContextualSearchHeuristics; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 private boolean mWasSearchContentViewSeen; | 30 private boolean mWasSearchContentViewSeen; |
| 31 private boolean mIsPromoActive; | 31 private boolean mIsPromoActive; |
| 32 private boolean mHasExpanded; | 32 private boolean mHasExpanded; |
| 33 private boolean mHasMaximized; | 33 private boolean mHasMaximized; |
| 34 private boolean mHasExitedPeeking; | 34 private boolean mHasExitedPeeking; |
| 35 private boolean mHasExitedExpanded; | 35 private boolean mHasExitedExpanded; |
| 36 private boolean mHasExitedMaximized; | 36 private boolean mHasExitedMaximized; |
| 37 private boolean mIsSerpNavigation; | 37 private boolean mIsSerpNavigation; |
| 38 private boolean mWasActivatedByTap; | 38 private boolean mWasActivatedByTap; |
| 39 private boolean mWasPanelOpenedBeyondPeek; | 39 private boolean mWasPanelOpenedBeyondPeek; |
| 40 private boolean mWasSelectionPartOfUrl; | |
| 41 private boolean mWasContextualCardsDataShown; | 40 private boolean mWasContextualCardsDataShown; |
| 42 private boolean mWasQuickActionShown; | 41 private boolean mWasQuickActionShown; |
| 43 private int mQuickActionCategory; | 42 private int mQuickActionCategory; |
| 44 private boolean mWasQuickActionClicked; | 43 private boolean mWasQuickActionClicked; |
| 45 private boolean mWasSelectionAllCaps; | |
| 46 private boolean mDidSelectionStartWithCapital; | 44 private boolean mDidSelectionStartWithCapital; |
| 47 private char mSelectionFirstChar; | 45 private char mSelectionFirstChar; |
| 48 private int mSelectionLength; | 46 private int mSelectionLength; |
| 49 // Whether any Tap suppression heuristic was satisfied when the panel was sh
own. | 47 // Whether any Tap suppression heuristic was satisfied when the panel was sh
own. |
| 50 private boolean mWasAnyHeuristicSatisfiedOnPanelShow; | 48 private boolean mWasAnyHeuristicSatisfiedOnPanelShow; |
| 51 // Time when the panel was triggered (not reset by a chained search). | 49 // Time when the panel was triggered (not reset by a chained search). |
| 52 // Panel transitions are animated so mPanelTriggerTimeNs will be less than m
FirstPeekTimeNs. | 50 // Panel transitions are animated so mPanelTriggerTimeNs will be less than m
FirstPeekTimeNs. |
| 53 private long mPanelTriggerTimeFromTapNs; | 51 private long mPanelTriggerTimeFromTapNs; |
| 54 // Time when the panel peeks into view (not reset by a chained search). | 52 // Time when the panel peeks into view (not reset by a chained search). |
| 55 // Used to log total time the panel is showing (not closed). | 53 // Used to log total time the panel is showing (not closed). |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // Measure duration only when the promo is not involved. | 112 // Measure duration only when the promo is not involved. |
| 115 ContextualSearchUma.logDuration(mWasSearchContentViewSeen, isCha
ined, durationMs); | 113 ContextualSearchUma.logDuration(mWasSearchContentViewSeen, isCha
ined, durationMs); |
| 116 } | 114 } |
| 117 if (mIsPromoActive) { | 115 if (mIsPromoActive) { |
| 118 // The user is exiting still in the promo, without choosing an o
ption. | 116 // The user is exiting still in the promo, without choosing an o
ption. |
| 119 ContextualSearchUma.logPromoSeen(mWasSearchContentViewSeen, mWas
ActivatedByTap); | 117 ContextualSearchUma.logPromoSeen(mWasSearchContentViewSeen, mWas
ActivatedByTap); |
| 120 } else { | 118 } else { |
| 121 ContextualSearchUma.logResultsSeen(mWasSearchContentViewSeen, mW
asActivatedByTap); | 119 ContextualSearchUma.logResultsSeen(mWasSearchContentViewSeen, mW
asActivatedByTap); |
| 122 } | 120 } |
| 123 | 121 |
| 124 if (mWasSelectionPartOfUrl) { | |
| 125 ContextualSearchUma.logResultsSeenSelectionIsUrl(mWasSearchConte
ntViewSeen, | |
| 126 mWasActivatedByTap); | |
| 127 } | |
| 128 | |
| 129 if (mWasContextualCardsDataShown) { | 122 if (mWasContextualCardsDataShown) { |
| 130 ContextualSearchUma.logContextualCardsResultsSeen(mWasSearchCont
entViewSeen); | 123 ContextualSearchUma.logContextualCardsResultsSeen(mWasSearchCont
entViewSeen); |
| 131 } | 124 } |
| 132 if (mWasQuickActionShown) { | 125 if (mWasQuickActionShown) { |
| 133 ContextualSearchUma.logQuickActionResultsSeen(mWasSearchContentV
iewSeen, | 126 ContextualSearchUma.logQuickActionResultsSeen(mWasSearchContentV
iewSeen, |
| 134 mQuickActionCategory); | 127 mQuickActionCategory); |
| 135 ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked
, | 128 ContextualSearchUma.logQuickActionClicked(mWasQuickActionClicked
, |
| 136 mQuickActionCategory); | 129 mQuickActionCategory); |
| 137 mTapSuppressionRankerLogger.log( | 130 mTapSuppressionRankerLogger.log( |
| 138 ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_A
CTION_CLICKED, | 131 ContextualSearchRankerLogger.Feature.OUTCOME_WAS_QUICK_A
CTION_CLICKED, |
| 139 mWasQuickActionClicked); | 132 mWasQuickActionClicked); |
| 140 } | 133 } |
| 141 | 134 |
| 142 if (mWasSelectionAllCaps && mWasActivatedByTap) { | 135 if (mDidSelectionStartWithCapital && mWasActivatedByTap) { |
| 143 ContextualSearchUma.logAllCapsResultsSeen(mWasSearchContentViewS
een); | |
| 144 } else if (mDidSelectionStartWithCapital && mWasActivatedByTap) { | |
| 145 ContextualSearchUma.logStartedWithCapitalResultsSeen(mWasSearchC
ontentViewSeen); | 136 ContextualSearchUma.logStartedWithCapitalResultsSeen(mWasSearchC
ontentViewSeen); |
| 146 } | 137 } |
| 147 | 138 |
| 148 ContextualSearchUma.logBlacklistSeen(mBlacklistReason, mWasSearchCon
tentViewSeen); | 139 ContextualSearchUma.logBlacklistSeen(mBlacklistReason, mWasSearchCon
tentViewSeen); |
| 149 | 140 |
| 150 if (mResultsSeenExperiments != null) { | 141 if (mResultsSeenExperiments != null) { |
| 151 mResultsSeenExperiments.logResultsSeen( | 142 mResultsSeenExperiments.logResultsSeen( |
| 152 mWasSearchContentViewSeen, mWasActivatedByTap); | 143 mWasSearchContentViewSeen, mWasActivatedByTap); |
| 153 mResultsSeenExperiments = null; | 144 mResultsSeenExperiments = null; |
| 154 } | 145 } |
| 155 | 146 |
| 156 if (mWasActivatedByTap) { | 147 if (mWasActivatedByTap) { |
| 157 boolean wasAnySuppressionHeuristicSatisfied = | 148 boolean wasAnySuppressionHeuristicSatisfied = mWasAnyHeuristicSa
tisfiedOnPanelShow; |
| 158 mWasAnyHeuristicSatisfiedOnPanelShow || mWasSelectionPar
tOfUrl; | |
| 159 ContextualSearchUma.logAnyTapSuppressionHeuristicSatisfied( | 149 ContextualSearchUma.logAnyTapSuppressionHeuristicSatisfied( |
| 160 mWasSearchContentViewSeen, wasAnySuppressionHeuristicSat
isfied); | 150 mWasSearchContentViewSeen, wasAnySuppressionHeuristicSat
isfied); |
| 161 // Log all the experiments to the Ranker logger. | 151 // Log all the experiments to the Ranker logger. |
| 162 if (mRankerLogExperiments != null) { | 152 if (mRankerLogExperiments != null) { |
| 163 writeSelectionFeaturesToRanker(); | 153 writeSelectionFeaturesToRanker(); |
| 164 mTapSuppressionRankerLogger.logOutcome(mWasSearchContentView
Seen); | 154 mTapSuppressionRankerLogger.logOutcome(mWasSearchContentView
Seen); |
| 165 mRankerLogExperiments.logRankerTapSuppression(mTapSuppressio
nRankerLogger); | 155 mRankerLogExperiments.logRankerTapSuppression(mTapSuppressio
nRankerLogger); |
| 166 mTapSuppressionRankerLogger.writeLogAndReset(); | 156 mTapSuppressionRankerLogger.writeLogAndReset(); |
| 167 mRankerLogExperiments = null; | 157 mRankerLogExperiments = null; |
| 168 } | 158 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 | 225 |
| 236 if (isEndingSearch) { | 226 if (isEndingSearch) { |
| 237 mDidSearchInvolvePromo = false; | 227 mDidSearchInvolvePromo = false; |
| 238 mWasSearchContentViewSeen = false; | 228 mWasSearchContentViewSeen = false; |
| 239 mHasExpanded = false; | 229 mHasExpanded = false; |
| 240 mHasMaximized = false; | 230 mHasMaximized = false; |
| 241 mHasExitedPeeking = false; | 231 mHasExitedPeeking = false; |
| 242 mHasExitedExpanded = false; | 232 mHasExitedExpanded = false; |
| 243 mHasExitedMaximized = false; | 233 mHasExitedMaximized = false; |
| 244 mIsSerpNavigation = false; | 234 mIsSerpNavigation = false; |
| 245 mWasSelectionPartOfUrl = false; | |
| 246 mWasContextualCardsDataShown = false; | 235 mWasContextualCardsDataShown = false; |
| 247 mWasQuickActionShown = false; | 236 mWasQuickActionShown = false; |
| 248 mQuickActionCategory = QuickActionCategory.NONE; | 237 mQuickActionCategory = QuickActionCategory.NONE; |
| 249 mWasQuickActionClicked = false; | 238 mWasQuickActionClicked = false; |
| 250 mWasSelectionAllCaps = false; | |
| 251 mDidSelectionStartWithCapital = false; | 239 mDidSelectionStartWithCapital = false; |
| 252 mWasAnyHeuristicSatisfiedOnPanelShow = false; | 240 mWasAnyHeuristicSatisfiedOnPanelShow = false; |
| 253 mPanelTriggerTimeFromTapNs = 0; | 241 mPanelTriggerTimeFromTapNs = 0; |
| 254 } | 242 } |
| 255 } | 243 } |
| 256 | 244 |
| 257 /** | 245 /** |
| 258 * Sets the reason why the current selection was blacklisted. | 246 * Sets the reason why the current selection was blacklisted. |
| 259 * @param reason The given reason. | 247 * @param reason The given reason. |
| 260 */ | 248 */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 279 } | 267 } |
| 280 | 268 |
| 281 /** | 269 /** |
| 282 * Sets whether the promo is active. | 270 * Sets whether the promo is active. |
| 283 */ | 271 */ |
| 284 public void setIsPromoActive(boolean shown) { | 272 public void setIsPromoActive(boolean shown) { |
| 285 mIsPromoActive = shown; | 273 mIsPromoActive = shown; |
| 286 } | 274 } |
| 287 | 275 |
| 288 /** | 276 /** |
| 289 * @param wasPartOfUrl Whether the selected text was part of a URL. | |
| 290 */ | |
| 291 public void setWasSelectionPartOfUrl(boolean wasPartOfUrl) { | |
| 292 mWasSelectionPartOfUrl = wasPartOfUrl; | |
| 293 } | |
| 294 | |
| 295 /** | |
| 296 * @param wasContextualCardsDataShown Whether Contextual Cards data was show
n in the Contextual | 277 * @param wasContextualCardsDataShown Whether Contextual Cards data was show
n in the Contextual |
| 297 * Search Bar. | 278 * Search Bar. |
| 298 */ | 279 */ |
| 299 public void setWasContextualCardsDataShown(boolean wasContextualCardsDataSho
wn) { | 280 public void setWasContextualCardsDataShown(boolean wasContextualCardsDataSho
wn) { |
| 300 mWasContextualCardsDataShown = wasContextualCardsDataShown; | 281 mWasContextualCardsDataShown = wasContextualCardsDataShown; |
| 301 } | 282 } |
| 302 | 283 |
| 303 /** | 284 /** |
| 304 * @param wasQuickActionShown Whether a quick action was shown in the Contex
tual Search Bar. | 285 * @param wasQuickActionShown Whether a quick action was shown in the Contex
tual Search Bar. |
| 305 * @param quickActionCategory The {@link QuickActionCategory} for the quick
action. | 286 * @param quickActionCategory The {@link QuickActionCategory} for the quick
action. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 321 */ | 302 */ |
| 322 public void onPanelTriggeredFromTap() { | 303 public void onPanelTriggeredFromTap() { |
| 323 mPanelTriggerTimeFromTapNs = System.nanoTime(); | 304 mPanelTriggerTimeFromTapNs = System.nanoTime(); |
| 324 } | 305 } |
| 325 | 306 |
| 326 /** | 307 /** |
| 327 * @param selection The text that is selected when a selection is establishe
d. | 308 * @param selection The text that is selected when a selection is establishe
d. |
| 328 */ | 309 */ |
| 329 public void onSelectionEstablished(String selection) { | 310 public void onSelectionEstablished(String selection) { |
| 330 mSelectionLength = selection.length(); | 311 mSelectionLength = selection.length(); |
| 331 // In some locales, there is no concept of an upper or lower case letter
. Account for this | |
| 332 // by checking that the selected text is not equivalent to selection#toL
owerCase(). | |
| 333 mWasSelectionAllCaps = selection.equals(selection.toUpperCase(Locale.get
Default())) | |
| 334 && !selection.equals(selection.toLowerCase(Locale.getDefault()))
; | |
| 335 mSelectionFirstChar = selection.charAt(0); | 312 mSelectionFirstChar = selection.charAt(0); |
| 336 String firstChar = String.valueOf(mSelectionFirstChar); | 313 String firstChar = String.valueOf(mSelectionFirstChar); |
| 337 mDidSelectionStartWithCapital = firstChar.equals( | 314 mDidSelectionStartWithCapital = firstChar.equals( |
| 338 firstChar.toUpperCase(Locale.getDefault())) | 315 firstChar.toUpperCase(Locale.getDefault())) |
| 339 && !firstChar.equals(firstChar.toLowerCase(Locale.getDefault()))
; | 316 && !firstChar.equals(firstChar.toLowerCase(Locale.getDefault()))
; |
| 340 } | 317 } |
| 341 | 318 |
| 342 /** | 319 /** |
| 343 * Writes the set of selection features that we've collected for Ranker to i
ts log. | 320 * Writes the set of selection features that we've collected for Ranker to i
ts log. |
| 344 */ | 321 */ |
| 345 private void writeSelectionFeaturesToRanker() { | 322 private void writeSelectionFeaturesToRanker() { |
| 346 mTapSuppressionRankerLogger.log( | 323 mTapSuppressionRankerLogger.log( |
| 347 ContextualSearchRankerLogger.Feature.SELECTION_LENGTH, mSelectio
nLength); | 324 ContextualSearchRankerLogger.Feature.SELECTION_LENGTH, mSelectio
nLength); |
| 348 mTapSuppressionRankerLogger.log( | 325 mTapSuppressionRankerLogger.log( |
| 349 ContextualSearchRankerLogger.Feature.SELECTION_FIRST_CHAR, mSele
ctionFirstChar); | 326 ContextualSearchRankerLogger.Feature.SELECTION_FIRST_CHAR, mSele
ctionFirstChar); |
| 350 mTapSuppressionRankerLogger.log( | |
| 351 ContextualSearchRankerLogger.Feature.SELECTION_WAS_ALL_CAPS, mWa
sSelectionAllCaps); | |
| 352 } | 327 } |
| 353 | 328 |
| 354 /** | 329 /** |
| 355 * Called to record the time when a search request started, for resolve and
prefetch timing. | 330 * Called to record the time when a search request started, for resolve and
prefetch timing. |
| 356 */ | 331 */ |
| 357 public void onSearchRequestStarted() { | 332 public void onSearchRequestStarted() { |
| 358 mSearchRequestStartTimeNs = System.nanoTime(); | 333 mSearchRequestStartTimeNs = System.nanoTime(); |
| 359 } | 334 } |
| 360 | 335 |
| 361 /** | 336 /** |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 | 396 |
| 422 /** | 397 /** |
| 423 * @param fromState The state the panel is transitioning from. | 398 * @param fromState The state the panel is transitioning from. |
| 424 * @return Whether there is an ongoing contextual search. | 399 * @return Whether there is an ongoing contextual search. |
| 425 */ | 400 */ |
| 426 private boolean isOngoingContextualSearch(PanelState fromState) { | 401 private boolean isOngoingContextualSearch(PanelState fromState) { |
| 427 return fromState != PanelState.UNDEFINED && fromState != PanelState.CLOS
ED; | 402 return fromState != PanelState.UNDEFINED && fromState != PanelState.CLOS
ED; |
| 428 } | 403 } |
| 429 } | 404 } |
| 430 | 405 |
| OLD | NEW |