| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/ui/views/translate/translate_bubble_view.h" | 5 #include "chrome/browser/ui/views/translate/translate_bubble_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 // is referred by Combobox's destructor. Before destroying the models, | 135 // is referred by Combobox's destructor. Before destroying the models, |
| 136 // removing the child views is needed. | 136 // removing the child views is needed. |
| 137 RemoveAllChildViews(true); | 137 RemoveAllChildViews(true); |
| 138 } | 138 } |
| 139 | 139 |
| 140 // static | 140 // static |
| 141 void TranslateBubbleView::ShowBubble(views::View* anchor_view, | 141 void TranslateBubbleView::ShowBubble(views::View* anchor_view, |
| 142 content::WebContents* web_contents, | 142 content::WebContents* web_contents, |
| 143 TranslateBubbleModel::ViewState type, | 143 TranslateBubbleModel::ViewState type, |
| 144 Browser* browser) { | 144 Browser* browser) { |
| 145 // During auto-translating, the bubble should not be shown. |
| 146 if (type == TranslateBubbleModel::VIEW_STATE_TRANSLATING || |
| 147 type == TranslateBubbleModel::VIEW_STATE_AFTER_TRANSLATE) { |
| 148 TranslateTabHelper* translate_tab_helper = |
| 149 TranslateTabHelper::FromWebContents(web_contents); |
| 150 if (!translate_tab_helper || |
| 151 translate_tab_helper->language_state().InTranslateNavigation()) { |
| 152 return; |
| 153 } |
| 154 } |
| 155 |
| 145 if (IsShowing()) { | 156 if (IsShowing()) { |
| 146 // When the user reads the advanced setting panel, the bubble should not be | 157 // When the user reads the advanced setting panel, the bubble should not be |
| 147 // changed because he/she is focusing on the bubble. | 158 // changed because he/she is focusing on the bubble. |
| 148 if (translate_bubble_view_->web_contents() == web_contents && | 159 if (translate_bubble_view_->web_contents() == web_contents && |
| 149 translate_bubble_view_->model()->GetViewState() == | 160 translate_bubble_view_->model()->GetViewState() == |
| 150 TranslateBubbleModel::VIEW_STATE_ADVANCED) { | 161 TranslateBubbleModel::VIEW_STATE_ADVANCED) { |
| 151 return; | 162 return; |
| 152 } | 163 } |
| 153 translate_bubble_view_->SwitchView(type); | 164 translate_bubble_view_->SwitchView(type); |
| 154 return; | 165 return; |
| (...skipping 597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); | 763 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); |
| 753 | 764 |
| 754 // "Always translate" checkbox doesn't exist in an incognito window. | 765 // "Always translate" checkbox doesn't exist in an incognito window. |
| 755 if (always_translate_checkbox_) { | 766 if (always_translate_checkbox_) { |
| 756 always_translate_checkbox_->SetText( | 767 always_translate_checkbox_->SetText( |
| 757 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS)); | 768 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS)); |
| 758 always_translate_checkbox_->SetChecked( | 769 always_translate_checkbox_->SetChecked( |
| 759 model_->ShouldAlwaysTranslate()); | 770 model_->ShouldAlwaysTranslate()); |
| 760 } | 771 } |
| 761 } | 772 } |
| OLD | NEW |