| 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/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 web_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( | 701 web_contents->GetRenderViewHost()->Send(new ChromeViewMsg_RevertTranslation( |
| 702 web_contents->GetRenderViewHost()->GetRoutingID(), entry->GetPageID())); | 702 web_contents->GetRenderViewHost()->GetRoutingID(), entry->GetPageID())); |
| 703 | 703 |
| 704 TranslateTabHelper* translate_tab_helper = | 704 TranslateTabHelper* translate_tab_helper = |
| 705 TranslateTabHelper::FromWebContents(web_contents); | 705 TranslateTabHelper::FromWebContents(web_contents); |
| 706 translate_tab_helper->language_state().set_current_language( | 706 translate_tab_helper->language_state().set_current_language( |
| 707 translate_tab_helper->language_state().original_language()); | 707 translate_tab_helper->language_state().original_language()); |
| 708 } | 708 } |
| 709 | 709 |
| 710 void TranslateManager::ReportLanguageDetectionError(WebContents* web_contents) { | 710 void TranslateManager::ReportLanguageDetectionError(WebContents* web_contents) { |
| 711 UMA_HISTOGRAM_COUNTS("Translate.ReportLanguageDetectionError", 1); | 711 TranslateManagerMetrics::ReportLanguageDetectionError(); |
| 712 // We'll open the URL in a new tab so that the user can tell us more. | 712 // We'll open the URL in a new tab so that the user can tell us more. |
| 713 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); | 713 Browser* browser = chrome::FindBrowserWithWebContents(web_contents); |
| 714 if (!browser) { | 714 if (!browser) { |
| 715 NOTREACHED(); | 715 NOTREACHED(); |
| 716 return; | 716 return; |
| 717 } | 717 } |
| 718 | 718 |
| 719 GURL report_error_url = GURL(kReportLanguageDetectionErrorURL); | 719 GURL report_error_url = GURL(kReportLanguageDetectionErrorURL); |
| 720 | 720 |
| 721 GURL page_url = web_contents->GetController().GetActiveEntry()->GetURL(); | 721 GURL page_url = web_contents->GetController().GetActiveEntry()->GetURL(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 759 translate_script, source_lang, target_lang)); | 759 translate_script, source_lang, target_lang)); |
| 760 } | 760 } |
| 761 | 761 |
| 762 void TranslateManager::PageTranslated(WebContents* web_contents, | 762 void TranslateManager::PageTranslated(WebContents* web_contents, |
| 763 PageTranslatedDetails* details) { | 763 PageTranslatedDetails* details) { |
| 764 if ((details->error_type == TranslateErrors::NONE) && | 764 if ((details->error_type == TranslateErrors::NONE) && |
| 765 !IsSupportedLanguage(details->source_language)) { | 765 !IsSupportedLanguage(details->source_language)) { |
| 766 // TODO(jcivelli): http://crbug.com/9390 We should change the "after | 766 // TODO(jcivelli): http://crbug.com/9390 We should change the "after |
| 767 // translate" infobar to support unknown as the original | 767 // translate" infobar to support unknown as the original |
| 768 // language. | 768 // language. |
| 769 UMA_HISTOGRAM_COUNTS("Translate.ServerReportedUnsupportedLanguage", 1); | 769 TranslateManagerMetrics::ReportUnsupportedLanguage(); |
| 770 details->error_type = TranslateErrors::UNSUPPORTED_LANGUAGE; | 770 details->error_type = TranslateErrors::UNSUPPORTED_LANGUAGE; |
| 771 } | 771 } |
| 772 Profile* profile = | 772 Profile* profile = |
| 773 Profile::FromBrowserContext(web_contents->GetBrowserContext()); | 773 Profile::FromBrowserContext(web_contents->GetBrowserContext()); |
| 774 PrefService* prefs = profile->GetPrefs(); | 774 PrefService* prefs = profile->GetPrefs(); |
| 775 TranslateInfoBarDelegate::Create( | 775 TranslateInfoBarDelegate::Create( |
| 776 InfoBarService::FromWebContents(web_contents), true, | 776 InfoBarService::FromWebContents(web_contents), true, |
| 777 (details->error_type == TranslateErrors::NONE) ? | 777 (details->error_type == TranslateErrors::NONE) ? |
| 778 TranslateInfoBarDelegate::AFTER_TRANSLATE : | 778 TranslateInfoBarDelegate::AFTER_TRANSLATE : |
| 779 TranslateInfoBarDelegate::TRANSLATION_ERROR, | 779 TranslateInfoBarDelegate::TRANSLATION_ERROR, |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 963 // reason so we are more aggressive showing the shortcuts for never translate. | 963 // reason so we are more aggressive showing the shortcuts for never translate. |
| 964 #if defined(OS_ANDROID) | 964 #if defined(OS_ANDROID) |
| 965 config.never_translate_min_count = 1; | 965 config.never_translate_min_count = 1; |
| 966 #else | 966 #else |
| 967 config.never_translate_min_count = 3; | 967 config.never_translate_min_count = 3; |
| 968 #endif // defined(OS_ANDROID) | 968 #endif // defined(OS_ANDROID) |
| 969 | 969 |
| 970 config.always_translate_min_count = 3; | 970 config.always_translate_min_count = 3; |
| 971 return config; | 971 return config; |
| 972 } | 972 } |
| OLD | NEW |