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

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

Issue 2757173002: Fix counting of ULP and DISABLED_BY_PREF. (Closed)
Patch Set: rebase to include lastest code changes. For real this time. Created 3 years, 9 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/metrics/proto/translate_event.proto ('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_manager.h" 5 #include "components/translate/core/browser/translate_manager.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 // else. 175 // else.
176 TranslateBrowserMetrics::ReportInitiationStatus( 176 TranslateBrowserMetrics::ReportInitiationStatus(
177 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_KEY); 177 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_KEY);
178 return; 178 return;
179 } 179 }
180 180
181 PrefService* prefs = translate_client_->GetPrefs(); 181 PrefService* prefs = translate_client_->GetPrefs();
182 if (!prefs->GetBoolean(prefs::kEnableTranslate)) { 182 if (!prefs->GetBoolean(prefs::kEnableTranslate)) {
183 TranslateBrowserMetrics::ReportInitiationStatus( 183 TranslateBrowserMetrics::ReportInitiationStatus(
184 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS); 184 TranslateBrowserMetrics::INITIATION_STATUS_DISABLED_BY_PREFS);
185 RecordTranslateEvent(metrics::TranslateEventProto::DISABLED_BY_PREF);
185 const std::string& locale = 186 const std::string& locale =
186 TranslateDownloadManager::GetInstance()->application_locale(); 187 TranslateDownloadManager::GetInstance()->application_locale();
187 TranslateBrowserMetrics::ReportLocalesOnDisabledByPrefs(locale); 188 TranslateBrowserMetrics::ReportLocalesOnDisabledByPrefs(locale);
188 return; 189 return;
189 } 190 }
190 191
191 // Allow disabling of translate from the command line to assist with 192 // Allow disabling of translate from the command line to assist with
192 // automated browser testing. 193 // automated browser testing.
193 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 194 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
194 translate::switches::kDisableTranslate)) { 195 translate::switches::kDisableTranslate)) {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 translate_event_->set_modified_target_language(auto_translate_to); 289 translate_event_->set_modified_target_language(auto_translate_to);
289 RecordTranslateEvent( 290 RecordTranslateEvent(
290 metrics::TranslateEventProto::AUTOMATICALLY_TRANSLATED); 291 metrics::TranslateEventProto::AUTOMATICALLY_TRANSLATED);
291 TranslatePage(language_code, auto_translate_to, false); 292 TranslatePage(language_code, auto_translate_to, false);
292 return; 293 return;
293 } 294 }
294 295
295 if (LanguageInULP(language_code)) { 296 if (LanguageInULP(language_code)) {
296 TranslateBrowserMetrics::ReportInitiationStatus( 297 TranslateBrowserMetrics::ReportInitiationStatus(
297 TranslateBrowserMetrics::INITIATION_STATUS_LANGUAGE_IN_ULP); 298 TranslateBrowserMetrics::INITIATION_STATUS_LANGUAGE_IN_ULP);
298 RecordTranslateEvent(metrics::TranslateEventProto::DISABLED_BY_PREF); 299 RecordTranslateEvent(metrics::TranslateEventProto::LANGUAGE_IN_ULP);
299 return; 300 return;
300 } 301 }
301 302
302 if (TranslateRanker::IsEnabled()) { 303 if (TranslateRanker::IsEnabled()) {
303 TranslateRanker* translate_ranker = TranslateRanker::GetInstance(); 304 TranslateRanker* translate_ranker = TranslateRanker::GetInstance();
304 bool should_offer_translation = translate_ranker->ShouldOfferTranslation( 305 bool should_offer_translation = translate_ranker->ShouldOfferTranslation(
305 *translate_prefs, language_code, target_lang); 306 *translate_prefs, language_code, target_lang);
306 translate_event_->set_ranker_request_timestamp_sec( 307 translate_event_->set_ranker_request_timestamp_sec(
307 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds()); 308 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds());
308 translate_event_->set_ranker_version(translate_ranker->GetModelVersion()); 309 translate_event_->set_ranker_version(translate_ranker->GetModelVersion());
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 void TranslateManager::RecordTranslateEvent(int event_type) { 599 void TranslateManager::RecordTranslateEvent(int event_type) {
599 DCHECK(metrics::TranslateEventProto::EventType_IsValid(event_type)); 600 DCHECK(metrics::TranslateEventProto::EventType_IsValid(event_type));
600 translate_event_->set_event_type( 601 translate_event_->set_event_type(
601 static_cast<metrics::TranslateEventProto::EventType>(event_type)); 602 static_cast<metrics::TranslateEventProto::EventType>(event_type));
602 translate_event_->set_event_timestamp_sec( 603 translate_event_->set_event_timestamp_sec(
603 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds()); 604 (base::TimeTicks::Now() - base::TimeTicks()).InSeconds());
604 TranslateRanker::GetInstance()->RecordTranslateEvent(*translate_event_); 605 TranslateRanker::GetInstance()->RecordTranslateEvent(*translate_event_);
605 } 606 }
606 607
607 } // namespace translate 608 } // namespace translate
OLDNEW
« no previous file with comments | « components/metrics/proto/translate_event.proto ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698