| 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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // the child view is destructed. For example, |source_language_combobx_model_| | 134 // the child view is destructed. For example, |source_language_combobx_model_| |
| 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 TranslateErrors::Type error_type, |
| 144 Browser* browser) { | 145 Browser* browser) { |
| 145 if (IsShowing()) { | 146 if (IsShowing()) { |
| 146 // When the user reads the advanced setting panel, the bubble should not be | 147 // When the user reads the advanced setting panel, the bubble should not be |
| 147 // changed because he/she is focusing on the bubble. | 148 // changed because he/she is focusing on the bubble. |
| 148 if (translate_bubble_view_->web_contents() == web_contents && | 149 if (translate_bubble_view_->web_contents() == web_contents && |
| 149 translate_bubble_view_->model()->GetViewState() == | 150 translate_bubble_view_->model()->GetViewState() == |
| 150 TranslateBubbleModel::VIEW_STATE_ADVANCED) { | 151 TranslateBubbleModel::VIEW_STATE_ADVANCED) { |
| 151 return; | 152 return; |
| 152 } | 153 } |
| 153 translate_bubble_view_->SwitchView(type); | 154 translate_bubble_view_->SwitchView(type); |
| 155 translate_bubble_view_->model()->SetErrorType(error_type); |
| 154 return; | 156 return; |
| 155 } | 157 } |
| 156 | 158 |
| 157 std::string source_language; | 159 std::string source_language; |
| 158 std::string target_language; | 160 std::string target_language; |
| 159 GetTranslateLanguages(web_contents, &source_language, &target_language); | 161 GetTranslateLanguages(web_contents, &source_language, &target_language); |
| 160 | 162 |
| 161 scoped_ptr<TranslateUIDelegate> ui_delegate( | 163 scoped_ptr<TranslateUIDelegate> ui_delegate( |
| 162 new TranslateUIDelegate(web_contents, source_language, target_language)); | 164 new TranslateUIDelegate(web_contents, source_language, target_language, |
| 165 error_type)); |
| 163 scoped_ptr<TranslateBubbleModel> model( | 166 scoped_ptr<TranslateBubbleModel> model( |
| 164 new TranslateBubbleModelImpl(type, ui_delegate.Pass())); | 167 new TranslateBubbleModelImpl(type, ui_delegate.Pass())); |
| 165 TranslateBubbleView* view = new TranslateBubbleView(anchor_view, | 168 TranslateBubbleView* view = new TranslateBubbleView(anchor_view, |
| 166 model.Pass(), | 169 model.Pass(), |
| 167 browser, | 170 browser, |
| 168 web_contents); | 171 web_contents); |
| 169 views::BubbleDelegateView::CreateBubble(view)->Show(); | 172 views::BubbleDelegateView::CreateBubble(view)->Show(); |
| 170 } | 173 } |
| 171 | 174 |
| 172 // static | 175 // static |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 752 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); | 755 model_->GetLanguageNameAt(model_->GetTargetLanguageIndex()); |
| 753 | 756 |
| 754 // "Always translate" checkbox doesn't exist in an incognito window. | 757 // "Always translate" checkbox doesn't exist in an incognito window. |
| 755 if (always_translate_checkbox_) { | 758 if (always_translate_checkbox_) { |
| 756 always_translate_checkbox_->SetText( | 759 always_translate_checkbox_->SetText( |
| 757 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS)); | 760 l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ALWAYS)); |
| 758 always_translate_checkbox_->SetChecked( | 761 always_translate_checkbox_->SetChecked( |
| 759 model_->ShouldAlwaysTranslate()); | 762 model_->ShouldAlwaysTranslate()); |
| 760 } | 763 } |
| 761 } | 764 } |
| OLD | NEW |