summaryrefslogtreecommitdiffstats
path: root/chrome/browser/renderer_host/render_view_host.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/renderer_host/render_view_host.cc')
-rw-r--r--chrome/browser/renderer_host/render_view_host.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc
index 8e8f161..b41c04c 100644
--- a/chrome/browser/renderer_host/render_view_host.cc
+++ b/chrome/browser/renderer_host/render_view_host.cc
@@ -41,6 +41,8 @@
#if defined(OS_WIN)
// TODO(port): accessibility not yet implemented. See http://crbug.com/8288.
#include "chrome/browser/browser_accessibility_manager.h"
+// TODO(port): The compact language detection library works only for Windows.
+#include "third_party/cld/bar/toolbar/cld/i18n/encodings/compact_lang_det/win/cld_unicodetext.h"
#endif
using base::TimeDelta;
@@ -410,6 +412,10 @@ void RenderViewHost::StopFinding(bool clear_selection) {
Send(new ViewMsg_StopFinding(routing_id(), clear_selection));
}
+void RenderViewHost::GetPageLanguage() {
+ Send(new ViewMsg_DeterminePageText(routing_id()));
+}
+
void RenderViewHost::Zoom(PageZoom::Function function) {
Send(new ViewMsg_Zoom(routing_id(), function));
}
@@ -726,6 +732,8 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_MESSAGE_HANDLER(ViewHostMsg_DidFailProvisionalLoadWithError,
OnMsgDidFailProvisionalLoadWithError)
IPC_MESSAGE_HANDLER(ViewHostMsg_Find_Reply, OnMsgFindReply)
+ IPC_MESSAGE_HANDLER(ViewMsg_DeterminePageText_Reply,
+ OnDeterminePageTextReply)
IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFavIconURL, OnMsgUpdateFavIconURL)
IPC_MESSAGE_HANDLER(ViewHostMsg_DidDownloadFavIcon, OnMsgDidDownloadFavIcon)
IPC_MESSAGE_HANDLER(ViewHostMsg_ContextMenu, OnMsgContextMenu)
@@ -1058,6 +1066,21 @@ void RenderViewHost::OnMsgFindReply(int request_id,
Send(new ViewMsg_FindReplyACK(routing_id()));
}
+void RenderViewHost::OnDeterminePageTextReply(
+ const std::wstring& page_text) {
+#if defined(OS_WIN) // Only for windows.
+ int num_languages = 0;
+ bool is_reliable = false;
+ const char* language_char = LanguageName(DetectLanguageOfUnicodeText(
+ page_text.c_str(), true, &is_reliable, &num_languages, NULL));
+ std::string language(language_char);
+ NotificationService::current()->Notify(
+ NotificationType::TAB_LANGUAGE_DETERMINED,
+ Source<RenderViewHost>(this),
+ Details<std::string>(&language));
+#endif
+}
+
void RenderViewHost::OnMsgUpdateFavIconURL(int32 page_id,
const GURL& icon_url) {
RenderViewHostDelegate::FavIcon* favicon_delegate =