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

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

Issue 2395253002: Send TranslateEventProtos to UMA. (Closed)
Patch Set: nit Created 4 years, 2 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
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 17 matching lines...) Expand all
28 #include "chrome/grit/theme_resources.h" 28 #include "chrome/grit/theme_resources.h"
29 #include "components/prefs/pref_service.h" 29 #include "components/prefs/pref_service.h"
30 #include "components/translate/core/browser/language_model.h" 30 #include "components/translate/core/browser/language_model.h"
31 #include "components/translate/core/browser/language_state.h" 31 #include "components/translate/core/browser/language_state.h"
32 #include "components/translate/core/browser/page_translated_details.h" 32 #include "components/translate/core/browser/page_translated_details.h"
33 #include "components/translate/core/browser/translate_accept_languages.h" 33 #include "components/translate/core/browser/translate_accept_languages.h"
34 #include "components/translate/core/browser/translate_download_manager.h" 34 #include "components/translate/core/browser/translate_download_manager.h"
35 #include "components/translate/core/browser/translate_infobar_delegate.h" 35 #include "components/translate/core/browser/translate_infobar_delegate.h"
36 #include "components/translate/core/browser/translate_manager.h" 36 #include "components/translate/core/browser/translate_manager.h"
37 #include "components/translate/core/browser/translate_prefs.h" 37 #include "components/translate/core/browser/translate_prefs.h"
38 #include "components/translate/core/browser/translate_ranker.h"
38 #include "components/translate/core/common/language_detection_details.h" 39 #include "components/translate/core/common/language_detection_details.h"
39 #include "components/variations/service/variations_service.h" 40 #include "components/variations/service/variations_service.h"
40 #include "content/public/browser/notification_service.h" 41 #include "content/public/browser/notification_service.h"
41 #include "content/public/browser/render_view_host.h" 42 #include "content/public/browser/render_view_host.h"
42 #include "content/public/browser/web_contents.h" 43 #include "content/public/browser/web_contents.h"
43 #include "url/gurl.h" 44 #include "url/gurl.h"
44 45
45 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeTranslateClient); 46 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromeTranslateClient);
46 47
47 ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents) 48 ChromeTranslateClient::ChromeTranslateClient(content::WebContents* web_contents)
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 if (!instance) 161 if (!instance)
161 return; 162 return;
162 163
163 instance->translate_driver().BindRequest(std::move(request)); 164 instance->translate_driver().BindRequest(std::move(request));
164 } 165 }
165 166
166 translate::TranslateManager* ChromeTranslateClient::GetTranslateManager() { 167 translate::TranslateManager* ChromeTranslateClient::GetTranslateManager() {
167 return translate_manager_.get(); 168 return translate_manager_.get();
168 } 169 }
169 170
171 // TODO(rogerm): This code can be moved into TranslateManager.
Roger McFarlane (Chromium) 2016/10/12 18:18:28 This can be removed. TranslateManager is is the in
hamelphi 2016/10/12 21:06:09 Agreed. Removed.
172 bool ChromeTranslateClient::RecordTranslateEvent(
173 const metrics::TranslateEventProto& translate_event) {
174 if (translate::TranslateRanker::IsLoggingEnabled()) {
175 translate::TranslateRanker* translate_ranker =
176 translate::TranslateRanker::GetInstance();
177 if (translate_ranker != nullptr) {
178 translate_ranker->RecordTranslateEvent(translate_event);
179 return true;
180 }
181 }
182 return false;
183 }
184
185
170 void ChromeTranslateClient::ShowTranslateUI( 186 void ChromeTranslateClient::ShowTranslateUI(
171 translate::TranslateStep step, 187 translate::TranslateStep step,
172 const std::string& source_language, 188 const std::string& source_language,
173 const std::string& target_language, 189 const std::string& target_language,
174 translate::TranslateErrors::Type error_type, 190 translate::TranslateErrors::Type error_type,
175 bool triggered_from_menu) { 191 bool triggered_from_menu) {
176 DCHECK(web_contents()); 192 DCHECK(web_contents());
177 if (error_type != translate::TranslateErrors::NONE) 193 if (error_type != translate::TranslateErrors::NONE)
178 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; 194 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR;
179 195
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 if (GetLanguageState().InTranslateNavigation()) 352 if (GetLanguageState().InTranslateNavigation())
337 return; 353 return;
338 } 354 }
339 355
340 TranslateBubbleFactory::Show(browser->window(), web_contents(), step, 356 TranslateBubbleFactory::Show(browser->window(), web_contents(), step,
341 error_type); 357 error_type);
342 #else 358 #else
343 NOTREACHED(); 359 NOTREACHED();
344 #endif 360 #endif
345 } 361 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698