| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/infobars/translate_infobars.h" | 5 #include "chrome/browser/views/infobars/translate_infobars.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "app/gfx/canvas.h" | 10 #include "app/gfx/canvas.h" |
| (...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 | 712 |
| 713 string16 new_language = TranslateInfoBarDelegate::GetDisplayNameForLocale( | 713 string16 new_language = TranslateInfoBarDelegate::GetDisplayNameForLocale( |
| 714 GetDelegate()->GetLocaleFromIndex(new_language_index)); | 714 GetDelegate()->GetLocaleFromIndex(new_language_index)); |
| 715 menu_button->SetText(UTF16ToWideHack(new_language)); | 715 menu_button->SetText(UTF16ToWideHack(new_language)); |
| 716 menu_button->ClearMaxTextSize(); | 716 menu_button->ClearMaxTextSize(); |
| 717 menu_button->SizeToPreferredSize(); | 717 menu_button->SizeToPreferredSize(); |
| 718 Layout(); | 718 Layout(); |
| 719 SchedulePaint(); | 719 SchedulePaint(); |
| 720 // Clear options menu model so that it'll be created with new language. | 720 // Clear options menu model so that it'll be created with new language. |
| 721 options_menu_model_.reset(); | 721 options_menu_model_.reset(); |
| 722 // If necessary, trigger translation. | 722 // Selecting an item from the "from language" menu in the before translate |
| 723 // phase shouldn't trigger translation - http://crbug.com/36666 |
| 723 if (GetDelegate()->state() == TranslateInfoBarDelegate::kAfterTranslate) | 724 if (GetDelegate()->state() == TranslateInfoBarDelegate::kAfterTranslate) |
| 724 GetDelegate()->Translate(); | 725 GetDelegate()->Translate(); |
| 725 } | 726 } |
| 726 | 727 |
| 727 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const { | 728 inline TranslateInfoBarDelegate* TranslateInfoBar::GetDelegate() const { |
| 728 return static_cast<TranslateInfoBarDelegate*>(delegate()); | 729 return static_cast<TranslateInfoBarDelegate*>(delegate()); |
| 729 } | 730 } |
| 730 | 731 |
| 731 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const { | 732 inline int TranslateInfoBar::GetSpacingAfterFirstLanguageButton() const { |
| 732 return (GetDelegate()->state() == TranslateInfoBarDelegate::kBeforeTranslate ? | 733 return (GetDelegate()->state() == TranslateInfoBarDelegate::kBeforeTranslate ? |
| 733 10 : kButtonInLabelSpacing); | 734 10 : kButtonInLabelSpacing); |
| 734 } | 735 } |
| 735 | 736 |
| 736 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------ | 737 // TranslateInfoBarDelegate, InfoBarDelegate overrides: ------------------ |
| 737 | 738 |
| 738 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { | 739 InfoBar* TranslateInfoBarDelegate::CreateInfoBar() { |
| 739 return new TranslateInfoBar(this); | 740 return new TranslateInfoBar(this); |
| 740 } | 741 } |
| OLD | NEW |