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 CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 5 #ifndef CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 6 #define CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/gtest_prod_util.h" | 10 #include "base/gtest_prod_util.h" |
11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
12 #include "base/time/time.h" | 12 #include "base/time/time.h" |
13 #include "chrome/common/translate/translate_errors.h" | 13 #include "chrome/common/translate/translate_errors.h" |
14 #include "content/public/renderer/render_view_observer.h" | 14 #include "content/public/renderer/render_view_observer.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 class WebDocument; | 17 class WebDocument; |
18 class WebFrame; | 18 class WebFrame; |
19 } | 19 } |
20 | 20 |
21 // This class deals with page translation. | 21 // This class deals with page translation. |
22 // There is one TranslateHelper per RenderView. | 22 // There is one TranslateHelper per RenderView. |
23 | 23 |
24 class TranslateHelper : public content::RenderViewObserver { | 24 class TranslateHelper : public content::RenderViewObserver { |
25 public: | 25 public: |
26 explicit TranslateHelper(content::RenderView* render_view); | 26 explicit TranslateHelper(content::RenderView* render_view); |
27 virtual ~TranslateHelper(); | 27 virtual ~TranslateHelper(); |
28 | 28 |
29 // Informs us that the page's text has been extracted. | 29 // Informs us that the page's text has been extracted. |
30 void PageCaptured(int page_id, const string16& contents); | 30 void PageCaptured(int page_id, const base::string16& contents); |
31 | 31 |
32 protected: | 32 protected: |
33 // The following methods are protected so they can be overridden in | 33 // The following methods are protected so they can be overridden in |
34 // unit-tests. | 34 // unit-tests. |
35 void OnTranslatePage(int page_id, | 35 void OnTranslatePage(int page_id, |
36 const std::string& translate_script, | 36 const std::string& translate_script, |
37 const std::string& source_lang, | 37 const std::string& source_lang, |
38 const std::string& target_lang); | 38 const std::string& target_lang); |
39 void OnRevertTranslation(int page_id); | 39 void OnRevertTranslation(int page_id); |
40 | 40 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 // time from showing infobar to requesting translation. | 145 // time from showing infobar to requesting translation. |
146 base::TimeTicks language_determined_time_; | 146 base::TimeTicks language_determined_time_; |
147 | 147 |
148 // Method factory used to make calls to TranslatePageImpl. | 148 // Method factory used to make calls to TranslatePageImpl. |
149 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 149 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
150 | 150 |
151 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 151 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
152 }; | 152 }; |
153 | 153 |
154 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ | 154 #endif // CHROME_RENDERER_TRANSLATE_TRANSLATE_HELPER_H_ |
OLD | NEW |