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/memory/singleton.h" | 9 #include "base/memory/singleton.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 // This ShowBubble function is also used for upating the existing bubble. | 722 // This ShowBubble function is also used for upating the existing bubble. |
723 // However, with the bubble shown, any browser windows are NOT activated | 723 // However, with the bubble shown, any browser windows are NOT activated |
724 // because the bubble takes the focus from the other widgets including the | 724 // because the bubble takes the focus from the other widgets including the |
725 // browser windows. So it is checked that |browser| is the last activated | 725 // browser windows. So it is checked that |browser| is the last activated |
726 // browser, not is now activated. | 726 // browser, not is now activated. |
727 if (browser != | 727 if (browser != |
728 chrome::FindLastActiveWithHostDesktopType(browser->host_desktop_type())) { | 728 chrome::FindLastActiveWithHostDesktopType(browser->host_desktop_type())) { |
729 return; | 729 return; |
730 } | 730 } |
731 | 731 |
| 732 // During auto-translating, the bubble should not be shown. |
| 733 if (view_state == TranslateBubbleModel::VIEW_STATE_TRANSLATING || |
| 734 view_state == TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE) { |
| 735 TranslateTabHelper* translate_tab_helper = |
| 736 TranslateTabHelper::FromWebContents(web_contents); |
| 737 if (!translate_tab_helper || |
| 738 translate_tab_helper->language_state().InTranslateNavigation()) { |
| 739 return; |
| 740 } |
| 741 } |
| 742 |
732 TranslateBubbleFactory::Show(browser->window(), web_contents, view_state, | 743 TranslateBubbleFactory::Show(browser->window(), web_contents, view_state, |
733 error_type); | 744 error_type); |
734 #else | 745 #else |
735 NOTREACHED(); | 746 NOTREACHED(); |
736 #endif | 747 #endif |
737 } | 748 } |
738 | 749 |
739 // static | 750 // static |
740 std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { | 751 std::string TranslateManager::GetTargetLanguage(PrefService* prefs) { |
741 std::string ui_lang = | 752 std::string ui_lang = |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 // so we are more aggressive about showing the shortcut to never translate. | 810 // so we are more aggressive about showing the shortcut to never translate. |
800 #if defined(OS_ANDROID) | 811 #if defined(OS_ANDROID) |
801 config.never_translate_min_count = 1; | 812 config.never_translate_min_count = 1; |
802 #else | 813 #else |
803 config.never_translate_min_count = 3; | 814 config.never_translate_min_count = 3; |
804 #endif // defined(OS_ANDROID) | 815 #endif // defined(OS_ANDROID) |
805 | 816 |
806 config.always_translate_min_count = 3; | 817 config.always_translate_min_count = 3; |
807 return config; | 818 return config; |
808 } | 819 } |
OLD | NEW |