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

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

Issue 922953002: Minor infobar cleanup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resync Created 5 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_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 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 kNeverTranslateMinCount); 261 kNeverTranslateMinCount);
262 } 262 }
263 263
264 bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateShortcut() { 264 bool TranslateInfoBarDelegate::ShouldShowAlwaysTranslateShortcut() {
265 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_); 265 DCHECK_EQ(translate::TRANSLATE_STEP_BEFORE_TRANSLATE, step_);
266 return !is_off_the_record_ && 266 return !is_off_the_record_ &&
267 (prefs_->GetTranslationAcceptedCount(original_language_code()) >= 267 (prefs_->GetTranslationAcceptedCount(original_language_code()) >=
268 kAlwaysTranslateMinCount); 268 kAlwaysTranslateMinCount);
269 } 269 }
270 270
271 #if defined(OS_IOS)
272 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() {
273 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_,
274 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(),
275 target_language_code(), TranslateErrors::NONE, false);
276 }
277 #endif
278
271 // static 279 // static
272 void TranslateInfoBarDelegate::GetAfterTranslateStrings( 280 void TranslateInfoBarDelegate::GetAfterTranslateStrings(
273 std::vector<base::string16>* strings, 281 std::vector<base::string16>* strings,
274 bool* swap_languages, 282 bool* swap_languages,
275 bool autodetermined_source_language) { 283 bool autodetermined_source_language) {
276 DCHECK(strings); 284 DCHECK(strings);
277 285
278 if (autodetermined_source_language) { 286 if (autodetermined_source_language) {
279 size_t offset; 287 size_t offset;
280 base::string16 text = l10n_util::GetStringFUTF16( 288 base::string16 text = l10n_util::GetStringFUTF16(
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 346
339 void TranslateInfoBarDelegate::InfoBarDismissed() { 347 void TranslateInfoBarDelegate::InfoBarDismissed() {
340 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE) 348 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE)
341 return; 349 return;
342 350
343 // The user closed the infobar without clicking the translate button. 351 // The user closed the infobar without clicking the translate button.
344 TranslationDeclined(); 352 TranslationDeclined();
345 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 353 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
346 } 354 }
347 355
348 int TranslateInfoBarDelegate::GetIconID() const { 356 infobars::InfoBarDelegate::Type
349 return translate_manager_->translate_client()->GetInfobarIconID(); 357 TranslateInfoBarDelegate::GetInfoBarType() const {
350 }
351
352 infobars::InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType()
353 const {
354 return PAGE_ACTION_TYPE; 358 return PAGE_ACTION_TYPE;
355 } 359 }
356 360
357 bool TranslateInfoBarDelegate::ShouldExpire( 361 bool TranslateInfoBarDelegate::ShouldExpire(
358 const NavigationDetails& details) const { 362 const NavigationDetails& details) const {
359 // Note: we allow closing this infobar even if the main frame navigation 363 // Note: we allow closing this infobar even if the main frame navigation
360 // was programmatic and not initiated by the user - crbug.com/70261 . 364 // was programmatic and not initiated by the user - crbug.com/70261 .
361 if (!details.is_navigation_to_different_page && !details.is_main_frame) 365 if (!details.is_navigation_to_different_page && !details.is_main_frame)
362 return false; 366 return false;
363 367
364 return infobars::InfoBarDelegate::ShouldExpireInternal(details); 368 return infobars::InfoBarDelegate::ShouldExpireInternal(details);
365 } 369 }
366 370
367 TranslateInfoBarDelegate* 371 TranslateInfoBarDelegate*
368 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 372 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
369 return this; 373 return this;
370 } 374 }
371 375
372 #if defined(OS_IOS) 376 int TranslateInfoBarDelegate::GetIconID() const {
373 void TranslateInfoBarDelegate::ShowNeverTranslateInfobar() { 377 return translate_manager_->translate_client()->GetInfobarIconID();
374 Create(true, translate_manager_, infobar()->owner(), is_off_the_record_,
375 translate::TRANSLATE_STEP_NEVER_TRANSLATE, original_language_code(),
376 target_language_code(), TranslateErrors::NONE, false);
377 } 378 }
378 #endif
379 379
380 } // namespace translate 380 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698