| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| index f2d836b303e8352ca60e52cca77d0c24dfab7b4b..2f26df970521341350b8d00769ac9d2883f27f21 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java
|
| @@ -487,6 +487,9 @@ public class ContextualSearchPanel extends OverlayPanel {
|
| * @param searchTerm The string that represents the search term.
|
| */
|
| public void setSearchTerm(String searchTerm) {
|
| + mThumbnailUrl = "";
|
| + mThumbnailVisible = false;
|
| +
|
| getSearchBarControl().setSearchTerm(searchTerm);
|
| mPanelMetrics.onSearchRequestStarted();
|
| }
|
| @@ -497,6 +500,9 @@ public class ContextualSearchPanel extends OverlayPanel {
|
| * @param end The portion of the context from the selection to its end.
|
| */
|
| public void setSearchContext(String selection, String end) {
|
| + mThumbnailUrl = "";
|
| + mThumbnailVisible = false;
|
| +
|
| getSearchBarControl().setSearchContext(selection, end);
|
| mPanelMetrics.onSearchRequestStarted();
|
| }
|
| @@ -513,11 +519,13 @@ public class ContextualSearchPanel extends OverlayPanel {
|
| /**
|
| * Handles showing the resolved search term in the SearchBar.
|
| * @param searchTerm The string that represents the search term.
|
| + * @param thumbnailUrl The URL of the thumbnail to display.
|
| */
|
| - public void onSearchTermResolved(String searchTerm) {
|
| + public void onSearchTermResolved(String searchTerm, String thumbnailUrl) {
|
| mPanelMetrics.onSearchTermResolved();
|
| getSearchBarControl().setSearchTerm(searchTerm);
|
| getSearchBarControl().animateSearchTermResolution();
|
| + mThumbnailUrl = thumbnailUrl;
|
| }
|
|
|
| // ============================================================================================
|
| @@ -674,13 +682,74 @@ public class ContextualSearchPanel extends OverlayPanel {
|
|
|
| /**
|
| * @param shouldAnimateIconSprite Whether the search provider icon sprite should be animated.
|
| - * @param isAnimationDisabledByTrial Whether animating the search provider icon is disabled by a
|
| - * field trial.
|
| */
|
| - public void setShouldAnimateIconSprite(boolean shouldAnimateIconSprite,
|
| - boolean isAnimationDisabledByTrial) {
|
| - getIconSpriteControl().setShouldAnimateAppearance(shouldAnimateIconSprite,
|
| - isAnimationDisabledByTrial);
|
| + public void setShouldAnimateIconSprite(boolean shouldAnimateIconSprite) {
|
| + getIconSpriteControl().setShouldAnimateAppearance(shouldAnimateIconSprite);
|
| + }
|
| +
|
| + // ============================================================================================
|
| + // Thumbnail
|
| + // ============================================================================================
|
| +
|
| + // TODO(twellington): The thumbnail and icon sprite should probably be moved to
|
| + // ContextualSearchBarControl since they are displayed in the bar. This
|
| + // would also help facilitate showing the thumbnail and a caption at the
|
| + // same time.
|
| +
|
| + /**
|
| + * The URL of the thumbnail to display.
|
| + */
|
| + private String mThumbnailUrl;
|
| +
|
| + /**
|
| + * The height and width of the thumbnail.
|
| + */
|
| + private int mThumbnailSize;
|
| +
|
| + /**
|
| + * Whether the thumbnail is visible.
|
| + */
|
| + private boolean mThumbnailVisible;
|
| +
|
| + /**
|
| + * @return The URL used to fetch a thumbnail to display in the SearchBar. Will return an empty
|
| + * string if no thumbnail is available.
|
| + */
|
| + public String getThumbnailUrl() {
|
| + return mThumbnailUrl != null ? mThumbnailUrl : "";
|
| + }
|
| +
|
| + /**
|
| + * @return The height and width of the thumbnail in px.
|
| + */
|
| + public int getThumbnailSize() {
|
| + if (mThumbnailSize == 0) {
|
| + mThumbnailSize = mContext.getResources().getDimensionPixelSize(
|
| + R.dimen.contextual_search_thumbnail_size);
|
| + }
|
| + return mThumbnailSize;
|
| + }
|
| +
|
| + /**
|
| + * @return Whether the thumbnail is visible.
|
| + */
|
| + public boolean getThumbnailVisible() {
|
| + // TODO(twellington): The thumbnail and caption should become visible at the same time,
|
| + // possibly by using an observer that is notified when the caption
|
| + // snapshot is captured.
|
| + // Once the thumbnail has been captured, an animation for both
|
| + // the thumbnail and caption should be started.
|
| + return mThumbnailVisible;
|
| + }
|
| +
|
| +
|
| + /**
|
| + * Called when the thumbnail has finished being fetched.
|
| + * @param success Whether fetching the thumbnail was successful.
|
| + */
|
| + public void onThumbnailFetched(boolean success) {
|
| + mThumbnailVisible = success;
|
| + if (success) requestUpdate();
|
| }
|
|
|
| // ============================================================================================
|
|
|