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

Unified Diff: components/translate/content/renderer/translate_helper.h

Issue 2919343007: Check |errorCode| of translate.js and notify to Browser (Closed)
Patch Set: Added test cases to check for translate error types and a minor refactoring. 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 side-by-side diff with in-line comments
Download patch
Index: components/translate/content/renderer/translate_helper.h
diff --git a/components/translate/content/renderer/translate_helper.h b/components/translate/content/renderer/translate_helper.h
index 622e7183fc6e8c11a6ab71b4fd263b0f8523f749..5b8a0735c7809e60232971e0f1521e36c71b38bd 100644
--- a/components/translate/content/renderer/translate_helper.h
+++ b/components/translate/content/renderer/translate_helper.h
@@ -64,6 +64,9 @@ class TranslateHelper : public content::RenderFrameObserver,
// translation.
virtual bool HasTranslationFailed();
+ // Returns the error code generated in translate library.
+ virtual int64_t GetErrorCode();
napper 2017/06/16 12:41:51 Can this method (and the one below) be const?
Takashi Toyoshima 2017/06/16 16:14:17 IMHO, the method causes a side effect should not b
+
// Starts the translation by calling the translate library. This method
// should only be called when the translate script has been injected in the
// page. Returns false if the call failed immediately.
@@ -98,6 +101,12 @@ class TranslateHelper : public content::RenderFrameObserver,
// run successfully. Otherwise, returns 0.0.
virtual double ExecuteScriptAndGetDoubleResult(const std::string& script);
+ // Executes the JavaScript code in |script| in the main frame of RenderView.
+ // and returns the integer value returned by the script evaluation if the
+ // script was run successfully. Otherwise, returns |fallback| value.
+ virtual int64_t ExecuteScriptAndGetIntegerResult(const std::string& script,
+ int64_t fallback);
+
private:
// Converts language code to the one used in server supporting list.
static void ConvertLanguageCodeSynonym(std::string* code);

Powered by Google App Engine
This is Rietveld 408576698