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

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

Issue 2871783003: Automatically trigger Always-Translate in new translation infobar (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" 10 #include "base/feature_list.h"
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 188 }
189 189
190 bool TranslateInfoBarDelegate::ShouldAlwaysTranslate() { 190 bool TranslateInfoBarDelegate::ShouldAlwaysTranslate() {
191 return ui_delegate_.ShouldAlwaysTranslate(); 191 return ui_delegate_.ShouldAlwaysTranslate();
192 } 192 }
193 193
194 void TranslateInfoBarDelegate::ToggleAlwaysTranslate() { 194 void TranslateInfoBarDelegate::ToggleAlwaysTranslate() {
195 ui_delegate_.SetAlwaysTranslate(!ui_delegate_.ShouldAlwaysTranslate()); 195 ui_delegate_.SetAlwaysTranslate(!ui_delegate_.ShouldAlwaysTranslate());
196 } 196 }
197 197
198 int TranslateInfoBarDelegate::GetTranslationAcceptedCount() {
199 return prefs_->GetTranslationAcceptedCount(original_language_code());
200 }
201
198 void TranslateInfoBarDelegate::AlwaysTranslatePageLanguage() { 202 void TranslateInfoBarDelegate::AlwaysTranslatePageLanguage() {
199 DCHECK(!ui_delegate_.ShouldAlwaysTranslate()); 203 DCHECK(!ui_delegate_.ShouldAlwaysTranslate());
200 ui_delegate_.SetAlwaysTranslate(true); 204 ui_delegate_.SetAlwaysTranslate(true);
201 Translate(); 205 Translate();
202 } 206 }
203 207
204 void TranslateInfoBarDelegate::NeverTranslatePageLanguage() { 208 void TranslateInfoBarDelegate::NeverTranslatePageLanguage() {
205 DCHECK(!ui_delegate_.IsLanguageBlocked()); 209 DCHECK(!ui_delegate_.IsLanguageBlocked());
206 ui_delegate_.SetLanguageBlocked(true); 210 ui_delegate_.SetLanguageBlocked(true);
207 infobar()->RemoveSelf(); 211 infobar()->RemoveSelf();
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 return PAGE_ACTION_TYPE; 375 return PAGE_ACTION_TYPE;
372 } 376 }
373 377
374 int TranslateInfoBarDelegate::GetIconId() const { 378 int TranslateInfoBarDelegate::GetIconId() const {
375 return translate_manager_->translate_client()->GetInfobarIconID(); 379 return translate_manager_->translate_client()->GetInfobarIconID();
376 } 380 }
377 381
378 void TranslateInfoBarDelegate::InfoBarDismissed() { 382 void TranslateInfoBarDelegate::InfoBarDismissed() {
379 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE) 383 if (step_ != translate::TRANSLATE_STEP_BEFORE_TRANSLATE)
380 return; 384 return;
381 385 if (IsCompactUIEnabled())
Marti Wong 2017/05/09 06:53:07 In Compact UI, the declined is only counted during
386 return;
382 // The user closed the infobar without clicking the translate button. 387 // The user closed the infobar without clicking the translate button.
383 TranslationDeclined(); 388 TranslationDeclined();
384 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true); 389 UMA_HISTOGRAM_BOOLEAN("Translate.DeclineTranslateCloseInfobar", true);
385 } 390 }
386 391
387 TranslateInfoBarDelegate* 392 TranslateInfoBarDelegate*
388 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 393 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
389 return this; 394 return this;
390 } 395 }
391 396
392 } // namespace translate 397 } // 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