| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| 6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 6 #define COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace translate { | 25 namespace translate { |
| 26 | 26 |
| 27 // This class deals with page translation. | 27 // This class deals with page translation. |
| 28 // There is one TranslateHelper per RenderView. | 28 // There is one TranslateHelper per RenderView. |
| 29 class TranslateHelper : public content::RenderFrameObserver, | 29 class TranslateHelper : public content::RenderFrameObserver, |
| 30 public mojom::Page { | 30 public mojom::Page { |
| 31 public: | 31 public: |
| 32 TranslateHelper(content::RenderFrame* render_frame, | 32 TranslateHelper(content::RenderFrame* render_frame, |
| 33 int world_id, | 33 int world_id, |
| 34 int extension_group, | |
| 35 const std::string& extension_scheme); | 34 const std::string& extension_scheme); |
| 36 ~TranslateHelper() override; | 35 ~TranslateHelper() override; |
| 37 | 36 |
| 38 // Informs us that the page's text has been extracted. | 37 // Informs us that the page's text has been extracted. |
| 39 void PageCaptured(const base::string16& contents); | 38 void PageCaptured(const base::string16& contents); |
| 40 | 39 |
| 41 // Lets the translation system know that we are preparing to navigate to | 40 // Lets the translation system know that we are preparing to navigate to |
| 42 // the specified URL. If there is anything that can or should be done before | 41 // the specified URL. If there is anything that can or should be done before |
| 43 // this URL loads, this is the time to prepare for it. | 42 // this URL loads, this is the time to prepare for it. |
| 44 void PrepareForUrl(const GURL& url); | 43 void PrepareForUrl(const GURL& url); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 std::string source_lang_; | 137 std::string source_lang_; |
| 139 std::string target_lang_; | 138 std::string target_lang_; |
| 140 | 139 |
| 141 // Time when a page langauge is determined. This is used to know a duration | 140 // Time when a page langauge is determined. This is used to know a duration |
| 142 // time from showing infobar to requesting translation. | 141 // time from showing infobar to requesting translation. |
| 143 base::TimeTicks language_determined_time_; | 142 base::TimeTicks language_determined_time_; |
| 144 | 143 |
| 145 // The world ID to use for script execution. | 144 // The world ID to use for script execution. |
| 146 int world_id_; | 145 int world_id_; |
| 147 | 146 |
| 148 // The extension group. | |
| 149 int extension_group_; | |
| 150 | |
| 151 // The URL scheme for translate extensions. | 147 // The URL scheme for translate extensions. |
| 152 std::string extension_scheme_; | 148 std::string extension_scheme_; |
| 153 | 149 |
| 154 mojom::ContentTranslateDriverPtr translate_driver_; | 150 mojom::ContentTranslateDriverPtr translate_driver_; |
| 155 | 151 |
| 156 mojo::Binding<mojom::Page> binding_; | 152 mojo::Binding<mojom::Page> binding_; |
| 157 | 153 |
| 158 // Method factory used to make calls to TranslatePageImpl. | 154 // Method factory used to make calls to TranslatePageImpl. |
| 159 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 155 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
| 160 | 156 |
| 161 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 157 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
| 162 }; | 158 }; |
| 163 | 159 |
| 164 } // namespace translate | 160 } // namespace translate |
| 165 | 161 |
| 166 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 162 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
| OLD | NEW |