| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/browser/translate_ui_delegate.h" | 5 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 6 | 6 |
| 7 #include "base/i18n/string_compare.h" | 7 #include "base/i18n/string_compare.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "components/translate/core/browser/language_state.h" | 9 #include "components/translate/core/browser/language_state.h" |
| 10 #include "components/translate/core/browser/translate_client.h" | 10 #include "components/translate/core/browser/translate_client.h" |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 if (translate_manager_) { | 173 if (translate_manager_) { |
| 174 translate_manager_->RevertTranslation(); | 174 translate_manager_->RevertTranslation(); |
| 175 UMA_HISTOGRAM_BOOLEAN(kRevertTranslation, true); | 175 UMA_HISTOGRAM_BOOLEAN(kRevertTranslation, true); |
| 176 } | 176 } |
| 177 } | 177 } |
| 178 | 178 |
| 179 void TranslateUIDelegate::TranslationDeclined(bool explicitly_closed) { | 179 void TranslateUIDelegate::TranslationDeclined(bool explicitly_closed) { |
| 180 if (!translate_driver_->IsOffTheRecord()) { | 180 if (!translate_driver_->IsOffTheRecord()) { |
| 181 prefs_->ResetTranslationAcceptedCount(GetOriginalLanguageCode()); | 181 prefs_->ResetTranslationAcceptedCount(GetOriginalLanguageCode()); |
| 182 prefs_->IncrementTranslationDeniedCount(GetOriginalLanguageCode()); | 182 prefs_->IncrementTranslationDeniedCount(GetOriginalLanguageCode()); |
| 183 prefs_->UpdateLastDeniedTime(); |
| 183 } | 184 } |
| 184 | 185 |
| 185 // Remember that the user declined the translation so as to prevent showing a | 186 // Remember that the user declined the translation so as to prevent showing a |
| 186 // translate infobar for that page again. (TranslateManager initiates | 187 // translate UI for that page again. (TranslateManager initiates translations |
| 187 // translations when getting a LANGUAGE_DETERMINED from the page, which | 188 // when getting a LANGUAGE_DETERMINED from the page, which happens when a load |
| 188 // happens when a load stops. That could happen multiple times, including | 189 // stops. That could happen multiple times, including after the user already |
| 189 // after the user already declined the translation.) | 190 // declined the translation.) |
| 190 if (translate_manager_) { | 191 if (translate_manager_) { |
| 191 translate_manager_->GetLanguageState().set_translation_declined(true); | 192 translate_manager_->GetLanguageState().set_translation_declined(true); |
| 192 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslate, true); | 193 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslate, true); |
| 193 } | 194 } |
| 194 | 195 |
| 195 if (!explicitly_closed) | 196 if (!explicitly_closed) |
| 196 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslateDismissUI, true); | 197 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslateDismissUI, true); |
| 197 } | 198 } |
| 198 | 199 |
| 199 bool TranslateUIDelegate::IsLanguageBlocked() { | 200 bool TranslateUIDelegate::IsLanguageBlocked() { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 prefs_->RemoveLanguagePairFromWhitelist(original_lang, target_lang); | 250 prefs_->RemoveLanguagePairFromWhitelist(original_lang, target_lang); |
| 250 | 251 |
| 251 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true); | 252 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true); |
| 252 } | 253 } |
| 253 | 254 |
| 254 std::string TranslateUIDelegate::GetPageHost() { | 255 std::string TranslateUIDelegate::GetPageHost() { |
| 255 if (!translate_driver_->HasCurrentPage()) | 256 if (!translate_driver_->HasCurrentPage()) |
| 256 return std::string(); | 257 return std::string(); |
| 257 return translate_driver_->GetActiveURL().HostNoBrackets(); | 258 return translate_driver_->GetActiveURL().HostNoBrackets(); |
| 258 } | 259 } |
| OLD | NEW |