| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 android.text.TextUtils; | 7 import android.text.TextUtils; |
| 8 | 8 |
| 9 import com.google.common.annotations.VisibleForTesting; | 9 import com.google.common.annotations.VisibleForTesting; |
| 10 | 10 |
| 11 /** | 11 /** |
| 12 * Container class with information about each omnibox suggestion item. | 12 * Container class with information about each omnibox suggestion item. |
| 13 */ | 13 */ |
| 14 @VisibleForTesting | 14 @VisibleForTesting |
| 15 public class OmniboxSuggestion { | 15 public class OmniboxSuggestion { |
| 16 | 16 |
| 17 private final Type mType; | 17 private final Type mType; |
| 18 private final String mDisplayText; | 18 private final String mDisplayText; |
| 19 private final String mDescription; | 19 private final String mDescription; |
| 20 private final String mAnswerContents; | 20 private final String mAnswerContents; |
| 21 private final String mAnswerType; | 21 private final String mAnswerType; |
| 22 private final SuggestionAnswer mAnswer; |
| 22 private final String mFillIntoEdit; | 23 private final String mFillIntoEdit; |
| 23 private final String mUrl; | 24 private final String mUrl; |
| 24 private final String mFormattedUrl; | 25 private final String mFormattedUrl; |
| 25 private final int mRelevance; | 26 private final int mRelevance; |
| 26 private final int mTransition; | 27 private final int mTransition; |
| 27 private final boolean mIsStarred; | 28 private final boolean mIsStarred; |
| 28 private final boolean mIsDeletable; | 29 private final boolean mIsDeletable; |
| 29 | 30 |
| 30 /** | 31 /** |
| 31 * This should be kept in sync with AutocompleteMatch::Type | 32 * This should be kept in sync with AutocompleteMatch::Type |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 mTransition = transition; | 98 mTransition = transition; |
| 98 mDisplayText = text; | 99 mDisplayText = text; |
| 99 mDescription = description; | 100 mDescription = description; |
| 100 mAnswerContents = answerContents; | 101 mAnswerContents = answerContents; |
| 101 mAnswerType = answerType; | 102 mAnswerType = answerType; |
| 102 mFillIntoEdit = TextUtils.isEmpty(fillIntoEdit) ? text : fillIntoEdit; | 103 mFillIntoEdit = TextUtils.isEmpty(fillIntoEdit) ? text : fillIntoEdit; |
| 103 mUrl = url; | 104 mUrl = url; |
| 104 mFormattedUrl = formattedUrl; | 105 mFormattedUrl = formattedUrl; |
| 105 mIsStarred = isStarred; | 106 mIsStarred = isStarred; |
| 106 mIsDeletable = isDeletable; | 107 mIsDeletable = isDeletable; |
| 108 |
| 109 if (!TextUtils.isEmpty(mAnswerContents)) { |
| 110 // If any errors are encountered parsing the answer contents, this w
ill return null and |
| 111 // hasAnswer will return false, just as if there were no answer cont
ents at all. |
| 112 mAnswer = SuggestionAnswer.parseAnswerContents(mAnswerContents); |
| 113 } else { |
| 114 mAnswer = null; |
| 115 } |
| 107 } | 116 } |
| 108 | 117 |
| 109 /* TODO(groby): Remove - see http://crbug.com/375482 */ | 118 /* TODO(groby): Remove - see http://crbug.com/375482 */ |
| 110 public OmniboxSuggestion(int nativeType, int relevance, int transition, | 119 public OmniboxSuggestion(int nativeType, int relevance, int transition, |
| 111 String text, String description, String fillIntoEdit, String url, | 120 String text, String description, String fillIntoEdit, String url, |
| 112 String formattedUrl, boolean isStarred, boolean isDeletable) { | 121 String formattedUrl, boolean isStarred, boolean isDeletable) { |
| 113 this(nativeType, relevance, transition, text, description, null, null, f
illIntoEdit, url, | 122 this(nativeType, relevance, transition, text, description, null, null, f
illIntoEdit, url, |
| 114 formattedUrl, isStarred, isDeletable); | 123 formattedUrl, isStarred, isDeletable); |
| 115 } | 124 } |
| 116 | 125 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 131 } | 140 } |
| 132 | 141 |
| 133 public String getAnswerContents() { | 142 public String getAnswerContents() { |
| 134 return mAnswerContents; | 143 return mAnswerContents; |
| 135 } | 144 } |
| 136 | 145 |
| 137 public String getAnswerType() { | 146 public String getAnswerType() { |
| 138 return mAnswerType; | 147 return mAnswerType; |
| 139 } | 148 } |
| 140 | 149 |
| 150 public SuggestionAnswer getAnswer() { |
| 151 return mAnswer; |
| 152 } |
| 153 |
| 154 public boolean hasAnswer() { |
| 155 return mAnswer != null; |
| 156 } |
| 157 |
| 141 public String getFillIntoEdit() { | 158 public String getFillIntoEdit() { |
| 142 return mFillIntoEdit; | 159 return mFillIntoEdit; |
| 143 } | 160 } |
| 144 | 161 |
| 145 public String getUrl() { | 162 public String getUrl() { |
| 146 return mUrl; | 163 return mUrl; |
| 147 } | 164 } |
| 148 | 165 |
| 149 public String getFormattedUrl() { | 166 public String getFormattedUrl() { |
| 150 return mFormattedUrl; | 167 return mFormattedUrl; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 suggestion.mAnswerContents != null && | 211 suggestion.mAnswerContents != null && |
| 195 mAnswerContents.equals(suggestion.mAnswerContents)); | 212 mAnswerContents.equals(suggestion.mAnswerContents)); |
| 196 return mType == suggestion.mType | 213 return mType == suggestion.mType |
| 197 && mFillIntoEdit.equals(suggestion.mFillIntoEdit) | 214 && mFillIntoEdit.equals(suggestion.mFillIntoEdit) |
| 198 && mDisplayText.equals(suggestion.mDisplayText) | 215 && mDisplayText.equals(suggestion.mDisplayText) |
| 199 && answersAreEqual | 216 && answersAreEqual |
| 200 && mIsStarred == suggestion.mIsStarred | 217 && mIsStarred == suggestion.mIsStarred |
| 201 && mIsDeletable == suggestion.mIsDeletable; | 218 && mIsDeletable == suggestion.mIsDeletable; |
| 202 } | 219 } |
| 203 } | 220 } |
| OLD | NEW |