OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/browser/translate_infobar_delegate.h" | 5 #include "components/translate/core/browser/translate_infobar_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 return; | 97 return; |
98 } | 98 } |
99 | 99 |
100 // Find any existing translate infobar delegate. | 100 // Find any existing translate infobar delegate. |
101 infobars::InfoBar* old_infobar = NULL; | 101 infobars::InfoBar* old_infobar = NULL; |
102 TranslateInfoBarDelegate* old_delegate = NULL; | 102 TranslateInfoBarDelegate* old_delegate = NULL; |
103 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { | 103 for (size_t i = 0; i < infobar_manager->infobar_count(); ++i) { |
104 old_infobar = infobar_manager->infobar_at(i); | 104 old_infobar = infobar_manager->infobar_at(i); |
105 old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate(); | 105 old_delegate = old_infobar->delegate()->AsTranslateInfoBarDelegate(); |
106 if (old_delegate) { | 106 if (old_delegate) { |
107 if (!replace_existing_infobar) | 107 if (!replace_existing_infobar || IsCompactUIEnabled()) |
108 return; | 108 return; |
109 break; | 109 break; |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 // Add the new delegate. | 113 // Add the new delegate. |
114 std::unique_ptr<infobars::InfoBar> infobar(translate_client->CreateInfoBar( | 114 std::unique_ptr<infobars::InfoBar> infobar(translate_client->CreateInfoBar( |
115 base::WrapUnique(new TranslateInfoBarDelegate( | 115 base::WrapUnique(new TranslateInfoBarDelegate( |
116 translate_manager, is_off_the_record, step, old_delegate, | 116 translate_manager, is_off_the_record, step, old_delegate, |
117 original_language, target_language, error_type, | 117 original_language, target_language, error_type, |
(...skipping 18 matching lines...) Expand all Loading... |
136 const std::string& language_code) { | 136 const std::string& language_code) { |
137 ui_delegate_.UpdateTargetLanguage(language_code); | 137 ui_delegate_.UpdateTargetLanguage(language_code); |
138 } | 138 } |
139 | 139 |
140 void TranslateInfoBarDelegate::Translate() { | 140 void TranslateInfoBarDelegate::Translate() { |
141 ui_delegate_.Translate(); | 141 ui_delegate_.Translate(); |
142 } | 142 } |
143 | 143 |
144 void TranslateInfoBarDelegate::RevertTranslation() { | 144 void TranslateInfoBarDelegate::RevertTranslation() { |
145 ui_delegate_.RevertTranslation(); | 145 ui_delegate_.RevertTranslation(); |
| 146 if (IsCompactUIEnabled()) |
| 147 return; |
146 infobar()->RemoveSelf(); | 148 infobar()->RemoveSelf(); |
147 } | 149 } |
148 | 150 |
149 void TranslateInfoBarDelegate::ReportLanguageDetectionError() { | 151 void TranslateInfoBarDelegate::ReportLanguageDetectionError() { |
150 if (translate_manager_) | 152 if (translate_manager_) |
151 translate_manager_->ReportLanguageDetectionError(); | 153 translate_manager_->ReportLanguageDetectionError(); |
152 } | 154 } |
153 | 155 |
154 void TranslateInfoBarDelegate::TranslationDeclined() { | 156 void TranslateInfoBarDelegate::TranslationDeclined() { |
155 ui_delegate_.TranslationDeclined(true); | 157 ui_delegate_.TranslationDeclined(true); |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 TranslationDeclined(); | 384 TranslationDeclined(); |
383 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); | 385 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); |
384 } | 386 } |
385 | 387 |
386 TranslateInfoBarDelegate* | 388 TranslateInfoBarDelegate* |
387 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { | 389 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { |
388 return this; | 390 return this; |
389 } | 391 } |
390 | 392 |
391 } // namespace translate | 393 } // namespace translate |
OLD | NEW |