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

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.cc

Issue 6883299: Hide translate infobar on programmatic navigation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update testcase. Created 9 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 | Annotate | Revision Log
OLDNEW
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
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 main frame navigation
356 // was programmatic and not initiated by the user - crbug.com/70261 .
MAD 2011/05/17 16:25:55 Remove extra space before '.'
357 if (!details.is_user_initiated_main_frame_load() && !details.is_main_frame)
358 return false;
359
360 return InfoBarDelegate::ShouldExpireInternal(details);
361 }
362
353 void TranslateInfoBarDelegate::InfoBarDismissed() { 363 void TranslateInfoBarDelegate::InfoBarDismissed() {
354 if (type_ != BEFORE_TRANSLATE) 364 if (type_ != BEFORE_TRANSLATE)
355 return; 365 return;
356 366
357 // The user closed the infobar without clicking the translate button. 367 // The user closed the infobar without clicking the translate button.
358 TranslationDeclined(); 368 TranslationDeclined();
359 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1); 369 UMA_HISTOGRAM_COUNTS("Translate.DeclineTranslateCloseInfobar", 1);
360 } 370 }
361 371
362 gfx::Image* TranslateInfoBarDelegate::GetIcon() const { 372 gfx::Image* TranslateInfoBarDelegate::GetIcon() const {
363 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed( 373 return &ResourceBundle::GetSharedInstance().GetNativeImageNamed(
364 IDR_INFOBAR_TRANSLATE); 374 IDR_INFOBAR_TRANSLATE);
365 } 375 }
366 376
367 InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() const { 377 InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() const {
368 return PAGE_ACTION_TYPE; 378 return PAGE_ACTION_TYPE;
369 } 379 }
370 380
371 TranslateInfoBarDelegate* 381 TranslateInfoBarDelegate*
372 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 382 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
373 return this; 383 return this;
374 } 384 }
375 385
376 std::string TranslateInfoBarDelegate::GetPageHost() { 386 std::string TranslateInfoBarDelegate::GetPageHost() {
377 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry(); 387 NavigationEntry* entry = tab_contents_->controller().GetActiveEntry();
378 return entry ? entry->url().HostNoBrackets() : std::string(); 388 return entry ? entry->url().HostNoBrackets() : std::string();
379 } 389 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698