| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 IPC_MESSAGE_HANDLER(ViewMsg_NotifyRenderViewType, | 560 IPC_MESSAGE_HANDLER(ViewMsg_NotifyRenderViewType, |
| 561 OnNotifyRendererViewType) | 561 OnNotifyRendererViewType) |
| 562 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) | 562 IPC_MESSAGE_HANDLER(ViewMsg_MediaPlayerActionAt, OnMediaPlayerActionAt) |
| 563 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) | 563 IPC_MESSAGE_HANDLER(ViewMsg_SetActive, OnSetActive) |
| 564 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, | 564 IPC_MESSAGE_HANDLER(ViewMsg_SetEditCommandsForNextKeyEvent, |
| 565 OnSetEditCommandsForNextKeyEvent) | 565 OnSetEditCommandsForNextKeyEvent) |
| 566 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, | 566 IPC_MESSAGE_HANDLER(ViewMsg_ExecuteCode, |
| 567 OnExecuteCode) | 567 OnExecuteCode) |
| 568 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, | 568 IPC_MESSAGE_HANDLER(ViewMsg_CustomContextMenuAction, |
| 569 OnCustomContextMenuAction) | 569 OnCustomContextMenuAction) |
| 570 IPC_MESSAGE_HANDLER(ViewMsg_TranslatePage, OnTranslatePage) |
| 570 IPC_MESSAGE_HANDLER(ViewMsg_TranslateTextReponse, OnTranslateTextResponse) | 571 IPC_MESSAGE_HANDLER(ViewMsg_TranslateTextReponse, OnTranslateTextResponse) |
| 571 | 572 |
| 572 // Have the super handle all other messages. | 573 // Have the super handle all other messages. |
| 573 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 574 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 574 IPC_END_MESSAGE_MAP() | 575 IPC_END_MESSAGE_MAP() |
| 575 } | 576 } |
| 576 | 577 |
| 577 void RenderView::SendThumbnail() { | 578 void RenderView::SendThumbnail() { |
| 578 WebFrame* main_frame = webview()->mainFrame(); | 579 WebFrame* main_frame = webview()->mainFrame(); |
| 579 if (!main_frame) | 580 if (!main_frame) |
| (...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3301 } | 3302 } |
| 3302 | 3303 |
| 3303 void RenderView::OnSetAltErrorPageURL(const GURL& url) { | 3304 void RenderView::OnSetAltErrorPageURL(const GURL& url) { |
| 3304 alternate_error_page_url_ = url; | 3305 alternate_error_page_url_ = url; |
| 3305 } | 3306 } |
| 3306 | 3307 |
| 3307 void RenderView::OnCustomContextMenuAction(unsigned action) { | 3308 void RenderView::OnCustomContextMenuAction(unsigned action) { |
| 3308 webview()->performCustomContextMenuAction(action); | 3309 webview()->performCustomContextMenuAction(action); |
| 3309 } | 3310 } |
| 3310 | 3311 |
| 3312 void RenderView::OnTranslatePage(int page_id, |
| 3313 const std::string& source_lang, |
| 3314 const std::string& target_lang) { |
| 3315 if (page_id != page_id_) |
| 3316 return; // Not the page we expected, nothing to do. |
| 3317 |
| 3318 WebFrame* main_frame = webview()->mainFrame(); |
| 3319 if (!main_frame) |
| 3320 return; |
| 3321 page_translator_->Translate(main_frame, source_lang, target_lang); |
| 3322 } |
| 3323 |
| 3311 void RenderView::OnTranslateTextResponse( | 3324 void RenderView::OnTranslateTextResponse( |
| 3312 int work_id, int error_id, const std::vector<string16>& text_chunks) { | 3325 int work_id, int error_id, const std::vector<string16>& text_chunks) { |
| 3313 if (error_id) { | 3326 text_translator_.OnTranslationResponse(work_id, error_id, text_chunks); |
| 3314 page_translator_->TranslationError(work_id, error_id); | |
| 3315 return; | |
| 3316 } | |
| 3317 page_translator_->TextTranslated(work_id, text_chunks); | |
| 3318 } | 3327 } |
| 3319 | 3328 |
| 3320 void RenderView::OnInstallMissingPlugin() { | 3329 void RenderView::OnInstallMissingPlugin() { |
| 3321 // This could happen when the first default plugin is deleted. | 3330 // This could happen when the first default plugin is deleted. |
| 3322 if (first_default_plugin_) | 3331 if (first_default_plugin_) |
| 3323 first_default_plugin_->InstallMissingPlugin(); | 3332 first_default_plugin_->InstallMissingPlugin(); |
| 3324 } | 3333 } |
| 3325 | 3334 |
| 3326 void RenderView::OnFileChooserResponse( | 3335 void RenderView::OnFileChooserResponse( |
| 3327 const std::vector<FilePath>& file_names) { | 3336 const std::vector<FilePath>& file_names) { |
| (...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4092 new PluginMsg_SignalModalDialogEvent(host_window_)); | 4101 new PluginMsg_SignalModalDialogEvent(host_window_)); |
| 4093 | 4102 |
| 4094 message->EnableMessagePumping(); // Runs a nested message loop. | 4103 message->EnableMessagePumping(); // Runs a nested message loop. |
| 4095 bool rv = Send(message); | 4104 bool rv = Send(message); |
| 4096 | 4105 |
| 4097 PluginChannelHost::Broadcast( | 4106 PluginChannelHost::Broadcast( |
| 4098 new PluginMsg_ResetModalDialogEvent(host_window_)); | 4107 new PluginMsg_ResetModalDialogEvent(host_window_)); |
| 4099 | 4108 |
| 4100 return rv; | 4109 return rv; |
| 4101 } | 4110 } |
| OLD | NEW |