diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 23:25:52 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-01-07 23:25:52 +0000 |
commit | 7893a989c3e8cfa8f9cc25547025d541c1205ef4 (patch) | |
tree | 2ae568e48c773ec1c1bf614ca5ba326f9327d0d7 /chrome/renderer | |
parent | 59a10b95b43a0b78ec3153ed21f2b1181a4a947e (diff) | |
download | chromium_src-7893a989c3e8cfa8f9cc25547025d541c1205ef4.zip chromium_src-7893a989c3e8cfa8f9cc25547025d541c1205ef4.tar.gz chromium_src-7893a989c3e8cfa8f9cc25547025d541c1205ef4.tar.bz2 |
Revert 35735 - Relanding the language detection code.
Still causes redness on the reliability bot.
The code would crash if multiple PageContents notifications
were received rapidly. The CLDHelper now notifies the
TabContents directly and the TabContents ensures only one
language detection can be performed at a time.
Added unittests to validate these cases in web_contents_unittest.cc.
Note that patch set 1 is the original patch, patch set 2 contains the new changes.
Original review:
http://codereview.chromium.org/492024/show
BUG=30662
TEST=Run the unittests.
Review URL: http://codereview.chromium.org/504051
TBR=jcampan@chromium.org
Review URL: http://codereview.chromium.org/523149
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@35753 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_view.cc | 43 | ||||
-rw-r--r-- | chrome/renderer/render_view.h | 3 |
2 files changed, 41 insertions, 5 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index d46f5e2..418bf4c 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -261,6 +261,7 @@ RenderView::RenderView(RenderThreadBase* render_thread, send_preferred_size_changes_(false), ALLOW_THIS_IN_INITIALIZER_LIST( notification_provider_(new NotificationProvider(this))), + determine_page_text_after_loading_stops_(false), view_type_(ViewType::INVALID), browser_window_id_(-1), last_top_level_navigation_page_id_(-1), @@ -445,6 +446,7 @@ void RenderView::OnMessageReceived(const IPC::Message& message) { IPC_MESSAGE_HANDLER(ViewMsg_CopyImageAt, OnCopyImageAt) IPC_MESSAGE_HANDLER(ViewMsg_ExecuteEditCommand, OnExecuteEditCommand) IPC_MESSAGE_HANDLER(ViewMsg_Find, OnFind) + IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText, OnDeterminePageText) IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom) IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost, OnSetZoomLevelForLoadingHost) @@ -596,18 +598,23 @@ void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { if (!preliminary_capture) last_indexed_page_id_ = load_id; - // Get the URL for this page. + // get the URL for this page GURL url(main_frame->url()); if (url.is_empty()) return; - // Retrieve the frame's full text. + // full text std::wstring contents; CaptureText(main_frame, &contents); if (contents.size()) { - // Send the text to the browser for indexing (the browser might decide not - // to index, if the URL is HTTPS for instance) and language discovery. - Send(new ViewHostMsg_PageContents(routing_id_, url, load_id, contents)); + // Send the text to the browser for indexing. + Send(new ViewHostMsg_PageContents(url, load_id, contents)); + } + + // Send over text content of this page to the browser. + if (determine_page_text_after_loading_stops_) { + determine_page_text_after_loading_stops_ = false; + Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents)); } // thumbnail @@ -619,6 +626,15 @@ void RenderView::CaptureText(WebFrame* frame, std::wstring* contents) { if (!frame) return; + // Don't index any https pages. People generally don't want their bank + // accounts, etc. indexed on their computer, especially since some of these + // things are not marked cachable. + // TODO(brettw) we may want to consider more elaborate heuristics such as + // the cachability of the page. We may also want to consider subframes (this + // test will still index subframes if the subframe is SSL). + if (GURL(frame->url()).SchemeIsSecure()) + return; + #ifdef TIME_TEXT_RETRIEVAL double begin = time_util::GetHighResolutionTimeNow(); #endif @@ -2966,6 +2982,23 @@ void RenderView::OnFind(int request_id, const string16& search_text, } } +void RenderView::OnDeterminePageText() { + if (!is_loading_) { + if (!webview()) + return; + WebFrame* main_frame = webview()->mainFrame(); + std::wstring contents; + CaptureText(main_frame, &contents); + Send(new ViewMsg_DeterminePageText_Reply(routing_id_, contents)); + determine_page_text_after_loading_stops_ = false; + return; + } + + // We set |determine_page_text_after_loading_stops_| true here so that, + // after page has been loaded completely, the text in the page is captured. + determine_page_text_after_loading_stops_ = true; +} + void RenderView::DnsPrefetch(const std::vector<std::string>& host_names) { Send(new ViewHostMsg_DnsPrefetch(host_names)); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 706f5f0..32ea8c6 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -934,6 +934,9 @@ class RenderView : public RenderWidget, // Hopds a reference to the service which provides desktop notifications. scoped_ptr<NotificationProvider> notification_provider_; + // Set to true if request for capturing page text has been made. + bool determine_page_text_after_loading_stops_; + // Holds state pertaining to a navigation that we initiated. This is held by // the WebDataSource::ExtraData attribute. We use pending_navigation_state_ // as a temporary holder for the state until the WebDataSource corresponding |