OLD | NEW |
---|---|
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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
327 helper->language_state().translation_declined()) { | 327 helper->language_state().translation_declined()) { |
328 // Some sites (such as Google map) may trigger sub-frame navigations | 328 // Some sites (such as Google map) may trigger sub-frame navigations |
329 // when the user interacts with the page. We don't want to show a new | 329 // when the user interacts with the page. We don't want to show a new |
330 // infobar if the user already dismissed one in that case. | 330 // infobar if the user already dismissed one in that case. |
331 return; | 331 return; |
332 } | 332 } |
333 if (entry->GetTransitionType() != content::PAGE_TRANSITION_RELOAD && | 333 if (entry->GetTransitionType() != content::PAGE_TRANSITION_RELOAD && |
334 load_details->type != content::NAVIGATION_TYPE_SAME_PAGE) { | 334 load_details->type != content::NAVIGATION_TYPE_SAME_PAGE) { |
335 return; | 335 return; |
336 } | 336 } |
337 // When doing a page reload, we don't get a TAB_LANGUAGE_DETERMINED | 337 // When doing a page reload, we don't get a TAB_LANGUAGE_DETERMINED |
James Hawkins
2012/08/07 00:49:13
Drive-by optional nit: Don't use pronouns (we) in
MAD
2012/08/07 01:25:04
Done.
| |
338 // notification. So we need to explictly initiate the translation. | 338 // notification. So we need to explicitly initiate the translation. |
339 // At least when the page is indeed translatable. | |
James Hawkins
2012/08/07 00:49:13
Grammar nit: Sentence fragment.
MAD
2012/08/07 01:25:04
Done.
| |
340 if (!helper->language_state().page_translatable()) | |
341 return; | |
339 // Note that we delay it as the TranslateManager gets this notification | 342 // Note that we delay it as the TranslateManager gets this notification |
340 // before the WebContents and the WebContents processing might remove the | 343 // before the WebContents and the WebContents processing might remove the |
341 // current infobars. Since InitTranslation might add an infobar, it must | 344 // current infobars. Since InitTranslation might add an infobar, it must |
342 // be done after that. | 345 // be done after that. |
343 MessageLoop::current()->PostTask(FROM_HERE, | 346 MessageLoop::current()->PostTask(FROM_HERE, |
344 base::Bind( | 347 base::Bind( |
345 &TranslateManager::InitiateTranslationPosted, | 348 &TranslateManager::InitiateTranslationPosted, |
346 weak_method_factory_.GetWeakPtr(), | 349 weak_method_factory_.GetWeakPtr(), |
347 controller->GetWebContents()->GetRenderProcessHost()->GetID(), | 350 controller->GetWebContents()->GetRenderProcessHost()->GetID(), |
348 controller->GetWebContents()-> | 351 controller->GetWebContents()-> |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); | 900 InfoBarTabHelper* infobar_helper = tab_contents->infobar_tab_helper(); |
898 | 901 |
899 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 902 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
900 TranslateInfoBarDelegate* delegate = | 903 TranslateInfoBarDelegate* delegate = |
901 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 904 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
902 if (delegate) | 905 if (delegate) |
903 return delegate; | 906 return delegate; |
904 } | 907 } |
905 return NULL; | 908 return NULL; |
906 } | 909 } |
OLD | NEW |