OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/translate/translate_manager.h" | 5 #include "chrome/browser/translate/translate_manager.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/singleton.h" | 10 #include "base/memory/singleton.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 #include "content/public/browser/render_view_host.h" | 51 #include "content/public/browser/render_view_host.h" |
52 #include "content/public/browser/web_contents.h" | 52 #include "content/public/browser/web_contents.h" |
53 #include "google_apis/google_api_keys.h" | 53 #include "google_apis/google_api_keys.h" |
54 #include "grit/browser_resources.h" | 54 #include "grit/browser_resources.h" |
55 #include "net/base/escape.h" | 55 #include "net/base/escape.h" |
56 #include "net/base/load_flags.h" | 56 #include "net/base/load_flags.h" |
57 #include "net/base/url_util.h" | 57 #include "net/base/url_util.h" |
58 #include "net/http/http_status_code.h" | 58 #include "net/http/http_status_code.h" |
59 #include "net/url_request/url_fetcher.h" | 59 #include "net/url_request/url_fetcher.h" |
60 #include "net/url_request/url_request_status.h" | 60 #include "net/url_request/url_request_status.h" |
| 61 #include "ui/base/l10n/l10n_util.h" |
61 #include "ui/base/resource/resource_bundle.h" | 62 #include "ui/base/resource/resource_bundle.h" |
62 | 63 |
63 #ifdef FILE_MANAGER_EXTENSION | 64 #ifdef FILE_MANAGER_EXTENSION |
64 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" | 65 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" |
65 #include "extensions/common/constants.h" | 66 #include "extensions/common/constants.h" |
66 #endif | 67 #endif |
67 | 68 |
68 using content::NavigationController; | 69 using content::NavigationController; |
69 using content::NavigationEntry; | 70 using content::NavigationEntry; |
70 using content::WebContents; | 71 using content::WebContents; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 TranslateManagerMetrics::ReportInitiationStatus( | 416 TranslateManagerMetrics::ReportInitiationStatus( |
416 TranslateManagerMetrics::INITIATION_STATUS_ACCEPT_LANGUAGES); | 417 TranslateManagerMetrics::INITIATION_STATUS_ACCEPT_LANGUAGES); |
417 return; | 418 return; |
418 } | 419 } |
419 | 420 |
420 // Nothing to do if either the language Chrome is in or the language of the | 421 // Nothing to do if either the language Chrome is in or the language of the |
421 // page is not supported by the translation server. | 422 // page is not supported by the translation server. |
422 if (target_lang.empty() || !IsSupportedLanguage(language_code)) { | 423 if (target_lang.empty() || !IsSupportedLanguage(language_code)) { |
423 TranslateManagerMetrics::ReportInitiationStatus( | 424 TranslateManagerMetrics::ReportInitiationStatus( |
424 TranslateManagerMetrics::INITIATION_STATUS_LANGUAGE_IS_NOT_SUPPORTED); | 425 TranslateManagerMetrics::INITIATION_STATUS_LANGUAGE_IS_NOT_SUPPORTED); |
| 426 TranslateManagerMetrics::ReportUnsupportedLanguageAtInitiation( |
| 427 language_code); |
| 428 |
425 return; | 429 return; |
426 } | 430 } |
427 | 431 |
428 // Don't translate any user black-listed URLs or user selected language | 432 // Don't translate any user black-listed URLs or user selected language |
429 // combination. | 433 // combination. |
430 if (!TranslatePrefs::CanTranslate(prefs, language_code, page_url)) { | 434 if (!TranslatePrefs::CanTranslate(prefs, language_code, page_url)) { |
431 TranslateManagerMetrics::ReportInitiationStatus( | 435 TranslateManagerMetrics::ReportInitiationStatus( |
432 TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_CONFIG); | 436 TranslateManagerMetrics::INITIATION_STATUS_DISABLED_BY_CONFIG); |
433 return; | 437 return; |
434 } | 438 } |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
803 // reason so we are more aggressive showing the shortcuts for never translate. | 807 // reason so we are more aggressive showing the shortcuts for never translate. |
804 #if defined(OS_ANDROID) | 808 #if defined(OS_ANDROID) |
805 config.never_translate_min_count = 1; | 809 config.never_translate_min_count = 1; |
806 #else | 810 #else |
807 config.never_translate_min_count = 3; | 811 config.never_translate_min_count = 3; |
808 #endif // defined(OS_ANDROID) | 812 #endif // defined(OS_ANDROID) |
809 | 813 |
810 config.always_translate_min_count = 3; | 814 config.always_translate_min_count = 3; |
811 return config; | 815 return config; |
812 } | 816 } |
OLD | NEW |