summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 01:59:20 +0000
committerjcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-16 01:59:20 +0000
commit89f0e7493eb6d5a1a8001e975d0b1c45c47e9fc7 (patch)
treee893a2df5a13287114ac5e9411088e4e15677dea /chrome/renderer
parent8df1420fda46cf3dcfd8c4a6cb67446d92e81309 (diff)
downloadchromium_src-89f0e7493eb6d5a1a8001e975d0b1c45c47e9fc7.zip
chromium_src-89f0e7493eb6d5a1a8001e975d0b1c45c47e9fc7.tar.gz
chromium_src-89f0e7493eb6d5a1a8001e975d0b1c45c47e9fc7.tar.bz2
Revert 36442 - Still causing test failures
4th attempt at landing this. It caused several tests to fails previously. Cannot repro any of the failure. I am suspecting a clobber would have probably fixed it. (there is a change in one of the IPC messages that probably messed up the build somehow). No code change. Enabling language detection on page load. A memory error has been fixed in the CLD library in the meantime. This should hopefully fixes the crashers in the reliability tests. Note that this version is actually simpler than the original review since the detection is now performed in the renderer. (So the CLD code runs sandboxed.) Original review: http://codereview.chromium.org/492024/show BUG=30662 TEST=Run the unittests. TBR=brettw Review URL: http://codereview.chromium.org/548057 TBR=jcampan@chromium.org Review URL: http://codereview.chromium.org/536085 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36447 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/render_view.cc53
-rw-r--r--chrome/renderer/render_view.h3
2 files changed, 35 insertions, 21 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index a43c011..649542f 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -304,6 +304,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),
@@ -494,6 +495,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_DeterminePageLanguage, OnDeterminePageLanguage)
IPC_MESSAGE_HANDLER(ViewMsg_Zoom, OnZoom)
IPC_MESSAGE_HANDLER(ViewMsg_SetZoomLevelForLoadingHost,
OnSetZoomLevelForLoadingHost)
@@ -664,35 +666,24 @@ 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()) {
- std::string language = "unknown";
-#if defined(OS_WIN)
- int num_languages = 0;
- bool is_reliable = false;
- base::TimeTicks begin_time = base::TimeTicks::Now();
- Language cld_lang =
- DetectLanguageOfUnicodeText(NULL, contents.c_str(), true,
- &is_reliable, &num_languages, NULL);
- if (cld_lang != NUM_LANGUAGES && cld_lang != UNKNOWN_LANGUAGE &&
- cld_lang != TG_UNKNOWN_LANGUAGE) {
- language = LanguageCodeISO639_1(cld_lang);
- }
- UMA_HISTOGRAM_MEDIUM_TIMES("Renderer4.LanguageDetection",
- base::TimeTicks::Now() - begin_time);
-#endif
+ // Send the text to the browser for indexing.
+ Send(new ViewHostMsg_PageContents(url, load_id, contents));
+ }
- // 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,
- language));
+ // Now that we have the contents, we can determine the language if necessary.
+ if (determine_page_text_after_loading_stops_) {
+ determine_page_text_after_loading_stops_ = false;
+ Send(new ViewHostMsg_PageLanguageDetermined(
+ routing_id_, DetermineTextLanguage(contents)));
}
// thumbnail
@@ -704,6 +695,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
@@ -3067,6 +3067,17 @@ void RenderView::OnFind(int request_id, const string16& search_text,
}
}
+void RenderView::OnDeterminePageLanguage() {
+ if (is_loading_) {
+ // Wait for the page to finish loading before trying to determine the
+ // language.
+ determine_page_text_after_loading_stops_ = true;
+ return;
+ }
+
+ Send(new ViewHostMsg_PageLanguageDetermined(routing_id_, DetectLanguage()));
+}
+
std::string RenderView::DetectLanguage() {
if (!webview() || is_loading_)
return kUnknownLanguageCode;
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 3e178ce..4d3a4e9 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -956,6 +956,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