Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(460)

Side by Side Diff: components/translate/core/browser/translate_ui_delegate.cc

Issue 1632953002: Change the TranslateDeclined() to only count decline if the explicit_closed is set to true (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix mac unit test breakage Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_macros.h" 8 #include "base/metrics/histogram_macros.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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 } 215 }
216 216
217 void TranslateUIDelegate::RevertTranslation() { 217 void TranslateUIDelegate::RevertTranslation() {
218 if (translate_manager_) { 218 if (translate_manager_) {
219 translate_manager_->RevertTranslation(); 219 translate_manager_->RevertTranslation();
220 UMA_HISTOGRAM_BOOLEAN(kRevertTranslation, true); 220 UMA_HISTOGRAM_BOOLEAN(kRevertTranslation, true);
221 } 221 }
222 } 222 }
223 223
224 void TranslateUIDelegate::TranslationDeclined(bool explicitly_closed) { 224 void TranslateUIDelegate::TranslationDeclined(bool explicitly_closed) {
225 if (!translate_driver_->IsOffTheRecord()) { 225 if (explicitly_closed && !translate_driver_->IsOffTheRecord()) {
226 const std::string& language = GetOriginalLanguageCode(); 226 const std::string& language = GetOriginalLanguageCode();
227 prefs_->ResetTranslationAcceptedCount(language); 227 prefs_->ResetTranslationAcceptedCount(language);
228 prefs_->IncrementTranslationDeniedCount(language); 228 prefs_->IncrementTranslationDeniedCount(language);
229 prefs_->UpdateLastDeniedTime(language); 229 prefs_->UpdateLastDeniedTime(language);
230 } 230 }
231 231
232 // Remember that the user declined the translation so as to prevent showing a 232 // Remember that the user declined the translation so as to prevent showing a
233 // translate UI for that page again. (TranslateManager initiates translations 233 // translate UI for that page again. (TranslateManager initiates translations
234 // when getting a LANGUAGE_DETERMINED from the page, which happens when a load 234 // when getting a LANGUAGE_DETERMINED from the page, which happens when a load
235 // stops. That could happen multiple times, including after the user already 235 // stops. That could happen multiple times, including after the user already
236 // declined the translation.) 236 // declined the translation.)
237 if (translate_manager_) { 237 if (explicitly_closed && translate_manager_) {
238 translate_manager_->GetLanguageState().set_translation_declined(true); 238 translate_manager_->GetLanguageState().set_translation_declined(true);
239 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslate, true); 239 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslate, true);
240 } 240 }
241 241
242 if (!explicitly_closed) 242 if (!explicitly_closed) {
243 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslateDismissUI, true); 243 UMA_HISTOGRAM_BOOLEAN(kDeclineTranslateDismissUI, true);
244 }
244 } 245 }
245 246
246 bool TranslateUIDelegate::IsLanguageBlocked() { 247 bool TranslateUIDelegate::IsLanguageBlocked() {
247 return prefs_->IsBlockedLanguage(GetOriginalLanguageCode()); 248 return prefs_->IsBlockedLanguage(GetOriginalLanguageCode());
248 } 249 }
249 250
250 void TranslateUIDelegate::SetLanguageBlocked(bool value) { 251 void TranslateUIDelegate::SetLanguageBlocked(bool value) {
251 if (value) { 252 if (value) {
252 prefs_->BlockLanguage(GetOriginalLanguageCode()); 253 prefs_->BlockLanguage(GetOriginalLanguageCode());
253 if (translate_manager_) { 254 if (translate_manager_) {
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
298 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true); 299 UMA_HISTOGRAM_BOOLEAN(kAlwaysTranslateLang, true);
299 } 300 }
300 301
301 std::string TranslateUIDelegate::GetPageHost() { 302 std::string TranslateUIDelegate::GetPageHost() {
302 if (!translate_driver_->HasCurrentPage()) 303 if (!translate_driver_->HasCurrentPage())
303 return std::string(); 304 return std::string();
304 return translate_driver_->GetLastCommittedURL().HostNoBrackets(); 305 return translate_driver_->GetLastCommittedURL().HostNoBrackets();
305 } 306 }
306 307
307 } // namespace translate 308 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698