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

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

Issue 1142153002: Simplify infobar expiry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Android compile Created 5 years, 7 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 352
353 infobars::InfoBarDelegate::Type 353 infobars::InfoBarDelegate::Type
354 TranslateInfoBarDelegate::GetInfoBarType() const { 354 TranslateInfoBarDelegate::GetInfoBarType() const {
355 return PAGE_ACTION_TYPE; 355 return PAGE_ACTION_TYPE;
356 } 356 }
357 357
358 int TranslateInfoBarDelegate::GetIconID() const { 358 int TranslateInfoBarDelegate::GetIconID() const {
359 return translate_manager_->translate_client()->GetInfobarIconID(); 359 return translate_manager_->translate_client()->GetInfobarIconID();
360 } 360 }
361 361
362 bool TranslateInfoBarDelegate::ShouldExpire(
363 const NavigationDetails& details) const {
364 // Note: we allow closing this infobar even if the main frame navigation
365 // was programmatic and not initiated by the user - crbug.com/70261 .
366 if (!details.is_navigation_to_different_page && !details.is_main_frame)
367 return false;
368
369 return infobars::InfoBarDelegate::ShouldExpireInternal(details);
370 }
371
372 void TranslateInfoBarDelegate::InfoBarDismissed() { 362 void TranslateInfoBarDelegate::InfoBarDismissed() {
373 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE) 363 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE)
374 return; 364 return;
375 365
376 // The user closed the infobar without clicking the translate button. 366 // The user closed the infobar without clicking the translate button.
377 TranslationDeclined(); 367 TranslationDeclined();
378 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 368 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
379 } 369 }
380 370
381 TranslateInfoBarDelegate* 371 TranslateInfoBarDelegate*
382 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 372 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
383 return this; 373 return this;
384 } 374 }
385 375
386 } // namespace translate 376 } // namespace translate
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698