| 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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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( | 83 void TranslateBubbleView::ShowBubble( |
| 84 views::View* anchor_view, | 84 views::View* anchor_view, |
| 85 content::WebContents* web_contents, | 85 content::WebContents* web_contents, |
| 86 translate::TranslateStep step, | 86 translate::TranslateStep step, |
| 87 translate::TranslateErrors::Type error_type) { | 87 translate::TranslateErrors::Type error_type, |
| 88 bool is_user_gesture) { |
| 88 if (IsShowing()) { | 89 if (IsShowing()) { |
| 89 // When the user reads the advanced setting panel, the bubble should not be | 90 // When the user reads the advanced setting panel, the bubble should not be |
| 90 // changed because he/she is focusing on the bubble. | 91 // changed because he/she is focusing on the bubble. |
| 91 if (translate_bubble_view_->web_contents() == web_contents && | 92 if (translate_bubble_view_->web_contents() == web_contents && |
| 92 translate_bubble_view_->model()->GetViewState() == | 93 translate_bubble_view_->model()->GetViewState() == |
| 93 TranslateBubbleModel::VIEW_STATE_ADVANCED) { | 94 TranslateBubbleModel::VIEW_STATE_ADVANCED) { |
| 94 return; | 95 return; |
| 95 } | 96 } |
| 96 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { | 97 if (step != translate::TRANSLATE_STEP_TRANSLATE_ERROR) { |
| 97 TranslateBubbleModel::ViewState state = | 98 TranslateBubbleModel::ViewState state = |
| 98 TranslateBubbleModelImpl::TranslateStepToViewState(step); | 99 TranslateBubbleModelImpl::TranslateStepToViewState(step); |
| 99 translate_bubble_view_->SwitchView(state); | 100 translate_bubble_view_->SwitchView(state); |
| 100 } else { | 101 } else { |
| 101 translate_bubble_view_->SwitchToErrorView(error_type); | 102 translate_bubble_view_->SwitchToErrorView(error_type); |
| 102 } | 103 } |
| 103 return; | 104 return; |
| 105 } else { |
| 106 if (step == translate::TRANSLATE_STEP_AFTER_TRANSLATE && |
| 107 !is_user_gesture) { |
| 108 return; |
| 109 } |
| 104 } | 110 } |
| 105 | 111 |
| 106 std::string source_language; | 112 std::string source_language; |
| 107 std::string target_language; | 113 std::string target_language; |
| 108 ChromeTranslateClient::GetTranslateLanguages( | 114 ChromeTranslateClient::GetTranslateLanguages( |
| 109 web_contents, &source_language, &target_language); | 115 web_contents, &source_language, &target_language); |
| 110 | 116 |
| 111 scoped_ptr<translate::TranslateUIDelegate> ui_delegate( | 117 scoped_ptr<translate::TranslateUIDelegate> ui_delegate( |
| 112 new translate::TranslateUIDelegate( | 118 new translate::TranslateUIDelegate( |
| 113 ChromeTranslateClient::GetManagerFromWebContents(web_contents) | 119 ChromeTranslateClient::GetManagerFromWebContents(web_contents) |
| (...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 model_->ShouldAlwaysTranslate()); | 751 model_->ShouldAlwaysTranslate()); |
| 746 } | 752 } |
| 747 | 753 |
| 748 base::string16 label; | 754 base::string16 label; |
| 749 if (model_->IsPageTranslatedInCurrentLanguages()) | 755 if (model_->IsPageTranslatedInCurrentLanguages()) |
| 750 label = l10n_util::GetStringUTF16(IDS_DONE); | 756 label = l10n_util::GetStringUTF16(IDS_DONE); |
| 751 else | 757 else |
| 752 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); | 758 label = l10n_util::GetStringUTF16(IDS_TRANSLATE_BUBBLE_ACCEPT); |
| 753 advanced_done_button_->SetText(label); | 759 advanced_done_button_->SetText(label); |
| 754 } | 760 } |
| OLD | NEW |