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

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

Issue 10827183: Don't show the translate bar when refreshing a page with the notranslate content tag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_manager.h" 5 #include "chrome/browser/translate/translate_manager.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/compiler_specific.h" 9 #include "base/compiler_specific.h"
10 #include "base/json/json_reader.h" 10 #include "base/json/json_reader.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 helper->language_state().translation_declined()) { 328 helper->language_state().translation_declined()) {
329 // Some sites (such as Google map) may trigger sub-frame navigations 329 // Some sites (such as Google map) may trigger sub-frame navigations
330 // when the user interacts with the page. We don't want to show a new 330 // when the user interacts with the page. We don't want to show a new
331 // infobar if the user already dismissed one in that case. 331 // infobar if the user already dismissed one in that case.
332 return; 332 return;
333 } 333 }
334 if (entry->GetTransitionType() != content::PAGE_TRANSITION_RELOAD && 334 if (entry->GetTransitionType() != content::PAGE_TRANSITION_RELOAD &&
335 load_details->type != content::NAVIGATION_TYPE_SAME_PAGE) { 335 load_details->type != content::NAVIGATION_TYPE_SAME_PAGE) {
336 return; 336 return;
337 } 337 }
338 // When doing a page reload, we don't get a TAB_LANGUAGE_DETERMINED 338 // When doing a page reload, TAB_LANGUAGE_DETERMINED is not sent,
339 // notification. So we need to explictly initiate the translation. 339 // so the translation needs to be explicitly initiated, but only when the
340 // page is translatable.
341 if (!helper->language_state().page_translatable())
342 return;
340 // Note that we delay it as the TranslateManager gets this notification 343 // Note that we delay it as the TranslateManager gets this notification
341 // before the WebContents and the WebContents processing might remove the 344 // before the WebContents and the WebContents processing might remove the
342 // current infobars. Since InitTranslation might add an infobar, it must 345 // current infobars. Since InitTranslation might add an infobar, it must
343 // be done after that. 346 // be done after that.
344 MessageLoop::current()->PostTask(FROM_HERE, 347 MessageLoop::current()->PostTask(FROM_HERE,
345 base::Bind( 348 base::Bind(
346 &TranslateManager::InitiateTranslationPosted, 349 &TranslateManager::InitiateTranslationPosted,
347 weak_method_factory_.GetWeakPtr(), 350 weak_method_factory_.GetWeakPtr(),
348 controller->GetWebContents()->GetRenderProcessHost()->GetID(), 351 controller->GetWebContents()->GetRenderProcessHost()->GetID(),
349 controller->GetWebContents()-> 352 controller->GetWebContents()->
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); 899 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper();
897 900
898 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { 901 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) {
899 TranslateInfoBarDelegate* delegate = 902 TranslateInfoBarDelegate* delegate =
900 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); 903 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate();
901 if (delegate) 904 if (delegate)
902 return delegate; 905 return delegate;
903 } 906 }
904 return NULL; 907 return NULL;
905 } 908 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698