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

Side by Side Diff: chrome/browser/translate/chrome_translate_client.cc

Issue 2697703004: Allow TranslateRanker to override decisions taken by heuristics. (Closed)
Patch Set: Nit. Created 3 years, 10 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 | « no previous file | components/metrics/proto/translate_event.proto » ('j') | 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 "chrome/browser/translate/chrome_translate_client.h" 5 #include "chrome/browser/translate/chrome_translate_client.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 18 matching lines...) Expand all
29 #include "components/metrics/proto/translate_event.pb.h" 29 #include "components/metrics/proto/translate_event.pb.h"
30 #include "components/prefs/pref_service.h" 30 #include "components/prefs/pref_service.h"
31 #include "components/translate/core/browser/language_model.h" 31 #include "components/translate/core/browser/language_model.h"
32 #include "components/translate/core/browser/language_state.h" 32 #include "components/translate/core/browser/language_state.h"
33 #include "components/translate/core/browser/page_translated_details.h" 33 #include "components/translate/core/browser/page_translated_details.h"
34 #include "components/translate/core/browser/translate_accept_languages.h" 34 #include "components/translate/core/browser/translate_accept_languages.h"
35 #include "components/translate/core/browser/translate_download_manager.h" 35 #include "components/translate/core/browser/translate_download_manager.h"
36 #include "components/translate/core/browser/translate_infobar_delegate.h" 36 #include "components/translate/core/browser/translate_infobar_delegate.h"
37 #include "components/translate/core/browser/translate_manager.h" 37 #include "components/translate/core/browser/translate_manager.h"
38 #include "components/translate/core/browser/translate_prefs.h" 38 #include "components/translate/core/browser/translate_prefs.h"
39 #include "components/translate/core/browser/translate_ranker.h"
39 #include "components/translate/core/common/language_detection_details.h" 40 #include "components/translate/core/common/language_detection_details.h"
40 #include "components/variations/service/variations_service.h" 41 #include "components/variations/service/variations_service.h"
41 #include "content/public/browser/notification_service.h" 42 #include "content/public/browser/notification_service.h"
42 #include "content/public/browser/render_view_host.h" 43 #include "content/public/browser/render_view_host.h"
43 #include "content/public/browser/web_contents.h" 44 #include "content/public/browser/web_contents.h"
44 #include "url/gurl.h" 45 #include "url/gurl.h"
45 46
46 namespace { 47 namespace {
47 48
48 metrics::TranslateEventProto::EventType BubbleResultToTranslateEvent( 49 metrics::TranslateEventProto::EventType BubbleResultToTranslateEvent(
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 #endif 218 #endif
218 219
219 // Bubble UI. 220 // Bubble UI.
220 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { 221 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) {
221 // TODO(droger): Move this logic out of UI code. 222 // TODO(droger): Move this logic out of UI code.
222 GetLanguageState().SetTranslateEnabled(true); 223 GetLanguageState().SetTranslateEnabled(true);
223 // In the new UI, continue offering translation after the user navigates to 224 // In the new UI, continue offering translation after the user navigates to
224 // another page. 225 // another page.
225 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) && 226 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) &&
226 !GetLanguageState().HasLanguageChanged()) { 227 !GetLanguageState().HasLanguageChanged()) {
227 translate_manager_->RecordTranslateEvent( 228 if (translate::TranslateRanker::IsDecisionOverrideEnabled()) {
228 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE); 229 translate_manager_->RecordDecisionOverride(
229 return; 230 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE);
231 DVLOG(3) << "Overriding decision MATCHES_PREVIOUS_LANGUAGE.";
232 } else {
233 translate_manager_->RecordTranslateEvent(
234 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE);
235 return;
236 }
230 } 237 }
231 238
232 if (!triggered_from_menu && 239 if (!triggered_from_menu &&
233 GetTranslatePrefs()->IsTooOftenDenied(source_language)) { 240 GetTranslatePrefs()->IsTooOftenDenied(source_language)) {
234 translate_manager_->RecordTranslateEvent( 241 if (translate::TranslateRanker::IsDecisionOverrideEnabled()) {
groby-ooo-7-16 2017/02/23 19:08:06 You could filter out the common code into a helper
hamelphi 2017/03/01 00:40:03 Done. I moved the logging logic to TranslateManage
235 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST); 242 translate_manager_->RecordDecisionOverride(
236 return; 243 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST);
244 DVLOG(3) << "Overriding decision LANGUAGE_DISABLED_BY_AUTO_BLACKLIST.";
245 } else {
246 translate_manager_->RecordTranslateEvent(
247 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST);
248 return;
249 }
237 } 250 }
238 } 251 }
252
239 ShowTranslateBubbleResult result = ShowBubble(step, error_type); 253 ShowTranslateBubbleResult result = ShowBubble(step, error_type);
240 if (result != ShowTranslateBubbleResult::SUCCESS && 254 if (result != ShowTranslateBubbleResult::SUCCESS &&
241 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { 255 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) {
242 translate_manager_->RecordTranslateEvent( 256 translate_manager_->RecordTranslateEvent(
243 BubbleResultToTranslateEvent(result)); 257 BubbleResultToTranslateEvent(result));
244 } 258 }
245 } 259 }
246 260
247 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { 261 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() {
248 return &translate_driver_; 262 return &translate_driver_;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 return ShowTranslateBubbleResult::SUCCESS; 387 return ShowTranslateBubbleResult::SUCCESS;
374 } 388 }
375 389
376 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, 390 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step,
377 error_type); 391 error_type);
378 #else 392 #else
379 NOTREACHED(); 393 NOTREACHED();
380 return ShowTranslateBubbleResult::SUCCESS; 394 return ShowTranslateBubbleResult::SUCCESS;
381 #endif 395 #endif
382 } 396 }
OLDNEW
« no previous file with comments | « no previous file | components/metrics/proto/translate_event.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698