OLD | NEW |
---|---|
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 <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
79 | 79 |
80 syncer::UserEventService* const user_event_service = | 80 syncer::UserEventService* const user_event_service = |
81 browser_sync::UserEventServiceFactory::GetForProfile(profile); | 81 browser_sync::UserEventServiceFactory::GetForProfile(profile); |
82 | 82 |
83 const auto* const entry = | 83 const auto* const entry = |
84 web_contents->GetController().GetLastCommittedEntry(); | 84 web_contents->GetController().GetLastCommittedEntry(); |
85 | 85 |
86 // If entry is null, we don't record the page. | 86 // If entry is null, we don't record the page. |
87 // The navigation entry can be null in situations like download or initial | 87 // The navigation entry can be null in situations like download or initial |
88 // blank page. | 88 // blank page. |
89 if (entry != nullptr) { | 89 if (entry != nullptr && |
90 TranslateService::IsTranslatableURL(entry->GetVirtualURL())) { | |
skym
2017/06/02 21:22:40
Would be nice to have a test case get filtered by
renjieliu1
2017/06/05 06:39:19
Done.
| |
90 user_event_service->RecordUserEvent( | 91 user_event_service->RecordUserEvent( |
91 translate::ConstructLanguageDetectionEvent(details)); | 92 translate::ConstructLanguageDetectionEvent( |
93 entry->GetTimestamp().ToInternalValue(), details)); | |
92 } | 94 } |
93 } | 95 } |
94 | 96 |
95 } // namespace | 97 } // namespace |
96 | 98 |
97 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeTranslateClient); | 99 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeTranslateClient); |
98 | 100 |
99 ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents) | 101 ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents) |
100 : content::WebContentsObserver(web_contents), | 102 : content::WebContentsObserver(web_contents), |
101 translate_driver_(&web_contents->GetController()), | 103 translate_driver_(&web_contents->GetController()), |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
392 return ShowTranslateBubbleResult::SUCCESS; | 394 return ShowTranslateBubbleResult::SUCCESS; |
393 } | 395 } |
394 | 396 |
395 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, | 397 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, |
396 error_type); | 398 error_type); |
397 #else | 399 #else |
398 NOTREACHED(); | 400 NOTREACHED(); |
399 return ShowTranslateBubbleResult::SUCCESS; | 401 return ShowTranslateBubbleResult::SUCCESS; |
400 #endif | 402 #endif |
401 } | 403 } |
OLD | NEW |