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

Unified Diff: ios/chrome/browser/translate/chrome_ios_translate_client.mm

Issue 2962783003: Implement ios language detection logging. (Closed)
Patch Set: updates Created 3 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/browser/translate/chrome_ios_translate_client.mm
diff --git a/ios/chrome/browser/translate/chrome_ios_translate_client.mm b/ios/chrome/browser/translate/chrome_ios_translate_client.mm
index 4b984e2e8732b65119d519336eb99885ecb81689..65bef039afb5eb4f6524d5ca33ba97d1381fd240 100644
--- a/ios/chrome/browser/translate/chrome_ios_translate_client.mm
+++ b/ios/chrome/browser/translate/chrome_ios_translate_client.mm
@@ -23,6 +23,7 @@
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/browser/translate_step.h"
#include "components/translate/core/common/language_detection_details.h"
+#include "components/translate/core/common/language_detection_logging_helper.h"
#include "components/translate/core/common/translation_logging_helper.h"
#include "ios/chrome/browser/browser_state/chrome_browser_state.h"
#include "ios/chrome/browser/infobars/infobar.h"
@@ -193,7 +194,25 @@ int ChromeIOSTranslateClient::GetInfobarIconID() const {
void ChromeIOSTranslateClient::RecordLanguageDetectionEvent(
const translate::LanguageDetectionDetails& details) const {
- // TODO(crbug.com/728491): Implement this.
+ if (!base::FeatureList::IsEnabled(switches::kSyncUserLanguageDetectionEvents))
+ return;
+
+ syncer::UserEventService* const user_event_service =
+ IOSUserEventServiceFactory::GetForBrowserState(
+ ios::ChromeBrowserState::FromBrowserState(
+ web_state()->GetBrowserState()));
+ const auto* const item =
+ web_state()->GetNavigationManager()->GetLastCommittedItem();
+
+ // If entry is null, we don't record the page.
+ // The navigation entry can be null in situations like download or initial
+ // blank page.
+ if (item != nullptr &&
+ TranslateServiceIOS::IsTranslatableURL(item->GetVirtualURL())) {
+ user_event_service->RecordUserEvent(
+ translate::ConstructLanguageDetectionEvent(
+ item->GetTimestamp().ToInternalValue(), details));
+ }
}
bool ChromeIOSTranslateClient::IsTranslatableURL(const GURL& url) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698