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

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: Pull, respond to comments, add image property, add more tests. 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
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/omnibox/SuggestionAnswer.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 28153739c9e37cdd9019315c614ba94482922a2a..1b58616e2ca7dbb8dbfdda167180d804535c76af 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;
@@ -104,6 +105,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 */
@@ -138,6 +147,14 @@ public class OmniboxSuggestion {
return mAnswerType;
}
+ public SuggestionAnswer getAnswer() {
+ return mAnswer;
+ }
+
+ public boolean hasAnswer() {
+ return mAnswer != null;
+ }
+
public String getFillIntoEdit() {
return mFillIntoEdit;
}
« no previous file with comments | « no previous file | chrome/android/java/src/org/chromium/chrome/browser/omnibox/SuggestionAnswer.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698