Chromium Code Reviews| Index: chrome/browser/android/contextualsearch/contextual_search_context.cc |
| diff --git a/chrome/browser/android/contextualsearch/contextual_search_context.cc b/chrome/browser/android/contextualsearch/contextual_search_context.cc |
| index 5ce515720a5ad5510b87f3327f44d0dd8339bde2..6910a6636f750b8c5e198c635cc32f1b08bf064a 100644 |
| --- a/chrome/browser/android/contextualsearch/contextual_search_context.cc |
| +++ b/chrome/browser/android/contextualsearch/contextual_search_context.cc |
| @@ -12,7 +12,6 @@ |
| ContextualSearchContext::ContextualSearchContext(JNIEnv* env, jobject obj) |
| : can_resolve(false), |
| can_send_base_page_url(false), |
| - selected_text(std::string()), |
| home_country(std::string()), |
| base_page_url(GURL()), |
| surrounding_text(base::string16()), |
| @@ -23,12 +22,10 @@ ContextualSearchContext::ContextualSearchContext(JNIEnv* env, jobject obj) |
| } |
| ContextualSearchContext::ContextualSearchContext( |
| - const std::string& selected_text, |
| const std::string& home_country, |
| const GURL& page_url, |
| const std::string& encoding) |
| - : selected_text(selected_text), |
| - home_country(home_country), |
| + : home_country(home_country), |
| base_page_url(page_url), |
| base_page_encoding(encoding), |
| weak_factory_(this) { |
| @@ -57,15 +54,25 @@ ContextualSearchContext::FromJavaContextualSearchContext( |
| void ContextualSearchContext::SetResolveProperties( |
| 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) { |
| can_resolve = true; |
| - selected_text = base::android::ConvertJavaStringToUTF8(env, j_selection); |
| home_country = base::android::ConvertJavaStringToUTF8(env, j_home_country); |
| can_send_base_page_url = j_may_send_base_page_url; |
| } |
| +void ContextualSearchContext::AdjustSelection(JNIEnv* env, |
| + jobject obj, |
| + jint j_start_adjust, |
| + jint j_end_adjust) { |
| + DCHECK(start_offset + j_start_adjust >= 0); |
|
Donn Denman
2017/04/26 03:43:54
Added this bounds checking.
|
| + DCHECK(start_offset + j_start_adjust <= (int)surrounding_text.length()); |
| + DCHECK(end_offset + j_end_adjust >= 0); |
| + DCHECK(end_offset + j_end_adjust <= (int)surrounding_text.length()); |
| + start_offset += j_start_adjust; |
| + end_offset += j_end_adjust; |
| +} |
| + |
| // Accessors |
| bool ContextualSearchContext::CanResolve() const { |
| @@ -106,10 +113,6 @@ void ContextualSearchContext::SetSelectionSurroundings( |
| this->surrounding_text = surrounding_text; |
| } |
| -const std::string ContextualSearchContext::GetOriginalSelectedText() const { |
| - return selected_text; |
| -} |
| - |
| const base::string16 ContextualSearchContext::GetSurroundingText() const { |
| return surrounding_text; |
| } |