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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 // and returns the string returned by the script evaluation if the script was | 91 // and returns the string returned by the script evaluation if the script was |
92 // run successfully. Otherwise, returns empty string. | 92 // run successfully. Otherwise, returns empty string. |
93 virtual std::string ExecuteScriptAndGetStringResult( | 93 virtual std::string ExecuteScriptAndGetStringResult( |
94 const std::string& script); | 94 const std::string& script); |
95 | 95 |
96 // Executes the JavaScript code in |script| in the main frame of RenderView. | 96 // Executes the JavaScript code in |script| in the main frame of RenderView. |
97 // and returns the number returned by the script evaluation if the script was | 97 // and returns the number returned by the script evaluation if the script was |
98 // run successfully. Otherwise, returns 0.0. | 98 // run successfully. Otherwise, returns 0.0. |
99 virtual double ExecuteScriptAndGetDoubleResult(const std::string& script); | 99 virtual double ExecuteScriptAndGetDoubleResult(const std::string& script); |
100 | 100 |
| 101 // Executes the JavaScript code in |script| in the main frame of RenderView. |
| 102 // and returns the integer value returned by the script evaluation if the |
| 103 // script was run successfully. Otherwise, returns |fallback| value. |
| 104 virtual int64_t ExecuteScriptAndGetIntegerResult(const std::string& script, |
| 105 int64_t fallback); |
| 106 |
101 private: | 107 private: |
102 // Converts language code to the one used in server supporting list. | 108 // Converts language code to the one used in server supporting list. |
103 static void ConvertLanguageCodeSynonym(std::string* code); | 109 static void ConvertLanguageCodeSynonym(std::string* code); |
104 | 110 |
105 const mojom::ContentTranslateDriverPtr& GetTranslateDriver(); | 111 const mojom::ContentTranslateDriverPtr& GetTranslateDriver(); |
106 | 112 |
107 // Cleanups all states and pending callbacks associated with the current | 113 // Cleanups all states and pending callbacks associated with the current |
108 // running page translation. | 114 // running page translation. |
109 void ResetPage(); | 115 void ResetPage(); |
110 | 116 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 | 159 |
154 // Method factory used to make calls to TranslatePageImpl. | 160 // Method factory used to make calls to TranslatePageImpl. |
155 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; | 161 base::WeakPtrFactory<TranslateHelper> weak_method_factory_; |
156 | 162 |
157 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); | 163 DISALLOW_COPY_AND_ASSIGN(TranslateHelper); |
158 }; | 164 }; |
159 | 165 |
160 } // namespace translate | 166 } // namespace translate |
161 | 167 |
162 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ | 168 #endif // COMPONENTS_TRANSLATE_CONTENT_RENDERER_TRANSLATE_HELPER_H_ |
OLD | NEW |