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_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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 return; | 273 return; |
274 | 274 |
275 TranslateTabHelper* helper = wrapper->translate_tab_helper(); | 275 TranslateTabHelper* helper = wrapper->translate_tab_helper(); |
276 if (!load_details->is_main_frame && | 276 if (!load_details->is_main_frame && |
277 helper->language_state().translation_declined()) { | 277 helper->language_state().translation_declined()) { |
278 // Some sites (such as Google map) may trigger sub-frame navigations | 278 // Some sites (such as Google map) may trigger sub-frame navigations |
279 // when the user interacts with the page. We don't want to show a new | 279 // when the user interacts with the page. We don't want to show a new |
280 // infobar if the user already dismissed one in that case. | 280 // infobar if the user already dismissed one in that case. |
281 return; | 281 return; |
282 } | 282 } |
283 if (entry->transition_type() != PageTransition::RELOAD && | 283 if (entry->transition_type() != content::PAGE_TRANSITION_RELOAD && |
284 load_details->type != NavigationType::SAME_PAGE) { | 284 load_details->type != NavigationType::SAME_PAGE) { |
285 return; | 285 return; |
286 } | 286 } |
287 // When doing a page reload, we don't get a TAB_LANGUAGE_DETERMINED | 287 // When doing a page reload, we don't get a TAB_LANGUAGE_DETERMINED |
288 // notification. So we need to explictly initiate the translation. | 288 // notification. So we need to explictly initiate the translation. |
289 // Note that we delay it as the TranslateManager gets this notification | 289 // Note that we delay it as the TranslateManager gets this notification |
290 // before the TabContents and the TabContents processing might remove the | 290 // before the TabContents and the TabContents processing might remove the |
291 // current infobars. Since InitTranslation might add an infobar, it must | 291 // current infobars. Since InitTranslation might add an infobar, it must |
292 // be done after that. | 292 // be done after that. |
293 MessageLoop::current()->PostTask(FROM_HERE, | 293 MessageLoop::current()->PostTask(FROM_HERE, |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 GetLanguageCode(g_browser_process->GetApplicationLocale()); | 612 GetLanguageCode(g_browser_process->GetApplicationLocale()); |
613 // Open that URL in a new tab so that the user can tell us more. | 613 // Open that URL in a new tab so that the user can tell us more. |
614 Profile* profile = | 614 Profile* profile = |
615 Profile::FromBrowserContext(tab_contents->browser_context()); | 615 Profile::FromBrowserContext(tab_contents->browser_context()); |
616 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); | 616 Browser* browser = BrowserList::GetLastActiveWithProfile(profile); |
617 if (!browser) { | 617 if (!browser) { |
618 NOTREACHED(); | 618 NOTREACHED(); |
619 return; | 619 return; |
620 } | 620 } |
621 browser->AddSelectedTabWithURL(GURL(report_error_url), | 621 browser->AddSelectedTabWithURL(GURL(report_error_url), |
622 PageTransition::AUTO_BOOKMARK); | 622 content::PAGE_TRANSITION_AUTO_BOOKMARK); |
623 } | 623 } |
624 | 624 |
625 void TranslateManager::DoTranslatePage(TabContents* tab, | 625 void TranslateManager::DoTranslatePage(TabContents* tab, |
626 const std::string& translate_script, | 626 const std::string& translate_script, |
627 const std::string& source_lang, | 627 const std::string& source_lang, |
628 const std::string& target_lang) { | 628 const std::string& target_lang) { |
629 NavigationEntry* entry = tab->controller().GetActiveEntry(); | 629 NavigationEntry* entry = tab->controller().GetActiveEntry(); |
630 if (!entry) { | 630 if (!entry) { |
631 NOTREACHED(); | 631 NOTREACHED(); |
632 return; | 632 return; |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
832 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); | 832 InfoBarTabHelper* infobar_helper = wrapper->infobar_tab_helper(); |
833 | 833 |
834 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { | 834 for (size_t i = 0; i < infobar_helper->infobar_count(); ++i) { |
835 TranslateInfoBarDelegate* delegate = | 835 TranslateInfoBarDelegate* delegate = |
836 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); | 836 infobar_helper->GetInfoBarDelegateAt(i)->AsTranslateInfoBarDelegate(); |
837 if (delegate) | 837 if (delegate) |
838 return delegate; | 838 return delegate; |
839 } | 839 } |
840 return NULL; | 840 return NULL; |
841 } | 841 } |
OLD | NEW |