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

Side by Side Diff: components/translate/ios/browser/ios_translate_driver.h

Issue 2913573002: Updates language model on iOS. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | components/translate/ios/browser/ios_translate_driver.mm » ('j') | 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 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_ 5 #ifndef COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_
6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_ 6 #define COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "components/translate/core/browser/translate_driver.h" 13 #include "components/translate/core/browser/translate_driver.h"
14 #include "components/translate/ios/browser/language_detection_controller.h" 14 #include "components/translate/ios/browser/language_detection_controller.h"
15 #include "components/translate/ios/browser/translate_controller.h" 15 #include "components/translate/ios/browser/translate_controller.h"
16 #include "ios/web/public/web_state/web_state_observer.h" 16 #include "ios/web/public/web_state/web_state_observer.h"
17 17
18 @class CRWJSInjectionReceiver; 18 @class CRWJSInjectionReceiver;
19 19
20 namespace web { 20 namespace web {
21 class NavigationManager; 21 class NavigationManager;
22 class WebState; 22 class WebState;
23 } 23 }
24 24
25 namespace translate { 25 namespace translate {
26 26
27 class TranslateManager; 27 class TranslateManager;
28 class LanguageModel;
28 29
29 // Content implementation of TranslateDriver. 30 // Content implementation of TranslateDriver.
30 class IOSTranslateDriver : public TranslateDriver, 31 class IOSTranslateDriver : public TranslateDriver,
31 public TranslateController::Observer, 32 public TranslateController::Observer,
32 public web::WebStateObserver { 33 public web::WebStateObserver {
33 public: 34 public:
34 IOSTranslateDriver(web::WebState* web_state, 35 IOSTranslateDriver(web::WebState* web_state,
35 web::NavigationManager* navigation_manager, 36 web::NavigationManager* navigation_manager,
36 TranslateManager* translate_manager); 37 TranslateManager* translate_manager,
38 LanguageModel* language_model);
37 ~IOSTranslateDriver() override; 39 ~IOSTranslateDriver() override;
38 40
39 LanguageDetectionController* language_detection_controller() { 41 LanguageDetectionController* language_detection_controller() {
40 return language_detection_controller_.get(); 42 return language_detection_controller_.get();
41 } 43 }
42 44
43 TranslateController* translate_controller() { 45 TranslateController* translate_controller() {
44 return translate_controller_.get(); 46 return translate_controller_.get();
45 } 47 }
46 48
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 void OnTranslateScriptReady(bool success, 93 void OnTranslateScriptReady(bool success,
92 double load_time, 94 double load_time,
93 double ready_time) override; 95 double ready_time) override;
94 void OnTranslateComplete(bool success, 96 void OnTranslateComplete(bool success,
95 const std::string& original_language, 97 const std::string& original_language,
96 double translation_time) override; 98 double translation_time) override;
97 99
98 // The navigation manager of the tab we are associated with. 100 // The navigation manager of the tab we are associated with.
99 web::NavigationManager* navigation_manager_; 101 web::NavigationManager* navigation_manager_;
100 102
103 // Model to be notified about detected language of every page visited.
104 translate::LanguageModel* language_model_;
105
101 base::WeakPtr<TranslateManager> translate_manager_; 106 base::WeakPtr<TranslateManager> translate_manager_;
102 std::unique_ptr<TranslateController> translate_controller_; 107 std::unique_ptr<TranslateController> translate_controller_;
103 std::unique_ptr<LanguageDetectionController> language_detection_controller_; 108 std::unique_ptr<LanguageDetectionController> language_detection_controller_;
104 std::unique_ptr<LanguageDetectionController::CallbackList::Subscription> 109 std::unique_ptr<LanguageDetectionController::CallbackList::Subscription>
105 language_detection_callback_subscription_; 110 language_detection_callback_subscription_;
106 111
107 // An ever-increasing sequence number of the current page, used to match up 112 // An ever-increasing sequence number of the current page, used to match up
108 // translation requests with responses. 113 // translation requests with responses.
109 // This matches the similar field in TranslateHelper in the renderer on other 114 // This matches the similar field in TranslateHelper in the renderer on other
110 // platforms. 115 // platforms.
111 int page_seq_no_; 116 int page_seq_no_;
112 117
113 // When a translation is in progress, its page sequence number is stored in 118 // When a translation is in progress, its page sequence number is stored in
114 // |pending_page_seq_no_|. 119 // |pending_page_seq_no_|.
115 int pending_page_seq_no_; 120 int pending_page_seq_no_;
116 121
117 // Parameters of the current translation. 122 // Parameters of the current translation.
118 std::string source_language_; 123 std::string source_language_;
119 std::string target_language_; 124 std::string target_language_;
120 125
121 base::WeakPtrFactory<IOSTranslateDriver> weak_method_factory_; 126 base::WeakPtrFactory<IOSTranslateDriver> weak_method_factory_;
122 127
123 DISALLOW_COPY_AND_ASSIGN(IOSTranslateDriver); 128 DISALLOW_COPY_AND_ASSIGN(IOSTranslateDriver);
124 }; 129 };
125 130
126 } // namespace translate 131 } // namespace translate
127 132
128 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_ 133 #endif // COMPONENTS_TRANSLATE_IOS_BROWSER_IOS_TRANSLATE_DRIVER_H_
OLDNEW
« no previous file with comments | « no previous file | components/translate/ios/browser/ios_translate_driver.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698