| 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_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 Loading... |
| 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 |
| OLD | NEW |