Index: chrome/renderer/render_view.cc |
=================================================================== |
--- chrome/renderer/render_view.cc (revision 36549) |
+++ chrome/renderer/render_view.cc (working copy) |
@@ -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 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 @@ |
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; |
} |