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

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

Issue 972123002: [iOS] Fix DCHECK in ShouldShowAlwaysTranslateShortcut() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_infobar_delegate.h" 5 #include "components/translate/core/browser/translate_infobar_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/string_compare.h" 9 #include "base/i18n/string_compare.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 } 255 }
256 256
257 bool TranslateInfoBarDelegate::ShouldShowNeverTranslateShortcut() { 257 bool TranslateInfoBarDelegate::ShouldShowNeverTranslateShortcut() {
258 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_); 258 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_);
259 return !is_off_the_record_ && 259 return !is_off_the_record_ &&
260 (prefs_->GetTranslationDeniedCount(original_language_code()) >= 260 (prefs_->GetTranslationDeniedCount(original_language_code()) >=
261 kNeverTranslateMinCount); 261 kNeverTranslateMinCount);
262 } 262 }
263 263
264 bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateShortcut() { 264 bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateShortcut() {
265 #if defined(OS_IOS)
266 // On mobile, the option to always translate is shown after the translation.
267 DCHECK_EQ(translate::TRANSLATE_STEP_AFTER_TRANSLATE, step_);
268 #else
269 // On desktop, the option to always translate is shown before the translation.
265 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_); 270 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_);
271 #endif
266 return !is_off_the_record_ && 272 return !is_off_the_record_ &&
267 (prefs_->GetTranslationAcceptedCount(original_language_code()) >= 273 (prefs_->GetTranslationAcceptedCount(original_language_code()) >=
268 kAlwaysTranslateMinCount); 274 kAlwaysTranslateMinCount);
269 } 275 }
270 276
271 #if defined(OS_IOS) 277 #if defined(OS_IOS)
272 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() { 278 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() {
273 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_, 279 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_,
274 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(), 280 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(),
275 target_language_code(), TranslateErrors::NONE, false); 281 target_language_code(), TranslateErrors::NONE, false);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 TranslationDeclined(); 377 TranslationDeclined();
372 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 378 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
373 } 379 }
374 380
375 TranslateInfoBarDelegate* 381 TranslateInfoBarDelegate*
376 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 382 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
377 return this; 383 return this;
378 } 384 }
379 385
380 } // namespace translate 386 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698