diff options
-rw-r--r-- | build/common.gypi | 9 | ||||
-rw-r--r-- | chrome/browser/chrome_browser_main.cc | 7 | ||||
-rw-r--r-- | chrome/chrome_browser.gypi | 11 | ||||
-rw-r--r-- | chrome/chrome_browser_ui.gypi | 1 | ||||
-rw-r--r-- | chrome/chrome_renderer.gypi | 10 | ||||
-rw-r--r-- | chrome/chrome_tests.gypi | 5 | ||||
-rw-r--r-- | chrome/renderer/translate_helper.cc | 12 | ||||
-rw-r--r-- | chrome/renderer/translate_helper.h | 2 |
8 files changed, 51 insertions, 6 deletions
diff --git a/build/common.gypi b/build/common.gypi index a660001..6a0205b 100644 --- a/build/common.gypi +++ b/build/common.gypi @@ -286,6 +286,9 @@ # Enable browser automation. 'enable_automation%': 1, + # Enable language detection. + 'enable_language_detection%': 1, + # Enable printing support and UI. 'enable_printing%': 1, @@ -459,6 +462,7 @@ ['OS=="android"', { 'enable_extensions%': 0, + 'enable_language_detection%': 0, 'enable_printing%': 0, 'enable_themes%': 0, 'enable_webrtc%': 0, @@ -471,6 +475,7 @@ 'disable_ftp_support%': 1, 'enable_automation%': 0, 'enable_extensions%': 0, + 'enable_language_detection%': 0, 'enable_printing%': 0, 'enable_session_service%': 0, 'enable_themes%': 0, @@ -654,6 +659,7 @@ 'test_isolation_outdir%': '<(test_isolation_outdir)', 'enable_automation%': '<(enable_automation)', 'enable_printing%': '<(enable_printing)', + 'enable_language_detection%': '<(enable_language_detection)', 'enable_captive_portal_detection%': '<(enable_captive_portal_detection)', 'disable_ftp_support%': '<(disable_ftp_support)', 'enable_task_manager%': '<(enable_task_manager)', @@ -1782,6 +1788,9 @@ ['enable_automation==1', { 'defines': ['ENABLE_AUTOMATION=1'], }], + ['enable_language_detection==1', { + 'defines': ['ENABLE_LANGUAGE_DETECTION=1'], + }], ['enable_printing==1', { 'defines': ['ENABLE_PRINTING=1'], }], diff --git a/chrome/browser/chrome_browser_main.cc b/chrome/browser/chrome_browser_main.cc index 3f75904..c3f29b5 100644 --- a/chrome/browser/chrome_browser_main.cc +++ b/chrome/browser/chrome_browser_main.cc @@ -46,7 +46,6 @@ #include "chrome/browser/google/google_search_counter.h" #include "chrome/browser/google/google_util.h" #include "chrome/browser/jankometer.h" -#include "chrome/browser/language_usage_metrics.h" #include "chrome/browser/managed_mode/managed_mode.h" #include "chrome/browser/metrics/field_trial_synchronizer.h" #include "chrome/browser/metrics/metrics_log.h" @@ -170,6 +169,10 @@ #include "policy/policy_constants.h" #endif +#if defined(ENABLE_LANGUAGE_DETECTION) +#include "chrome/browser/language_usage_metrics.h" +#endif + #if defined(ENABLE_RLZ) #include "chrome/browser/rlz/rlz.h" #endif @@ -1334,10 +1337,12 @@ int ChromeBrowserMainParts::PreMainMessageLoopRunImpl() { HandleTestParameters(parsed_command_line()); RecordBreakpadStatusUMA(browser_process_->metrics_service()); about_flags::RecordUMAStatistics(local_state_); +#if defined(ENABLE_LANGUAGE_DETECTION) LanguageUsageMetrics::RecordAcceptLanguages( profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); LanguageUsageMetrics::RecordApplicationLanguage( browser_process_->GetApplicationLocale()); +#endif // The extension service may be available at this point. If the command line // specifies --uninstall-extension, attempt the uninstall extension startup diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi index 1e766bc..251f94b 100644 --- a/chrome/chrome_browser.gypi +++ b/chrome/chrome_browser.gypi @@ -2162,7 +2162,6 @@ '../ppapi/ppapi_internal.gyp:ppapi_ipc', # For PpapiMsg_LoadPlugin '../printing/printing.gyp:printing', '../third_party/adobe/flash/flash_player.gyp:flapper_version_h', - '../third_party/cld/cld.gyp:cld', '../third_party/expat/expat.gyp:expat', '../third_party/hunspell/hunspell.gyp:hunspell', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', @@ -2564,6 +2563,16 @@ ['exclude', '^browser/automation/'], ], }], + ['enable_language_detection==0', { + 'sources!': [ + 'browser/language_usage_metrics.cc', + 'browser/language_usage_metrics.h', + ], + }, { # enable_language_detection==1 + 'dependencies': [ + '../third_party/cld/cld.gyp:cld', + ], + }], ['enable_printing!=1', { 'sources/': [ ['exclude', '^browser/ui/webui/print_preview/'], diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi index 770ec8e..5898e12 100644 --- a/chrome/chrome_browser_ui.gypi +++ b/chrome/chrome_browser_ui.gypi @@ -2098,7 +2098,6 @@ '../ppapi/ppapi_internal.gyp:ppapi_ipc', # For PpapiMsg_LoadPlugin '../printing/printing.gyp:printing', '../third_party/adobe/flash/flash_player.gyp:flapper_version_h', - '../third_party/cld/cld.gyp:cld', '../third_party/expat/expat.gyp:expat', '../third_party/hunspell/hunspell.gyp:hunspell', '../third_party/leveldatabase/leveldatabase.gyp:leveldatabase', diff --git a/chrome/chrome_renderer.gypi b/chrome/chrome_renderer.gypi index 7c3f5da8..4f1a067 100644 --- a/chrome/chrome_renderer.gypi +++ b/chrome/chrome_renderer.gypi @@ -21,7 +21,6 @@ '../ppapi/ppapi_internal.gyp:ppapi_shared', '../printing/printing.gyp:printing', '../skia/skia.gyp:skia', - '../third_party/cld/cld.gyp:cld', '../third_party/hunspell/hunspell.gyp:hunspell', '../third_party/icu/icu.gyp:icui18n', '../third_party/icu/icu.gyp:icuuc', @@ -35,7 +34,6 @@ ], 'include_dirs': [ '..', - '../third_party/cld', ], 'defines': [ '<@(nacl_defines)', @@ -303,6 +301,14 @@ '../third_party/mach_override/mach_override.gyp:mach_override', ], }], + ['enable_language_detection==1', { + 'dependencies': [ + '../third_party/cld/cld.gyp:cld', + ], + 'include_dirs': [ + '../third_party/cld', + ], + }], ['toolkit_uses_gtk == 1', { 'dependencies': [ '../build/linux/system.gyp:gtk', diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 66f5035..4988f19 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2700,6 +2700,11 @@ ['exclude', '^browser/themes/'], ], }], + ['enable_language_detection==0', { + 'sources!': [ + 'browser/language_usage_metrics_unittest.cc', + ], + }], ['enable_plugin_installation==0', { 'sources!': [ ], diff --git a/chrome/renderer/translate_helper.cc b/chrome/renderer/translate_helper.cc index e2d23bf..d2ae5ef 100644 --- a/chrome/renderer/translate_helper.cc +++ b/chrome/renderer/translate_helper.cc @@ -19,10 +19,13 @@ #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebScriptSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h" -#include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h" #include "v8/include/v8.h" #include "webkit/glue/dom_operations.h" +#if defined(ENABLE_LANGUAGE_DETECTION) +#include "third_party/cld/encodings/compact_lang_det/win/cld_unicodetext.h" +#endif + using WebKit::WebDocument; using WebKit::WebElement; using WebKit::WebFrame; @@ -80,6 +83,7 @@ void TranslateHelper::PageCaptured(const string16& contents) { TrimWhitespaceASCII(language, TRIM_ALL, &language); language = StringToLowerASCII(language); +#if defined(ENABLE_LANGUAGE_DETECTION) if (language.empty()) { base::TimeTicks begin_time = base::TimeTicks::Now(); language = DetermineTextLanguage(contents); @@ -88,6 +92,10 @@ void TranslateHelper::PageCaptured(const string16& contents) { } else { VLOG(9) << "PageLanguageFromMetaTag: " << language; } +#else + if (language.empty()) + return; +#endif // defined(ENABLE_LANGUAGE_DETECTION) Send(new ChromeViewHostMsg_TranslateLanguageDetermined( routing_id(), language, IsPageTranslatable(&document))); @@ -121,6 +129,7 @@ bool TranslateHelper::IsPageTranslatable(WebDocument* document) { return true; } +#if defined(ENABLE_LANGUAGE_DETECTION) // static std::string TranslateHelper::DetermineTextLanguage(const string16& text) { std::string language = chrome::kUnknownLanguageCode; @@ -147,6 +156,7 @@ std::string TranslateHelper::DetermineTextLanguage(const string16& text) { << "\n*************************************\n"; return language; } +#endif // defined(ENABLE_LANGUAGE_DETECTION) //////////////////////////////////////////////////////////////////////////////// // TranslateHelper, protected: diff --git a/chrome/renderer/translate_helper.h b/chrome/renderer/translate_helper.h index de7afa3..88a1a15 100644 --- a/chrome/renderer/translate_helper.h +++ b/chrome/renderer/translate_helper.h @@ -70,9 +70,11 @@ class TranslateHelper : public content::RenderViewObserver { // should not be translated. static bool IsPageTranslatable(WebKit::WebDocument* document); +#if defined(ENABLE_LANGUAGE_DETECTION) // Returns the ISO 639_1 language code of the specified |text|, or 'unknown' // if it failed. static std::string DetermineTextLanguage(const string16& text); +#endif // RenderViewObserver implementation. virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |