summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_view.cc
diff options
context:
space:
mode:
authorjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 21:23:27 +0000
committerjshin@chromium.org <jshin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-19 21:23:27 +0000
commitfd2a9927ec151327e710f1fca66f5620e24f98dd (patch)
treea279b0d43bbde75c84f3eb5c3d449be63ea56628 /chrome/renderer/render_view.cc
parent225c5084d41efb256a2876180306d5484c7d0668 (diff)
downloadchromium_src-fd2a9927ec151327e710f1fca66f5620e24f98dd.zip
chromium_src-fd2a9927ec151327e710f1fca66f5620e24f98dd.tar.gz
chromium_src-fd2a9927ec151327e710f1fca66f5620e24f98dd.tar.bz2
Revert 36541 (which went in without any commit log by some black magic).
Reland it with the commit log for the record. Review URL: http://codereview.chromium.org/545123 TBR=jshin@chromium.org Review URL: http://codereview.chromium.org/551070 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36550 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_view.cc')
-rw-r--r--chrome/renderer/render_view.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index dcbda82..5b1ee82 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -67,7 +67,10 @@
#include "net/base/net_errors.h"
#include "skia/ext/bitmap_platform_device.h"
#include "skia/ext/image_operations.h"
+#if defined(OS_WIN)
+// 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
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityCache.h"
#include "third_party/WebKit/WebKit/chromium/public/WebAccessibilityObject.h"
#include "third_party/WebKit/WebKit/chromium/public/WebCString.h"
@@ -220,7 +223,7 @@ static const char* const kUnreachableWebDataURL =
static const char* const kBackForwardNavigationScheme = "history";
// The string returned in DetectLanguage if we failed to detect the language.
-static const char* const kUnknownLanguageCode = "und";
+static const char* const kUnknownLanguageCode = "unknown";
static void GetRedirectChain(WebDataSource* ds, std::vector<GURL>* result) {
WebVector<WebURL> urls;
@@ -3079,29 +3082,31 @@ std::string RenderView::DetectLanguage() {
if (!webview() || is_loading_)
return kUnknownLanguageCode;
+ std::string language = kUnknownLanguageCode;
+#if defined(OS_WIN) // CLD is only available on Windows at this time.
WebFrame* main_frame = webview()->mainFrame();
std::wstring contents;
CaptureText(main_frame, &contents);
- return DetermineTextLanguage(contents);
+ language = DetermineTextLanguage(contents);
+#endif
+
+ return language;
}
// static
std::string RenderView::DetermineTextLanguage(const std::wstring& text) {
std::string language = kUnknownLanguageCode;
+#if defined(OS_WIN) // CLD is only available on Windows at this time.
int num_languages = 0;
bool is_reliable = false;
- string16 input = WideToUTF16(text);
Language cld_language =
- DetectLanguageOfUnicodeText(NULL, input.c_str(), true, &is_reliable,
+ DetectLanguageOfUnicodeText(NULL, text.c_str(), true, &is_reliable,
&num_languages, NULL);
if (cld_language != NUM_LANGUAGES && cld_language != UNKNOWN_LANGUAGE &&
cld_language != TG_UNKNOWN_LANGUAGE) {
- // We should not use LanguageCode_ISO_639_1 because it does not cover all the
- // languages CLD can detect. As a result, it'll return the invalid language
- // code for tradtional Chinese among others. |LanguageCode| will go through
- // ISO 639-1, ISO-639-2 and 'other' tables to do the 'right' thing.
- language = LanguageCode(cld_language);
+ language = LanguageCodeISO639_1(cld_language);
}
+#endif
return language;
}