Index: chrome/browser/android/contextualsearch/contextual_search_context.h |
diff --git a/chrome/browser/android/contextualsearch/contextual_search_context.h b/chrome/browser/android/contextualsearch/contextual_search_context.h |
index 436a114e3344f9972bbeee6584ea0898284f7fc9..b2f28f8375e4c77db1303229d60e225222f357b0 100644 |
--- a/chrome/browser/android/contextualsearch/contextual_search_context.h |
+++ b/chrome/browser/android/contextualsearch/contextual_search_context.h |
@@ -7,6 +7,7 @@ |
#include <string> |
+#include "base/android/jni_android.h" |
#include "base/macros.h" |
#include "url/gurl.h" |
@@ -14,22 +15,63 @@ |
// text. |
struct ContextualSearchContext { |
public: |
- ContextualSearchContext(const std::string& selected_text, |
- const std::string& home_country, |
- const GURL& page_url, |
- const std::string& encoding); |
+ ContextualSearchContext(JNIEnv* env, jobject obj); |
+ // Constructor for tests. |
+ ContextualSearchContext(); |
~ContextualSearchContext(); |
- const std::string selected_text; |
- const std::string home_country; |
- const GURL page_url; |
- const std::string encoding; |
+ // Calls the destructor. Should be called when this native object is no |
+ // longer needed. |
+ void Destroy(JNIEnv* env, const base::android::JavaParamRef<jobject>& obj); |
+ // Returns the native |ContextualSearchContext| given the java object. |
+ static ContextualSearchContext* FromJavaContextualSearchContext( |
+ const base::android::JavaRef<jobject>& j_contextual_search_context); |
+ |
+ // Returns whether the content associated with this context is brief. |
+ // If not, then this context may be resolved, but not otherwise. |
+ bool IsBrief(); |
+ |
+ // Returns whether the base page URL may be sent (according to the Java |
+ // context). |
+ bool MaySendBasePageUrl(); |
+ |
+ // Sets whether the content associated with this context is brief or not. |
+ void SetUseBriefPageContent(JNIEnv* env, |
Theresa
2017/03/08 01:54:38
Can this be combined with setProperties?
Donn Denman
2017/03/09 17:35:05
Done.
Changed the model from brief/normal context
|
+ jobject obj, |
+ jboolean j_use_brief_page_content); |
+ |
+ // Sets most of the properties on a context. |
+ void SetProperties(JNIEnv* env, |
+ jobject obj, |
+ const base::android::JavaParamRef<jstring>& j_selection, |
+ const base::android::JavaParamRef<jstring>& j_home_country, |
+ jboolean j_may_send_base_page_url); |
+ |
+ // Sets most of the properties in a way that's convenient for tests. |
+ void SetPropertiesInternal(std::string selection, |
+ std::string home_country, |
+ bool may_send_base_page_url); |
+ |
+ // Data. TODO(donnd): make private? |
+ std::string selected_text; |
+ std::string home_country; |
+ GURL page_url; |
+ std::string encoding; |
base::string16 surrounding_text; |
int start_offset; |
int end_offset; |
+ private: |
+ bool is_brief_surrounding_text; |
+ bool may_send_base_page_url; |
+ |
+ // The linked Java object. |
+ base::android::ScopedJavaGlobalRef<jobject> java_object_; |
+ |
DISALLOW_COPY_AND_ASSIGN(ContextualSearchContext); |
}; |
+bool RegisterContextualSearchContext(JNIEnv* env); |
+ |
#endif // CHROME_BROWSER_ANDROID_CONTEXTUALSEARCH_CONTEXTUAL_SEARCH_CONTEXT_H_ |