OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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_tab_helper.h" | 5 #include "chrome/browser/translate/translate_tab_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
507 // |browser| might be NULL when testing. In this case, Show(...) should be | 507 // |browser| might be NULL when testing. In this case, Show(...) should be |
508 // called because the implementation for testing is used. | 508 // called because the implementation for testing is used. |
509 if (!browser) { | 509 if (!browser) { |
510 TranslateBubbleFactory::Show(NULL, web_contents(), step, error_type); | 510 TranslateBubbleFactory::Show(NULL, web_contents(), step, error_type); |
511 return; | 511 return; |
512 } | 512 } |
513 | 513 |
514 if (web_contents() != browser->tab_strip_model()->GetActiveWebContents()) | 514 if (web_contents() != browser->tab_strip_model()->GetActiveWebContents()) |
515 return; | 515 return; |
516 | 516 |
517 content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); | |
518 if (rvh->IsFocusedElementEditable()) | |
519 return; | |
520 | |
521 // This ShowBubble function is also used for upating the existing bubble. | 517 // This ShowBubble function is also used for upating the existing bubble. |
522 // However, with the bubble shown, any browser windows are NOT activated | 518 // However, with the bubble shown, any browser windows are NOT activated |
523 // because the bubble takes the focus from the other widgets including the | 519 // because the bubble takes the focus from the other widgets including the |
524 // browser windows. So it is checked that |browser| is the last activated | 520 // browser windows. So it is checked that |browser| is the last activated |
525 // browser, not is now activated. | 521 // browser, not is now activated. |
526 if (browser != | 522 if (browser != |
527 chrome::FindLastActiveWithHostDesktopType(browser->host_desktop_type())) { | 523 chrome::FindLastActiveWithHostDesktopType(browser->host_desktop_type())) { |
528 return; | 524 return; |
529 } | 525 } |
530 | 526 |
531 // During auto-translating, the bubble should not be shown. | 527 // During auto-translating, the bubble should not be shown. |
532 if (step == translate::TRANSLATE_STEP_TRANSLATING || | 528 if (step == translate::TRANSLATE_STEP_TRANSLATING || |
533 step == translate::TRANSLATE_STEP_AFTER_TRANSLATE) { | 529 step == translate::TRANSLATE_STEP_AFTER_TRANSLATE) { |
534 if (GetLanguageState().InTranslateNavigation()) | 530 if (GetLanguageState().InTranslateNavigation()) |
535 return; | 531 return; |
536 } | 532 } |
537 | 533 |
538 TranslateBubbleFactory::Show( | 534 TranslateBubbleFactory::Show( |
539 browser->window(), web_contents(), step, error_type); | 535 browser->window(), web_contents(), step, error_type); |
540 #else | 536 #else |
541 NOTREACHED(); | 537 NOTREACHED(); |
542 #endif | 538 #endif |
543 } | 539 } |
OLD | NEW |