Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1056)

Side by Side Diff: components/translate/core/browser/translate_infobar_delegate.cc

Issue 2892143002: Remove all feature flag checks in Delegate. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/translate/core/browser/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/i18n/string_compare.h" 10 #include "base/i18n/string_compare.h"
12 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
13 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
14 #include "build/build_config.h" 13 #include "build/build_config.h"
15 #include "components/infobars/core/infobar.h" 14 #include "components/infobars/core/infobar.h"
16 #include "components/infobars/core/infobar_manager.h" 15 #include "components/infobars/core/infobar_manager.h"
17 #include "components/strings/grit/components_strings.h" 16 #include "components/strings/grit/components_strings.h"
18 #include "components/translate/core/browser/language_state.h" 17 #include "components/translate/core/browser/language_state.h"
19 #include "components/translate/core/browser/translate_accept_languages.h" 18 #include "components/translate/core/browser/translate_accept_languages.h"
20 #include "components/translate/core/browser/translate_client.h" 19 #include "components/translate/core/browser/translate_client.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 std::unique_ptr<infobars::InfoBar> infobar(translate_client->CreateInfoBar( 117 std::unique_ptr<infobars::InfoBar> infobar(translate_client->CreateInfoBar(
119 base::WrapUnique(new TranslateInfoBarDelegate( 118 base::WrapUnique(new TranslateInfoBarDelegate(
120 translate_manager, is_off_the_record, step, original_language, 119 translate_manager, is_off_the_record, step, original_language,
121 target_language, error_type, triggered_from_menu)))); 120 target_language, error_type, triggered_from_menu))));
122 if (old_delegate) 121 if (old_delegate)
123 infobar_manager->ReplaceInfoBar(old_infobar, std::move(infobar)); 122 infobar_manager->ReplaceInfoBar(old_infobar, std::move(infobar));
124 else 123 else
125 infobar_manager->AddInfoBar(std::move(infobar)); 124 infobar_manager->AddInfoBar(std::move(infobar));
126 } 125 }
127 126
128 // static
129 bool TranslateInfoBarDelegate::IsCompactUIEnabled() {
130 return base::FeatureList::IsEnabled(kTranslateCompactUI);
131 }
132
133 void TranslateInfoBarDelegate::SetResponder(Responder* responder) { 127 void TranslateInfoBarDelegate::SetResponder(Responder* responder) {
134 responder_ = responder; 128 responder_ = responder;
135 } 129 }
136 130
137 void TranslateInfoBarDelegate::UpdateOriginalLanguage( 131 void TranslateInfoBarDelegate::UpdateOriginalLanguage(
138 const std::string& language_code) { 132 const std::string& language_code) {
139 ui_delegate_.UpdateOriginalLanguage(language_code); 133 ui_delegate_.UpdateOriginalLanguage(language_code);
140 } 134 }
141 135
142 void TranslateInfoBarDelegate::UpdateTargetLanguage( 136 void TranslateInfoBarDelegate::UpdateTargetLanguage(
143 const std::string& language_code) { 137 const std::string& language_code) {
144 ui_delegate_.UpdateTargetLanguage(language_code); 138 ui_delegate_.UpdateTargetLanguage(language_code);
145 } 139 }
146 140
147 void TranslateInfoBarDelegate::Translate() { 141 void TranslateInfoBarDelegate::Translate() {
148 ui_delegate_.Translate(); 142 ui_delegate_.Translate();
149 } 143 }
150 144
151 void TranslateInfoBarDelegate::RevertTranslation() { 145 void TranslateInfoBarDelegate::RevertTranslation() {
152 ui_delegate_.RevertTranslation(); 146 ui_delegate_.RevertTranslation();
153 if (IsCompactUIEnabled())
154 return;
155 infobar()->RemoveSelf(); 147 infobar()->RemoveSelf();
156 } 148 }
157 149
150 void TranslateInfoBarDelegate::RevertWithoutClosingInfobar() {
151 ui_delegate_.RevertTranslation();
152 }
153
158 void TranslateInfoBarDelegate::ReportLanguageDetectionError() { 154 void TranslateInfoBarDelegate::ReportLanguageDetectionError() {
159 if (translate_manager_) 155 if (translate_manager_)
160 translate_manager_->ReportLanguageDetectionError(); 156 translate_manager_->ReportLanguageDetectionError();
161 } 157 }
162 158
163 void TranslateInfoBarDelegate::TranslationDeclined() { 159 void TranslateInfoBarDelegate::TranslationDeclined() {
164 ui_delegate_.TranslationDeclined(true); 160 ui_delegate_.TranslationDeclined(true);
165 } 161 }
166 162
167 bool TranslateInfoBarDelegate::IsTranslatableLanguageByPrefs() { 163 bool TranslateInfoBarDelegate::IsTranslatableLanguageByPrefs() {
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 infobars::InfoBarDelegate::Type 376 infobars::InfoBarDelegate::Type
381 TranslateInfoBarDelegate::GetInfoBarType() const { 377 TranslateInfoBarDelegate::GetInfoBarType() const {
382 return PAGE_ACTION_TYPE; 378 return PAGE_ACTION_TYPE;
383 } 379 }
384 380
385 int TranslateInfoBarDelegate::GetIconId() const { 381 int TranslateInfoBarDelegate::GetIconId() const {
386 return translate_manager_->translate_client()->GetInfobarIconID(); 382 return translate_manager_->translate_client()->GetInfobarIconID();
387 } 383 }
388 384
389 void TranslateInfoBarDelegate::InfoBarDismissed() { 385 void TranslateInfoBarDelegate::InfoBarDismissed() {
390 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE) 386 bool declined = responder_
napper 2017/05/19 23:01:31 const bool
391 return; 387 ? responder_->Declined()
392 if (IsCompactUIEnabled()) 388 : (step_ == translate::TRANSLATE_STEP_BEFORE_TRANSLATE);
393 return; 389
394 // The user closed the infobar without clicking the translate button. 390 if (declined) {
395 TranslationDeclined(); 391 // The user closed the infobar without clicking the translate button.
396 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 392 TranslationDeclined();
393 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
394 }
397 } 395 }
398 396
399 TranslateInfoBarDelegate* 397 TranslateInfoBarDelegate*
400 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 398 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
401 return this; 399 return this;
402 } 400 }
403 401
404 } // namespace translate 402 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_infobar_delegate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698