| Index: chrome/renderer/chrome_render_frame_observer.cc
|
| diff --git a/chrome/renderer/chrome_render_frame_observer.cc b/chrome/renderer/chrome_render_frame_observer.cc
|
| index 9fd19893f6daa9b2a071ad61e512ce34570c44f0..1a210f5ce2b3c1f1a38914e7b4b158f4caf4f188 100644
|
| --- a/chrome/renderer/chrome_render_frame_observer.cc
|
| +++ b/chrome/renderer/chrome_render_frame_observer.cc
|
| @@ -28,6 +28,7 @@
|
| #include "net/base/net_util.h"
|
| #include "skia/ext/image_operations.h"
|
| #include "third_party/WebKit/public/platform/WebImage.h"
|
| +#include "third_party/WebKit/public/platform/WebLanguageDetectionDetails.h"
|
| #include "third_party/WebKit/public/platform/modules/app_banner/WebAppBannerPromptReply.h"
|
| #include "third_party/WebKit/public/web/WebDataSource.h"
|
| #include "third_party/WebKit/public/web/WebDocument.h"
|
| @@ -47,16 +48,13 @@
|
|
|
| using blink::WebDataSource;
|
| using blink::WebElement;
|
| +using blink::WebLanguageDetectionDetails;
|
| using blink::WebLocalFrame;
|
| using blink::WebNode;
|
| using blink::WebString;
|
| using content::SSLStatus;
|
| using content::RenderFrame;
|
|
|
| -// Maximum number of characters in the document to index.
|
| -// Any text beyond this point will be clipped.
|
| -static const size_t kMaxIndexChars = 65535;
|
| -
|
| // Constants for UMA statistic collection.
|
| static const char kTranslateCaptureText[] = "Translate.CaptureText";
|
|
|
| @@ -352,21 +350,28 @@ void ChromeRenderFrameObserver::CapturePageText(TextCaptureType capture_type) {
|
|
|
| base::TimeTicks capture_begin_time = base::TimeTicks::Now();
|
|
|
| - // Retrieve the frame's full text (up to kMaxIndexChars), and pass it to the
|
| - // translate helper for language detection and possible translation.
|
| - base::string16 contents = frame->contentAsText(kMaxIndexChars);
|
| + WebLanguageDetectionDetails incoming_details =
|
| + frame->document().languageDetectionDetails();
|
|
|
| UMA_HISTOGRAM_TIMES(kTranslateCaptureText,
|
| base::TimeTicks::Now() - capture_begin_time);
|
|
|
| // We should run language detection only once. Parsing finishes before
|
| // the page loads, so let's pick that timing.
|
| - if (translate_helper_ && capture_type == PRELIMINARY_CAPTURE)
|
| - translate_helper_->PageCaptured(contents);
|
| + if (translate_helper_ && capture_type == PRELIMINARY_CAPTURE) {
|
| + translate::LanguageDetectionDetails details;
|
| + details.url = incoming_details.url;
|
| + details.content_language = incoming_details.contentLanguage.utf8();
|
| + details.html_root_language = incoming_details.htmlLanguage.utf8();
|
| + details.has_notranslate = incoming_details.hasNoTranslateMeta;
|
| + details.contents = incoming_details.content;
|
| + translate_helper_->LanguageDetectionDetailsCaptured(details);
|
| + }
|
|
|
| TRACE_EVENT0("renderer", "ChromeRenderFrameObserver::CapturePageText");
|
|
|
| #if defined(SAFE_BROWSING_CSD)
|
| + base::string16 contents = incoming_details.content;
|
| // Will swap out the string.
|
| if (phishing_classifier_)
|
| phishing_classifier_->PageCaptured(&contents,
|
|
|