| 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 // the child view is destructed. For example, |source_language_combobx_model_| | 76 // the child view is destructed. For example, |source_language_combobx_model_| |
| 77 // is referred by Combobox's destructor. Before destroying the models, | 77 // is referred by Combobox's destructor. Before destroying the models, |
| 78 // removing the child views is needed. | 78 // removing the child views is needed. |
| 79 RemoveAllChildViews(true); | 79 RemoveAllChildViews(true); |
| 80 } | 80 } |
| 81 | 81 |
| 82 // static | 82 // static |
| 83 void TranslateBubbleView::ShowBubble(views::View* anchor_view, | 83 void TranslateBubbleView::ShowBubble(views::View* anchor_view, |
| 84 content::WebContents* web_contents, | 84 content::WebContents* web_contents, |
| 85 translate::TranslateStep step, | 85 translate::TranslateStep step, |
| 86 TranslateErrors::Type error_type) { | 86 TranslateErrors::Type error_type, |
| 87 bool is_explicit) { |
| 87 if (IsShowing()) { | 88 if (IsShowing()) { |
| 88 // When the user reads the advanced setting panel, the bubble should not be | 89 // When the user reads the advanced setting panel, the bubble should not be |
| 89 // changed because he/she is focusing on the bubble. | 90 // changed because he/she is focusing on the bubble. |
| 90 if (translate_bubble_view_->web_contents() == web_contents && | 91 if (translate_bubble_view_->web_contents() == web_contents && |
| 91 translate_bubble_view_->model()->GetViewState() == | 92 translate_bubble_view_->model()->GetViewState() == |
| 92 TranslateBubbleModel::VIEW_STATE_ADVANCED) { | 93 TranslateBubbleModel::VIEW_STATE_ADVANCED) { |
| 93 return; | 94 return; |
| 94 } | 95 } |
| 95 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { | 96 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { |
| 96 TranslateBubbleModel::ViewState state = | 97 TranslateBubbleModel::ViewState state = |
| 97 TranslateBubbleModelImpl::TranslateStepToViewState(step); | 98 TranslateBubbleModelImpl::TranslateStepToViewState(step); |
| 98 translate_bubble_view_->SwitchView(state); | 99 translate_bubble_view_->SwitchView(state); |
| 99 } else { | 100 } else { |
| 100 translate_bubble_view_->SwitchToErrorView(error_type); | 101 translate_bubble_view_->SwitchToErrorView(error_type); |
| 101 } | 102 } |
| 102 return; | 103 return; |
| 104 } else { |
| 105 if (step == translate::TRANSLATE_STEP_AFTER_TRANSLATE && |
| 106 !is_explicit) { |
| 107 return; |
| 108 } |
| 103 } | 109 } |
| 104 | 110 |
| 105 std::string source_language; | 111 std::string source_language; |
| 106 std::string target_language; | 112 std::string target_language; |
| 107 ChromeTranslateClient::GetTranslateLanguages( | 113 ChromeTranslateClient::GetTranslateLanguages( |
| 108 web_contents, &source_language, &target_language); | 114 web_contents, &source_language, &target_language); |
| 109 | 115 |
| 110 scoped_ptr<TranslateUIDelegate> ui_delegate(new TranslateUIDelegate( | 116 scoped_ptr<TranslateUIDelegate> ui_delegate(new TranslateUIDelegate( |
| 111 ChromeTranslateClient::GetManagerFromWebContents(web_contents) | 117 ChromeTranslateClient::GetManagerFromWebContents(web_contents) |
| 112 ->GetWeakPtr(), | 118 ->GetWeakPtr(), |
| (...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 model_->ShouldAlwaysTranslate()); | 748 model_->ShouldAlwaysTranslate()); |
| 743 } | 749 } |
| 744 | 750 |
| 745 base::string16 label; | 751 base::string16 label; |
| 746 if (model_->IsPageTranslatedInCurrentLanguages()) | 752 if (model_->IsPageTranslatedInCurrentLanguages()) |
| 747 label = l10n_util::GetStringUTF16(IDS_DONE); | 753 label = l10n_util::GetStringUTF16(IDS_DONE); |
| 748 else | 754 else |
| 749 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); | 755 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); |
| 750 advanced_done_button_->SetText(label); | 756 advanced_done_button_->SetText(label); |
| 751 } | 757 } |
| OLD | NEW |