OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/translate/translate_infobar_delegate.h" | 5 #include "chrome/browser/translate/translate_infobar_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
343 std::string language_code = iter->first; | 343 std::string language_code = iter->first; |
344 if (language_code == original_language) { | 344 if (language_code == original_language) { |
345 original_language_index_ = iter - languages_.begin(); | 345 original_language_index_ = iter - languages_.begin(); |
346 initial_original_language_index_ = original_language_index_; | 346 initial_original_language_index_ = original_language_index_; |
347 } | 347 } |
348 if (language_code == target_language) | 348 if (language_code == target_language) |
349 target_language_index_ = iter - languages_.begin(); | 349 target_language_index_ = iter - languages_.begin(); |
350 } | 350 } |
351 } | 351 } |
352 | 352 |
353 bool TranslateInfoBarDelegate::ShouldExpire( | |
354 const NavigationController::LoadCommittedDetails& details) const { | |
355 // Note: we allow closing this infobar even if the navigation was programmatic | |
356 // and not initiated by the user - crbug.com/70261 . | |
357 return (contents_unique_id_ != details.entry->unique_id()) || | |
brettw
2011/05/02 16:35:25
Might we still want to check that it's the main fr
jeremy
2011/05/11 08:24:03
Done.
| |
358 (PageTransition::StripQualifier(details.entry->transition_type()) == | |
359 PageTransition::RELOAD); | |
360 } | |
361 | |
353 void TranslateInfoBarDelegate::InfoBarDismissed() { | 362 void TranslateInfoBarDelegate::InfoBarDismissed() { |
354 if (type_ != BEFORE_TRANSLATE) | 363 if (type_ != BEFORE_TRANSLATE) |
355 return; | 364 return; |
356 | 365 |
357 // The user closed the infobar without clicking the translate button. | 366 // The user closed the infobar without clicking the translate button. |
358 TranslationDeclined(); | 367 TranslationDeclined(); |
359 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1); | 368 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1); |
360 } | 369 } |
361 | 370 |
362 void TranslateInfoBarDelegate::InfoBarClosed() { | 371 void TranslateInfoBarDelegate::InfoBarClosed() { |
(...skipping 11 matching lines...) Expand all Loading... | |
374 | 383 |
375 TranslateInfoBarDelegate* | 384 TranslateInfoBarDelegate* |
376 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { | 385 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { |
377 return this; | 386 return this; |
378 } | 387 } |
379 | 388 |
380 std::string TranslateInfoBarDelegate::GetPageHost() { | 389 std::string TranslateInfoBarDelegate::GetPageHost() { |
381 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); | 390 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); |
382 return entry ? entry->url().HostNoBrackets() : std::string(); | 391 return entry ? entry->url().HostNoBrackets() : std::string(); |
383 } | 392 } |
OLD | NEW |