Chromium Code Reviews| Index: chrome/browser/android/contextualsearch/contextual_search_delegate.h |
| diff --git a/chrome/browser/android/contextualsearch/contextual_search_delegate.h b/chrome/browser/android/contextualsearch/contextual_search_delegate.h |
| index dde551b3f383191ccf5631f0dd169bb790768a2a..ed108c66f15e3620c691f9b1c373acc7bdb2d52e 100644 |
| --- a/chrome/browser/android/contextualsearch/contextual_search_delegate.h |
| +++ b/chrome/browser/android/contextualsearch/contextual_search_delegate.h |
| @@ -43,11 +43,6 @@ class ContextualSearchDelegate |
| // Provides the Resolved Search Term, called when the Resolve Request returns. |
| typedef base::Callback<void(const ResolvedSearchTerm&)> |
| SearchTermResolutionCallback; |
| - // Provides the surrounding text and selection start/end when Blink gathers |
| - // surrounding text for the Context. |
| - typedef base::Callback< |
| - void(const base::string16&, int, int)> |
| - HandleSurroundingsCallback; |
| // Provides limited surrounding text for icing. |
| typedef base::Callback< |
| void(const std::string&, const base::string16&, size_t, size_t)> |
| @@ -67,23 +62,21 @@ class ContextualSearchDelegate |
| ~ContextualSearchDelegate() override; |
| // Gathers surrounding text and starts an asynchronous search term resolution |
| - // request. The "search term" is the best query to issue for a section of text |
| - // in the context of a web page. When the response is available the callback |
| - // specified in the constructor is run. |
| - void StartSearchTermResolutionRequest(const std::string& selection, |
| - const std::string& home_country, |
| - content::WebContents* web_contents, |
| - bool may_send_base_page_url); |
| - |
| - // Gathers surrounding text and saves it locally for a future query. |
| - void GatherAndSaveSurroundingText(const std::string& selection, |
| - const std::string& home_country, |
| - content::WebContents* web_contents, |
| - bool may_send_base_page_url); |
| - |
| - // Continues making a Search Term Resolution request, once the surrounding |
| - // text has been gathered. |
| - void ContinueSearchTermResolutionRequest(); |
| + // request. The given context includes some content from a web page. |
| + // When the response is available the callback specified in the constructor |
| + // is run. |
| + void StartSearchTermResolutionRequest( |
| + ContextualSearchContext* contextual_search_context, |
| + content::WebContents* web_contents); |
| + |
| + // Gathers surrounding text and saves it locally in the given context. |
| + void GatherAndSaveSurroundingText( |
| + ContextualSearchContext* contextual_search_context, |
| + content::WebContents* web_contents); |
| + |
| + // Resolves the search term specified by the current context. |
| + // Only needed for tests. TODO(donnd): make private and friend? |
| + void ResolveSearchTermFromContext(); |
| // Gets the target language for translation purposes for this user. |
| std::string GetTargetLanguage(); |
| @@ -93,7 +86,7 @@ class ContextualSearchDelegate |
| // For testing. |
| void set_context_for_testing(ContextualSearchContext* context) { |
| - context_.reset(context); |
| + context_ = context; |
| } |
| private: |
| @@ -118,13 +111,6 @@ class ContextualSearchDelegate |
| // net::URLFetcherDelegate: |
| void OnURLFetchComplete(const net::URLFetcher* source) override; |
| - // Builds the ContextualSearchContext in the current context from |
| - // the given parameters. |
| - void BuildContext(const std::string& selection, |
| - const std::string& home_country, |
| - content::WebContents* web_contents, |
| - bool may_send_base_page_url); |
| - |
| // Builds and returns the search term resolution request URL. |
| // |selection| is used as the default query. |
| std::string BuildRequestUrl(std::string selection); |
| @@ -136,17 +122,9 @@ class ContextualSearchDelegate |
| const std::string& base_page_url, |
| const bool may_send_base_page_url); |
| - // Will gather the surrounding text from the |content_view_core| and call the |
| - // |callback|. |
| - void GatherSurroundingTextWithCallback(const std::string& selection, |
| - const std::string& home_country, |
| - content::WebContents* web_contents, |
| - bool may_send_base_page_url, |
| - HandleSurroundingsCallback callback); |
| - |
| - // Callback for GatherSurroundingTextWithCallback(). Will start the search |
| - // term resolution request. |
| - void StartSearchTermRequestFromSelection( |
| + // Callback for GatherAndSaveSurroundingText, called when surrounding text is |
| + // available. |
| + void OnTextSurroundingSelectionAvailable( |
| const base::string16& surrounding_text, |
| int start_offset, |
| int end_offset); |
| @@ -243,7 +221,7 @@ class ContextualSearchDelegate |
| IcingCallback icing_callback_; |
| // Used to hold the context until an upcoming search term request is started. |
| - std::unique_ptr<ContextualSearchContext> context_; |
|
Theresa
2017/03/08 01:54:38
Just to check my understanding - the ContextualSea
Donn Denman
2017/03/09 17:35:05
That's right, it's now owned by the Java object.
|
| + ContextualSearchContext* context_; |
| DISALLOW_COPY_AND_ASSIGN(ContextualSearchDelegate); |
| }; |