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

Unified Diff: components/translate/content/renderer/translate_helper.h

Issue 1650303002: Move DOM-inspecting language detection logic to Blink. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased. Created 4 years, 10 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: components/translate/content/renderer/translate_helper.h
diff --git a/components/translate/content/renderer/translate_helper.h b/components/translate/content/renderer/translate_helper.h
index e3eab899e712d5481f7dc52859eee8f303828f8d..1cfaa25a91070c9ba113ef2d8f9cdd5f345564cc 100644
--- a/components/translate/content/renderer/translate_helper.h
+++ b/components/translate/content/renderer/translate_helper.h
@@ -13,6 +13,7 @@
#include "base/strings/string16.h"
#include "base/time/time.h"
#include "components/translate/content/renderer/renderer_cld_data_provider.h"
+#include "components/translate/core/common/language_detection_details.h"
#include "components/translate/core/common/translate_errors.h"
#include "content/public/renderer/render_frame_observer.h"
#include "url/gurl.h"
@@ -20,6 +21,7 @@
namespace blink {
class WebDocument;
class WebLocalFrame;
+struct WebLanguageDetectionDetails;
}
namespace content {
@@ -85,8 +87,10 @@ class TranslateHelper : public content::RenderFrameObserver {
const std::string& extension_scheme);
~TranslateHelper() override;
- // Informs us that the page's text has been extracted.
- void PageCaptured(const base::string16& contents);
+ // Informs us that language detection metadata has been extracted
+ // from the page.
+ void LanguageDetectionDetailsCaptured(
+ const LanguageDetectionDetails& details);
// Lets the translation system know that we are preparing to navigate to
// the specified URL. If there is anything that can or should be done before
@@ -164,8 +168,8 @@ class TranslateHelper : public content::RenderFrameObserver {
// RenderFrameObserver implementation.
bool OnMessageReceived(const IPC::Message& message) override;
- // Informs us that the page's text has been extracted.
- void PageCapturedImpl(int page_seq_no, const base::string16& contents);
+ // Attempt language detection.
+ void DetectLanguage(int page_seq_no);
// Cancels any translation that is currently being performed. This does not
// revert existing translations.
@@ -227,7 +231,7 @@ class TranslateHelper : public content::RenderFrameObserver {
bool cld_data_polling_canceled_;
// Whether or not a PageCaptured event arrived prior to CLD data becoming
- // available. If true, deferred_contents_ contains the most recent contents.
+ // available. If true, deferred_details_ contains the most recent details.
bool deferred_page_capture_;
// The ID of the page most recently reported to PageCaptured if
@@ -243,9 +247,8 @@ class TranslateHelper : public content::RenderFrameObserver {
// The URL scheme for translate extensions.
std::string extension_scheme_;
- // The contents of the page most recently reported to PageCaptured if
- // deferred_page_capture_ is true.
- base::string16 deferred_contents_;
+ // The most recently reported language detection details.
+ LanguageDetectionDetails detection_details_;
// Method factory used to make calls to TranslatePageImpl.
base::WeakPtrFactory<TranslateHelper> weak_method_factory_;
« no previous file with comments | « chrome/renderer/chrome_render_frame_observer.cc ('k') | components/translate/content/renderer/translate_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698