| 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 6f71da98b5d9fbd79ad933b15c6c5ddf2c62cd8c..ac78d742afaf106dd5e959220eb58419e3072560 100644
|
| --- a/chrome/renderer/chrome_render_frame_observer.cc
|
| +++ b/chrome/renderer/chrome_render_frame_observer.cc
|
| @@ -49,14 +49,14 @@ using blink::WebString;
|
| using content::SSLStatus;
|
| using content::RenderFrame;
|
|
|
| -// Delay in milliseconds that we'll wait before capturing the page contents.
|
| -static const int kDelayForCaptureMs = 500;
|
| +// // Delay in milliseconds that we'll wait before capturing the page contents.
|
| +// static const int kDelayForCaptureMs = 500;
|
|
|
| // Typically, we capture the page data once the page is loaded.
|
| // Sometimes, the page never finishes to load, preventing the page capture
|
| // To workaround this problem, we always perform a capture after the following
|
| // delay.
|
| -static const int kDelayForForcedCaptureMs = 6000;
|
| +// static const int kDelayForForcedCaptureMs = 6000;
|
|
|
| // Maximum number of characters in the document to index.
|
| // Any text beyond this point will be clipped.
|
| @@ -110,15 +110,15 @@ PageInfo::PageInfo(PageInfoReceiver* context)
|
| DCHECK(context_);
|
| }
|
|
|
| -// TODO(dglazkov): Refactor to remove the RenderFrame* argument.
|
| -void PageInfo::CapturePageInfoLater(CaptureType capture_type,
|
| - RenderFrame* render_frame,
|
| - base::TimeDelta delay) {
|
| - capture_timer_.Start(
|
| - FROM_HERE, delay,
|
| - base::Bind(&PageInfo::CapturePageInfo, base::Unretained(this),
|
| - render_frame, capture_type));
|
| -}
|
| +// // TODO(dglazkov): Refactor to remove the RenderFrame* argument.
|
| +// void PageInfo::CapturePageInfoLater(CaptureType capture_type,
|
| +// RenderFrame* render_frame,
|
| +// base::TimeDelta delay) {
|
| +// capture_timer_.Start(
|
| +// FROM_HERE, delay,
|
| +// base::Bind(&PageInfo::CapturePageInfo, base::Unretained(this),
|
| +// render_frame, capture_type));
|
| +// }
|
|
|
| bool PageInfo::IsErrorPage(WebLocalFrame* frame) {
|
| WebDataSource* ds = frame->dataSource();
|
| @@ -134,6 +134,10 @@ void PageInfo::CapturePageInfo(RenderFrame* render_frame,
|
| if (!frame)
|
| return;
|
|
|
| + // Don't capture pages that have pending redirect or location change.
|
| + if (frame->isNavigationScheduled())
|
| + return;
|
| +
|
| // Don't index/capture pages that are in view source mode.
|
| if (frame->isViewSourceModeEnabled())
|
| return;
|
| @@ -373,16 +377,11 @@ void ChromeRenderFrameObserver::DidFinishLoad() {
|
| search_provider::AUTODETECTED_PROVIDER));
|
| }
|
|
|
| - // Don't capture pages that have pending redirect or location change.
|
| - if (frame->isNavigationScheduled())
|
| - return;
|
| -
|
| - page_info_.CapturePageInfoLater(
|
| - FINAL_CAPTURE, render_frame(),
|
| - base::TimeDelta::FromMilliseconds(
|
| - render_frame()->GetRenderView()->GetContentStateImmediately()
|
| - ? 0
|
| - : kDelayForCaptureMs));
|
| + // // TODO(dglazkov): This is only necessary for testing and indicates that
|
| + // // the tests that rely on this specific timing need to be rewritten to
|
| + // // avoid this kludge.
|
| + // if (render_frame()->GetRenderView()->GetContentStateImmediately()) {
|
| + // page_info_.CapturePageInfo(render_frame(), FINAL_CAPTURE);
|
| }
|
|
|
| void ChromeRenderFrameObserver::DidStartProvisionalLoad() {
|
| @@ -403,31 +402,41 @@ void ChromeRenderFrameObserver::DidCommitProvisionalLoad(
|
| if (frame->parent())
|
| return;
|
|
|
| - // Don't capture pages being not new, with pending redirect, or location
|
| - // change.
|
| - if (!is_new_navigation || frame->isNavigationScheduled())
|
| - return;
|
| + // // Don't capture pages being not new, with pending redirect, or location
|
| + // // change.
|
| + // if (!is_new_navigation || frame->isNavigationScheduled())
|
| + // return;
|
|
|
| base::debug::SetCrashKeyValue(
|
| crash_keys::kViewCount,
|
| base::SizeTToString(content::RenderView::GetRenderViewCount()));
|
| +}
|
|
|
| - page_info_.CapturePageInfoLater(
|
| - PRELIMINARY_CAPTURE, render_frame(),
|
| - base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs));
|
| +void ChromeRenderFrameObserver::DidMeaningfulLayout(
|
| + blink::WebMeaningfulLayout layout_type) {
|
| + switch (layout_type) {
|
| + case blink::WebMeaningfulLayout::FinishedParsing:
|
| + page_info_.CapturePageInfo(render_frame(), PRELIMINARY_CAPTURE);
|
| + break;
|
| + case blink::WebMeaningfulLayout::FinishedLoading:
|
| + page_info_.CapturePageInfo(render_frame(), FINAL_CAPTURE);
|
| + break;
|
| + default:
|
| + break;
|
| + }
|
| }
|
|
|
| void ChromeRenderFrameObserver::PageCaptured(base::string16* content,
|
| CaptureType capture_type) {
|
| - if (translate_helper_)
|
| + bool is_preliminary_capture = capture_type == PRELIMINARY_CAPTURE;
|
| + if (translate_helper_ && is_preliminary_capture)
|
| translate_helper_->PageCaptured(*content);
|
|
|
| - TRACE_EVENT0("renderer", "ChromeRenderViewObserver::CapturePageInfo");
|
| + TRACE_EVENT0("renderer", "ChromeRenderFrameObserver::CapturePageInfo");
|
|
|
| #if defined(FULL_SAFE_BROWSING)
|
| // Will swap out the string.
|
| if (phishing_classifier_)
|
| - phishing_classifier_->PageCaptured(content,
|
| - capture_type == PRELIMINARY_CAPTURE);
|
| + phishing_classifier_->PageCaptured(content, is_preliminary_capture);
|
| #endif
|
| }
|
|
|