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

Unified Diff: chrome/browser/automation/automation_provider.cc

Issue 3061054: New pyauto translate hooks: always and never translate button. (Closed)
Patch Set: Added max tries count Created 10 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_observers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/automation/automation_provider.cc
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc
index 271d8b1966bd5bced3ce12fa6a283f442599954b..a3869d6bf0df5f2e787a58ce15f35aa63d9b49d0 100644
--- a/chrome/browser/automation/automation_provider.cc
+++ b/chrome/browser/automation/automation_provider.cc
@@ -2864,6 +2864,17 @@ void AutomationProvider::SelectTranslateOption(Browser* browser,
return_value->SetBoolean("translation_success", true);
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
return;
+ } else if (option == "click_always_translate_lang_button") {
+ if (!translate_bar->ShouldShowAlwaysTranslateButton()) {
+ AutomationJSONReply(this, reply_message)
+ .SendError("Always translate button not showing.");
+ return;
+ }
+ // Clicking 'Always Translate' triggers a translation. The observer will
+ // wait until the translation is complete before sending the reply.
+ new PageTranslatedObserver(this, reply_message, tab_contents);
+ translate_bar->AlwaysTranslatePageLanguage();
+ return;
}
AutomationJSONReply reply(this, reply_message);
@@ -2887,6 +2898,18 @@ void AutomationProvider::SelectTranslateOption(Browser* browser,
} else if (option == "revert_translation") {
translate_bar->RevertTranslation();
reply.SendSuccess(NULL);
+ } else if (option == "click_never_translate_lang_button") {
+ if (!translate_bar->ShouldShowNeverTranslateButton()) {
+ reply.SendError("Always translate button not showing.");
+ return;
+ }
+ translate_bar->NeverTranslatePageLanguage();
+ reply.SendSuccess(NULL);
+ } else if (option == "decline_translation") {
+ // This is the function called when an infobar is dismissed or when the
+ // user clicks the 'Nope' translate button.
+ translate_bar->TranslationDeclined();
+ reply.SendSuccess(NULL);
} else {
reply.SendError("Invalid string found for option.");
}
« no previous file with comments | « no previous file | chrome/browser/automation/automation_provider_observers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698