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

Unified Diff: chrome/browser/android/contextualsearch/contextual_search_delegate.h

Issue 1354763003: [Contextual Search] Trigger the translation one-box. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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/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 8714afe5da0cd33b116b2c57ca0be7ae678592a4..99ccf6ef74b87b79ea9308b18a1e49bf5b254860 100644
--- a/chrome/browser/android/contextualsearch/contextual_search_delegate.h
+++ b/chrome/browser/android/contextualsearch/contextual_search_delegate.h
@@ -11,6 +11,7 @@
#include "base/memory/weak_ptr.h"
#include "base/values.h"
#include "chrome/browser/android/contextualsearch/contextual_search_context.h"
+#include "chrome/browser/android/contextualsearch/resolved_search_term.h"
#include "content/public/browser/android/content_view_core.h"
#include "net/url_request/url_fetcher_delegate.h"
@@ -27,14 +28,8 @@ class ContextualSearchDelegate
: public net::URLFetcherDelegate,
public base::SupportsWeakPtr<ContextualSearchDelegate> {
public:
- typedef base::Callback<void(bool,
- int,
- const std::string&,
- const std::string&,
- const std::string&,
- bool,
- int,
- int)> SearchTermResolutionCallback;
+ typedef base::Callback<void(const ResolvedSearchTerm&)>
+ SearchTermResolutionCallback;
typedef base::Callback<
void(const std::string&, const std::string&)> SurroundingTextCallback;
typedef base::Callback<
@@ -77,6 +72,9 @@ class ContextualSearchDelegate
// text has been gathered.
void ContinueSearchTermResolutionRequest();
+ // Gets the target language for translation purposes (cached).
+ std::string GetTargetLanguage();
+
// For testing.
void set_context_for_testing(ContextualSearchContext* context) {
context_.reset(context);
@@ -96,7 +94,7 @@ class ContextualSearchDelegate
FRIEND_TEST_ALL_PREFIXES(ContextualSearchDelegateTest,
SurroundingTextForIcingNegativeLimit);
FRIEND_TEST_ALL_PREFIXES(ContextualSearchDelegateTest,
- DecodeSearchTermsFromJsonResponse);
+ DecodeSearchTermFromJsonResponse);
// net::URLFetcherDelegate:
void OnURLFetchComplete(const net::URLFetcher* source) override;
@@ -151,13 +149,14 @@ class ContextualSearchDelegate
TemplateURLService* template_url_service);
// Decodes the given json response string and extracts parameters.
- void DecodeSearchTermsFromJsonResponse(const std::string& response,
- std::string* search_term,
- std::string* display_text,
- std::string* alternate_term,
- std::string* prevent_preload,
- int* mention_start,
- int* mention_end);
+ void DecodeSearchTermFromJsonResponse(const std::string& response,
+ std::string* search_term,
+ std::string* display_text,
+ std::string* alternate_term,
+ std::string* prevent_preload,
+ int* mention_start,
+ int* mention_end,
+ std::string* lang);
void ExtractMentionsStartEnd(const base::ListValue& mentions_list,
int* startResult,
@@ -208,6 +207,10 @@ class ContextualSearchDelegate
// Used to hold the context until an upcoming search term request is started.
scoped_ptr<ContextualSearchContext> context_;
+ // Cached Target Language string, to determine when we need to trigger
+ // translation.
+ std::string target_language_;
+
DISALLOW_COPY_AND_ASSIGN(ContextualSearchDelegate);
};

Powered by Google App Engine
This is Rietveld 408576698