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

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java

Issue 332943002: [AiS] Add a structured representation of Answer JSON. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java
index 5c5b9af4bc7836a861729ec001a6a3a4d3c20acb..d47bbc154a68e894bd5d7e7cd3517107928d1fce 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/omnibox/OmniboxSuggestion.java
@@ -19,6 +19,7 @@ public class OmniboxSuggestion {
private final String mDescription;
private final String mAnswerContents;
private final String mAnswerType;
+ private final SuggestionAnswer mAnswer;
private final String mFillIntoEdit;
private final String mUrl;
private final String mFormattedUrl;
@@ -103,6 +104,14 @@ public class OmniboxSuggestion {
mFormattedUrl = formattedUrl;
mIsStarred = isStarred;
mIsDeletable = isDeletable;
+
+ if (!TextUtils.isEmpty(mAnswerContents)) {
+ // If any errors are encountered parsing the answer contents, this will return null and
+ // hasAnswer will return false, just as if there were no answer contents at all.
+ mAnswer = SuggestionAnswer.parseAnswerContents(mAnswerContents);
+ } else {
+ mAnswer = null;
+ }
}
/* TODO(groby): Remove - see http://crbug.com/375482 */
@@ -137,6 +146,14 @@ public class OmniboxSuggestion {
return mAnswerType;
}
+ public SuggestionAnswer getAnswer() {
+ return mAnswer;
+ }
+
+ public boolean hasAnswer() {
+ return mAnswer != null;
+ }
+
public String getFillIntoEdit() {
return mFillIntoEdit;
}

Powered by Google App Engine
This is Rietveld 408576698