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

Side by Side Diff: ios/web_view/internal/translate/web_view_translate_client.h

Issue 2913593002: Implementation of translation event logging. (Closed)
Patch Set: fix 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 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 #ifndef IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 5 #ifndef IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
6 #define IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 6 #define IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #import "base/ios/weak_nsobject.h" 11 #import "base/ios/weak_nsobject.h"
12 #include "components/translate/core/browser/translate_client.h" 12 #include "components/translate/core/browser/translate_client.h"
13 #include "components/translate/core/browser/translate_step.h" 13 #include "components/translate/core/browser/translate_step.h"
14 #include "components/translate/core/common/translate_errors.h" 14 #include "components/translate/core/common/translate_errors.h"
15 #import "components/translate/ios/browser/ios_translate_driver.h" 15 #import "components/translate/ios/browser/ios_translate_driver.h"
16 #include "ios/web/public/web_state/web_state_observer.h" 16 #include "ios/web/public/web_state/web_state_observer.h"
17 #import "ios/web/public/web_state/web_state_user_data.h" 17 #import "ios/web/public/web_state/web_state_user_data.h"
18 18
19 @class CWVTranslationController; 19 @class CWVTranslationController;
20 20
21 class PrefService; 21 class PrefService;
22 22
23 namespace metrics {
24 class TranslateEventProto;
25 } // namespace metrics
26
23 namespace translate { 27 namespace translate {
24 class TranslateAcceptLanguages; 28 class TranslateAcceptLanguages;
25 class TranslatePrefs; 29 class TranslatePrefs;
26 class TranslateManager; 30 class TranslateManager;
27 } // namespace translate 31 } // namespace translate
28 32
29 namespace web { 33 namespace web {
30 class WebState; 34 class WebState;
31 } 35 } // namespace web
32 36
33 namespace ios_web_view { 37 namespace ios_web_view {
34 38
35 class WebViewTranslateClient 39 class WebViewTranslateClient
36 : public translate::TranslateClient, 40 : public translate::TranslateClient,
37 public web::WebStateObserver, 41 public web::WebStateObserver,
38 public web::WebStateUserData<WebViewTranslateClient> { 42 public web::WebStateUserData<WebViewTranslateClient> {
39 public: 43 public:
40 ~WebViewTranslateClient() override; 44 ~WebViewTranslateClient() override;
41 45
(...skipping 11 matching lines...) Expand all
53 57
54 // The lifetime of WebViewTranslateClient is managed by WebStateUserData. 58 // The lifetime of WebViewTranslateClient is managed by WebStateUserData.
55 explicit WebViewTranslateClient(web::WebState* web_state); 59 explicit WebViewTranslateClient(web::WebState* web_state);
56 60
57 // TranslateClient implementation. 61 // TranslateClient implementation.
58 translate::TranslateDriver* GetTranslateDriver() override; 62 translate::TranslateDriver* GetTranslateDriver() override;
59 PrefService* GetPrefs() override; 63 PrefService* GetPrefs() override;
60 std::unique_ptr<translate::TranslatePrefs> GetTranslatePrefs() override; 64 std::unique_ptr<translate::TranslatePrefs> GetTranslatePrefs() override;
61 translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages() override; 65 translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages() override;
62 int GetInfobarIconID() const override; 66 int GetInfobarIconID() const override;
67 void RecordTranslateEvent(const metrics::TranslateEventProto&) override;
63 std::unique_ptr<infobars::InfoBar> CreateInfoBar( 68 std::unique_ptr<infobars::InfoBar> CreateInfoBar(
64 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate) 69 std::unique_ptr<translate::TranslateInfoBarDelegate> delegate)
65 const override; 70 const override;
66 void ShowTranslateUI(translate::TranslateStep step, 71 void ShowTranslateUI(translate::TranslateStep step,
67 const std::string& source_language, 72 const std::string& source_language,
68 const std::string& target_language, 73 const std::string& target_language,
69 translate::TranslateErrors::Type error_type, 74 translate::TranslateErrors::Type error_type,
70 bool triggered_from_menu) override; 75 bool triggered_from_menu) override;
71 bool IsTranslatableURL(const GURL& url) override; 76 bool IsTranslatableURL(const GURL& url) override;
72 void ShowReportLanguageDetectionErrorUI(const GURL& report_url) override; 77 void ShowReportLanguageDetectionErrorUI(const GURL& report_url) override;
73 78
74 // web::WebStateObserver implementation. 79 // web::WebStateObserver implementation.
75 void WebStateDestroyed() override; 80 void WebStateDestroyed() override;
76 81
77 std::unique_ptr<translate::TranslateManager> translate_manager_; 82 std::unique_ptr<translate::TranslateManager> translate_manager_;
78 translate::IOSTranslateDriver translate_driver_; 83 translate::IOSTranslateDriver translate_driver_;
79 84
80 // ObjC class that wraps this class. 85 // ObjC class that wraps this class.
81 base::WeakNSObject<CWVTranslationController> translation_controller_; 86 base::WeakNSObject<CWVTranslationController> translation_controller_;
82 87
83 DISALLOW_COPY_AND_ASSIGN(WebViewTranslateClient); 88 DISALLOW_COPY_AND_ASSIGN(WebViewTranslateClient);
84 }; 89 };
85 90
86 } // namespace ios_web_view 91 } // namespace ios_web_view
87 92
88 #endif // IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_ 93 #endif // IOS_WEB_VIEW_INTERNAL_TRANSLATE_WEB_VIEW_TRANSLATE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698