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

Unified Diff: chrome/renderer/render_view.cc

Issue 552216: This CL makes the TranslationService class send the text to be translated to ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 11 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: chrome/renderer/render_view.cc
===================================================================
--- chrome/renderer/render_view.cc (revision 37411)
+++ chrome/renderer/render_view.cc (working copy)
@@ -567,6 +567,7 @@
OnExecuteCode)
IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction,
OnCustomContextMenuAction)
+ IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage)
IPC_MESSAGE_HANDLER(ViewMsg_TranslateTextReponse, OnTranslateTextResponse)
// Have the super handle all other messages.
@@ -3308,13 +3309,21 @@
webview()->performCustomContextMenuAction(action);
}
+void RenderView::OnTranslatePage(int page_id,
+ const std::string& source_lang,
+ const std::string& target_lang) {
+ if (page_id != page_id_)
+ return; // Not the page we expected, nothing to do.
+
+ WebFrame* main_frame = webview()->mainFrame();
+ if (!main_frame)
+ return;
+ page_translator_->Translate(main_frame, source_lang, target_lang);
+}
+
void RenderView::OnTranslateTextResponse(
int work_id, int error_id, const std::vector<string16>& text_chunks) {
- if (error_id) {
- page_translator_->TranslationError(work_id, error_id);
- return;
- }
- page_translator_->TextTranslated(work_id, text_chunks);
+ text_translator_.OnTranslationResponse(work_id, error_id, text_chunks);
}
void RenderView::OnInstallMissingPlugin() {

Powered by Google App Engine
This is Rietveld 408576698