| 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 #include "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 963 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 974 device_orientation_dispatcher_->OnMessageReceived(message)) { | 974 device_orientation_dispatcher_->OnMessageReceived(message)) { |
| 975 return true; | 975 return true; |
| 976 } | 976 } |
| 977 | 977 |
| 978 bool handled = true; | 978 bool handled = true; |
| 979 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 979 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
| 980 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) | 980 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) |
| 981 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) | 981 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) |
| 982 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) | 982 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) |
| 983 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) | 983 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) |
| 984 IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview) |
| 985 IPC_MESSAGE_HANDLER(ViewMsg_PrintNodeUnderContextMenu, |
| 986 OnPrintNodeUnderContextMenu) |
| 984 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 987 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
| 985 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 988 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
| 986 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 989 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
| 987 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) | 990 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
| 988 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) | 991 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
| 989 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 992 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
| 990 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 993 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
| 991 #if defined(OS_MACOSX) | 994 #if defined(OS_MACOSX) |
| 992 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 995 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
| 993 #endif | 996 #endif |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 OnAccessibilityDoDefaultAction) | 1105 OnAccessibilityDoDefaultAction) |
| 1103 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, | 1106 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, |
| 1104 OnAccessibilityNotificationsAck) | 1107 OnAccessibilityNotificationsAck) |
| 1105 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) | 1108 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
| 1106 #if defined(ENABLE_FLAPPER_HACKS) | 1109 #if defined(ENABLE_FLAPPER_HACKS) |
| 1107 IPC_MESSAGE_HANDLER(ViewMsg_PepperConnectTcpACK, OnConnectTcpACK) | 1110 IPC_MESSAGE_HANDLER(ViewMsg_PepperConnectTcpACK, OnConnectTcpACK) |
| 1108 #endif | 1111 #endif |
| 1109 #if defined(OS_MACOSX) | 1112 #if defined(OS_MACOSX) |
| 1110 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1113 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
| 1111 #endif | 1114 #endif |
| 1112 IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview) | |
| 1113 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, | 1115 IPC_MESSAGE_HANDLER(ViewMsg_JavaScriptStressTestControl, |
| 1114 OnJavaScriptStressTestControl) | 1116 OnJavaScriptStressTestControl) |
| 1117 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 1115 | 1118 |
| 1116 // Have the super handle all other messages. | 1119 // Have the super handle all other messages. |
| 1117 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 1120 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 1118 IPC_END_MESSAGE_MAP() | 1121 IPC_END_MESSAGE_MAP() |
| 1119 return handled; | 1122 return handled; |
| 1120 } | 1123 } |
| 1121 | 1124 |
| 1122 void RenderView::OnCaptureThumbnail() { | 1125 void RenderView::OnCaptureThumbnail() { |
| 1123 WebFrame* main_frame = webview()->mainFrame(); | 1126 WebFrame* main_frame = webview()->mainFrame(); |
| 1124 if (!main_frame) | 1127 if (!main_frame) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1186 if (webview()) { | 1189 if (webview()) { |
| 1187 // If the user has selected text in the currently focused frame we print | 1190 // If the user has selected text in the currently focused frame we print |
| 1188 // only that frame (this makes print selection work for multiple frames). | 1191 // only that frame (this makes print selection work for multiple frames). |
| 1189 if (webview()->focusedFrame()->hasSelection()) | 1192 if (webview()->focusedFrame()->hasSelection()) |
| 1190 Print(webview()->focusedFrame(), false, true); | 1193 Print(webview()->focusedFrame(), false, true); |
| 1191 else | 1194 else |
| 1192 Print(webview()->focusedFrame(), false, true); | 1195 Print(webview()->focusedFrame(), false, true); |
| 1193 } | 1196 } |
| 1194 } | 1197 } |
| 1195 | 1198 |
| 1199 void RenderView::OnPrintNodeUnderContextMenu() { |
| 1200 if (context_menu_node_.isNull()) { |
| 1201 NOTREACHED(); |
| 1202 return; |
| 1203 } |
| 1204 |
| 1205 // Make a copy of the node, since we will do a sync call to the browser and |
| 1206 // during that time OnContextMenuClosed might reset context_menu_node_. |
| 1207 WebNode context_menu_node(context_menu_node_); |
| 1208 GetPrintWebViewHelper()->PrintNode(&context_menu_node, false, false); |
| 1209 } |
| 1210 |
| 1196 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { | 1211 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { |
| 1197 if (load_id != page_id_) | 1212 if (load_id != page_id_) |
| 1198 return; // this capture call is no longer relevant due to navigation | 1213 return; // this capture call is no longer relevant due to navigation |
| 1199 if (load_id == last_indexed_page_id_) | 1214 if (load_id == last_indexed_page_id_) |
| 1200 return; // we already indexed this page | 1215 return; // we already indexed this page |
| 1201 | 1216 |
| 1202 if (!webview()) | 1217 if (!webview()) |
| 1203 return; | 1218 return; |
| 1204 | 1219 |
| 1205 WebFrame* main_frame = webview()->mainFrame(); | 1220 WebFrame* main_frame = webview()->mainFrame(); |
| (...skipping 1300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2506 if (spelled_right) | 2521 if (spelled_right) |
| 2507 params.misspelled_word.clear(); | 2522 params.misspelled_word.clear(); |
| 2508 } | 2523 } |
| 2509 // Serializing a GURL longer than chrome::kMaxURLChars will fail, so don't do | 2524 // Serializing a GURL longer than chrome::kMaxURLChars will fail, so don't do |
| 2510 // it. We replace it with an empty GURL so the appropriate items are disabled | 2525 // it. We replace it with an empty GURL so the appropriate items are disabled |
| 2511 // in the context menu. | 2526 // in the context menu. |
| 2512 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | 2527 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
| 2513 // data encoded images. We should have a way to save them. | 2528 // data encoded images. We should have a way to save them. |
| 2514 if (params.src_url.spec().size() > chrome::kMaxURLChars) | 2529 if (params.src_url.spec().size() > chrome::kMaxURLChars) |
| 2515 params.src_url = GURL(); | 2530 params.src_url = GURL(); |
| 2531 context_menu_node_ = data.node; |
| 2516 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); | 2532 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
| 2517 } | 2533 } |
| 2518 | 2534 |
| 2519 bool RenderView::supportsFullscreen() { | 2535 bool RenderView::supportsFullscreen() { |
| 2520 return CommandLine::ForCurrentProcess()->HasSwitch( | 2536 return CommandLine::ForCurrentProcess()->HasSwitch( |
| 2521 switches::kEnableVideoFullscreen); | 2537 switches::kEnableVideoFullscreen); |
| 2522 } | 2538 } |
| 2523 | 2539 |
| 2524 void RenderView::enterFullscreenForNode(const WebKit::WebNode& node) { | 2540 void RenderView::enterFullscreenForNode(const WebKit::WebNode& node) { |
| 2525 NOTIMPLEMENTED(); | 2541 NOTIMPLEMENTED(); |
| (...skipping 2877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5403 FROM_HERE, | 5419 FROM_HERE, |
| 5404 accessibility_method_factory_.NewRunnableMethod( | 5420 accessibility_method_factory_.NewRunnableMethod( |
| 5405 &RenderView::SendPendingAccessibilityNotifications)); | 5421 &RenderView::SendPendingAccessibilityNotifications)); |
| 5406 } | 5422 } |
| 5407 } | 5423 } |
| 5408 | 5424 |
| 5409 void RenderView::Print(WebFrame* frame, | 5425 void RenderView::Print(WebFrame* frame, |
| 5410 bool script_initiated, | 5426 bool script_initiated, |
| 5411 bool is_preview) { | 5427 bool is_preview) { |
| 5412 DCHECK(frame); | 5428 DCHECK(frame); |
| 5413 if (print_helper_.get() == NULL) { | 5429 GetPrintWebViewHelper()->PrintFrame(frame, script_initiated, is_preview); |
| 5430 } |
| 5431 |
| 5432 PrintWebViewHelper* RenderView::GetPrintWebViewHelper() { |
| 5433 if (print_helper_.get() == NULL) |
| 5414 print_helper_.reset(new PrintWebViewHelper(this)); | 5434 print_helper_.reset(new PrintWebViewHelper(this)); |
| 5415 } | 5435 return print_helper_.get(); |
| 5416 print_helper_->Print(frame, script_initiated, is_preview); | |
| 5417 } | 5436 } |
| 5418 | 5437 |
| 5419 void RenderView::OnSetEditCommandsForNextKeyEvent( | 5438 void RenderView::OnSetEditCommandsForNextKeyEvent( |
| 5420 const EditCommands& edit_commands) { | 5439 const EditCommands& edit_commands) { |
| 5421 edit_commands_ = edit_commands; | 5440 edit_commands_ = edit_commands; |
| 5422 } | 5441 } |
| 5423 | 5442 |
| 5424 void RenderView::OnExecuteCode(const ViewMsg_ExecuteCode_Params& params) { | 5443 void RenderView::OnExecuteCode(const ViewMsg_ExecuteCode_Params& params) { |
| 5425 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 5444 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
| 5426 if (!main_frame) { | 5445 if (!main_frame) { |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5796 } | 5815 } |
| 5797 #endif | 5816 #endif |
| 5798 | 5817 |
| 5799 void RenderView::OnJavaScriptStressTestControl(int cmd, int param) { | 5818 void RenderView::OnJavaScriptStressTestControl(int cmd, int param) { |
| 5800 if (cmd == kJavaScriptStressTestSetStressRunType) { | 5819 if (cmd == kJavaScriptStressTestSetStressRunType) { |
| 5801 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); | 5820 v8::Testing::SetStressRunType(static_cast<v8::Testing::StressType>(param)); |
| 5802 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { | 5821 } else if (cmd == kJavaScriptStressTestPrepareStressRun) { |
| 5803 v8::Testing::PrepareStressRun(param); | 5822 v8::Testing::PrepareStressRun(param); |
| 5804 } | 5823 } |
| 5805 } | 5824 } |
| 5825 |
| 5826 void RenderView::OnContextMenuClosed() { |
| 5827 context_menu_node_.reset(); |
| 5828 } |
| OLD | NEW |