Commit ce7224f4 authored by avi@chromium.org's avatar avi@chromium.org

Remove page id from "page capture".

ChromeRenderViewObserver::CapturePageInfo is a relic. It hasn't captured page content for indexing for about a year now (r212459), and the fancy footwork to avoid re-indexing isn't needed any more.

BUG=371151
TEST=everything still works

Review URL: https://codereview.chromium.org/363293005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282479 0039d316-1c4b-4281-b951-d872f2087c98
parent bf171be1
...@@ -100,12 +100,6 @@ static const char kTranslateCaptureText[] = "Translate.CaptureText"; ...@@ -100,12 +100,6 @@ static const char kTranslateCaptureText[] = "Translate.CaptureText";
namespace { namespace {
GURL StripRef(const GURL& url) {
GURL::Replacements replacements;
replacements.ClearRef();
return url.ReplaceComponents(replacements);
}
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// Parses the DOM for a <meta> tag with a particular name. // Parses the DOM for a <meta> tag with a particular name.
// |meta_tag_content| is set to the contents of the 'content' attribute. // |meta_tag_content| is set to the contents of the 'content' attribute.
...@@ -165,7 +159,6 @@ ChromeRenderViewObserver::ChromeRenderViewObserver( ...@@ -165,7 +159,6 @@ ChromeRenderViewObserver::ChromeRenderViewObserver(
chrome_render_process_observer_(chrome_render_process_observer), chrome_render_process_observer_(chrome_render_process_observer),
translate_helper_(new TranslateHelper(render_view)), translate_helper_(new TranslateHelper(render_view)),
phishing_classifier_(NULL), phishing_classifier_(NULL),
last_indexed_page_id_(-1),
capture_timer_(false, false) { capture_timer_(false, false) {
const CommandLine& command_line = *CommandLine::ForCurrentProcess(); const CommandLine& command_line = *CommandLine::ForCurrentProcess();
if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection)) if (!command_line.HasSwitch(switches::kDisableClientSidePhishingDetection))
...@@ -357,7 +350,6 @@ void ChromeRenderViewObserver::DidStopLoading() { ...@@ -357,7 +350,6 @@ void ChromeRenderViewObserver::DidStopLoading() {
return; return;
CapturePageInfoLater( CapturePageInfoLater(
render_view()->GetPageId(),
false, // preliminary_capture false, // preliminary_capture
base::TimeDelta::FromMilliseconds( base::TimeDelta::FromMilliseconds(
render_view()->GetContentStateImmediately() ? render_view()->GetContentStateImmediately() ?
...@@ -371,29 +363,21 @@ void ChromeRenderViewObserver::DidCommitProvisionalLoad( ...@@ -371,29 +363,21 @@ void ChromeRenderViewObserver::DidCommitProvisionalLoad(
return; return;
CapturePageInfoLater( CapturePageInfoLater(
render_view()->GetPageId(),
true, // preliminary_capture true, // preliminary_capture
base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs)); base::TimeDelta::FromMilliseconds(kDelayForForcedCaptureMs));
} }
void ChromeRenderViewObserver::CapturePageInfoLater(int page_id, void ChromeRenderViewObserver::CapturePageInfoLater(bool preliminary_capture,
bool preliminary_capture,
base::TimeDelta delay) { base::TimeDelta delay) {
capture_timer_.Start( capture_timer_.Start(
FROM_HERE, FROM_HERE,
delay, delay,
base::Bind(&ChromeRenderViewObserver::CapturePageInfo, base::Bind(&ChromeRenderViewObserver::CapturePageInfo,
base::Unretained(this), base::Unretained(this),
page_id,
preliminary_capture)); preliminary_capture));
} }
void ChromeRenderViewObserver::CapturePageInfo(int page_id, void ChromeRenderViewObserver::CapturePageInfo(bool preliminary_capture) {
bool preliminary_capture) {
// If |page_id| is obsolete, we should stop indexing and capturing a page.
if (render_view()->GetPageId() != page_id)
return;
if (!render_view()->GetWebView()) if (!render_view()->GetWebView())
return; return;
...@@ -427,39 +411,6 @@ void ChromeRenderViewObserver::CapturePageInfo(int page_id, ...@@ -427,39 +411,6 @@ void ChromeRenderViewObserver::CapturePageInfo(int page_id,
if (translate_helper_) if (translate_helper_)
translate_helper_->PageCaptured(contents); translate_helper_->PageCaptured(contents);
// TODO(shess): Is indexing "Full text search" indexing? In that
// case more of this can go.
// Skip indexing if this is not a new load. Note that the case where
// page_id == last_indexed_page_id_ is more complicated, since we need to
// reindex if the toplevel URL has changed (such as from a redirect), even
// though this may not cause the page id to be incremented.
if (page_id < last_indexed_page_id_)
return;
bool same_page_id = last_indexed_page_id_ == page_id;
if (!preliminary_capture)
last_indexed_page_id_ = page_id;
// Get the URL for this page.
GURL url(main_frame->document().url());
if (url.is_empty()) {
if (!preliminary_capture)
last_indexed_url_ = GURL();
return;
}
// If the page id is unchanged, check whether the URL (ignoring fragments)
// has changed. If so, we need to reindex. Otherwise, assume this is a
// reload, in-page navigation, or some other load type where we don't want to
// reindex. Note: subframe navigations after onload increment the page id,
// so these will trigger a reindex.
GURL stripped_url(StripRef(url));
if (same_page_id && stripped_url == last_indexed_url_)
return;
if (!preliminary_capture)
last_indexed_url_ = stripped_url;
TRACE_EVENT0("renderer", "ChromeRenderViewObserver::CapturePageInfo"); TRACE_EVENT0("renderer", "ChromeRenderViewObserver::CapturePageInfo");
#if defined(FULL_SAFE_BROWSING) #if defined(FULL_SAFE_BROWSING)
......
...@@ -71,13 +71,12 @@ class ChromeRenderViewObserver : public content::RenderViewObserver { ...@@ -71,13 +71,12 @@ class ChromeRenderViewObserver : public content::RenderViewObserver {
void OnSetClientSidePhishingDetection(bool enable_phishing_detection); void OnSetClientSidePhishingDetection(bool enable_phishing_detection);
void OnSetWindowFeatures(const blink::WebWindowFeatures& window_features); void OnSetWindowFeatures(const blink::WebWindowFeatures& window_features);
void CapturePageInfoLater(int page_id, void CapturePageInfoLater(bool preliminary_capture,
bool preliminary_capture,
base::TimeDelta delay); base::TimeDelta delay);
// Captures the thumbnail and text contents for indexing for the given load // Captures the thumbnail and text contents for indexing for the given load
// ID. Kicks off analysis of the captured text. // ID. Kicks off analysis of the captured text.
void CapturePageInfo(int page_id, bool preliminary_capture); void CapturePageInfo(bool preliminary_capture);
// Retrieves the text from the given frame contents, the page text up to the // Retrieves the text from the given frame contents, the page text up to the
// maximum amount kMaxIndexChars will be placed into the given buffer. // maximum amount kMaxIndexChars will be placed into the given buffer.
...@@ -99,14 +98,6 @@ class ChromeRenderViewObserver : public content::RenderViewObserver { ...@@ -99,14 +98,6 @@ class ChromeRenderViewObserver : public content::RenderViewObserver {
TranslateHelper* translate_helper_; TranslateHelper* translate_helper_;
safe_browsing::PhishingClassifierDelegate* phishing_classifier_; safe_browsing::PhishingClassifierDelegate* phishing_classifier_;
// Page_id from the last page we indexed. This prevents us from indexing the
// same page twice in a row.
int32 last_indexed_page_id_;
// The toplevel URL that was last indexed. This is used together with the
// page id to decide whether to reindex in certain cases like history
// replacement.
GURL last_indexed_url_;
// A color page overlay when visually de-emaphasized. // A color page overlay when visually de-emaphasized.
scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_; scoped_ptr<WebViewColorOverlay> dimmed_color_overlay_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment