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 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
965 device_orientation_dispatcher_->OnMessageReceived(message)) { | 965 device_orientation_dispatcher_->OnMessageReceived(message)) { |
966 return true; | 966 return true; |
967 } | 967 } |
968 | 968 |
969 bool handled = true; | 969 bool handled = true; |
970 IPC_BEGIN_MESSAGE_MAP(RenderView, message) | 970 IPC_BEGIN_MESSAGE_MAP(RenderView, message) |
971 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) | 971 IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, OnCaptureThumbnail) |
972 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) | 972 IPC_MESSAGE_HANDLER(ViewMsg_CaptureSnapshot, OnCaptureSnapshot) |
973 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) | 973 IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages) |
974 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) | 974 IPC_MESSAGE_HANDLER(ViewMsg_PrintingDone, OnPrintingDone) |
| 975 IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview) |
| 976 IPC_MESSAGE_HANDLER(ViewMsg_PrintNodeUnderContextMenu, |
| 977 OnPrintNodeUnderContextMenu) |
975 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) | 978 IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate) |
976 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) | 979 IPC_MESSAGE_HANDLER(ViewMsg_Stop, OnStop) |
977 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) | 980 IPC_MESSAGE_HANDLER(ViewMsg_ReloadFrame, OnReloadFrame) |
978 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) | 981 IPC_MESSAGE_HANDLER(ViewMsg_Undo, OnUndo) |
979 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) | 982 IPC_MESSAGE_HANDLER(ViewMsg_Redo, OnRedo) |
980 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) | 983 IPC_MESSAGE_HANDLER(ViewMsg_Cut, OnCut) |
981 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) | 984 IPC_MESSAGE_HANDLER(ViewMsg_Copy, OnCopy) |
982 #if defined(OS_MACOSX) | 985 #if defined(OS_MACOSX) |
983 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) | 986 IPC_MESSAGE_HANDLER(ViewMsg_CopyToFindPboard, OnCopyToFindPboard) |
984 #endif | 987 #endif |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1093 OnAccessibilityDoDefaultAction) | 1096 OnAccessibilityDoDefaultAction) |
1094 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, | 1097 IPC_MESSAGE_HANDLER(ViewMsg_AccessibilityNotifications_ACK, |
1095 OnAccessibilityNotificationsAck) | 1098 OnAccessibilityNotificationsAck) |
1096 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) | 1099 IPC_MESSAGE_HANDLER(ViewMsg_AsyncOpenFile_ACK, OnAsyncFileOpened) |
1097 #if defined(ENABLE_FLAPPER_HACKS) | 1100 #if defined(ENABLE_FLAPPER_HACKS) |
1098 IPC_MESSAGE_HANDLER(ViewMsg_PepperConnectTcpACK, OnConnectTcpACK) | 1101 IPC_MESSAGE_HANDLER(ViewMsg_PepperConnectTcpACK, OnConnectTcpACK) |
1099 #endif | 1102 #endif |
1100 #if defined(OS_MACOSX) | 1103 #if defined(OS_MACOSX) |
1101 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1104 IPC_MESSAGE_HANDLER(ViewMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
1102 #endif | 1105 #endif |
1103 IPC_MESSAGE_HANDLER(ViewMsg_PrintPreview, OnPrintPreview) | 1106 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
1104 | 1107 |
1105 // Have the super handle all other messages. | 1108 // Have the super handle all other messages. |
1106 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 1109 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
1107 IPC_END_MESSAGE_MAP() | 1110 IPC_END_MESSAGE_MAP() |
1108 return handled; | 1111 return handled; |
1109 } | 1112 } |
1110 | 1113 |
1111 void RenderView::OnCaptureThumbnail() { | 1114 void RenderView::OnCaptureThumbnail() { |
1112 WebFrame* main_frame = webview()->mainFrame(); | 1115 WebFrame* main_frame = webview()->mainFrame(); |
1113 if (!main_frame) | 1116 if (!main_frame) |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 if (webview()) { | 1178 if (webview()) { |
1176 // If the user has selected text in the currently focused frame we print | 1179 // If the user has selected text in the currently focused frame we print |
1177 // only that frame (this makes print selection work for multiple frames). | 1180 // only that frame (this makes print selection work for multiple frames). |
1178 if (webview()->focusedFrame()->hasSelection()) | 1181 if (webview()->focusedFrame()->hasSelection()) |
1179 Print(webview()->focusedFrame(), false, true); | 1182 Print(webview()->focusedFrame(), false, true); |
1180 else | 1183 else |
1181 Print(webview()->focusedFrame(), false, true); | 1184 Print(webview()->focusedFrame(), false, true); |
1182 } | 1185 } |
1183 } | 1186 } |
1184 | 1187 |
| 1188 |
| 1189 void RenderView::OnPrintNodeUnderContextMenu() { |
| 1190 if (context_menu_node_.isNull()) { |
| 1191 NOTREACHED(); |
| 1192 return; |
| 1193 } |
| 1194 |
| 1195 GetPrintWebViewHelper()->Print(&context_menu_node_, false, false); |
| 1196 } |
| 1197 |
1185 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { | 1198 void RenderView::CapturePageInfo(int load_id, bool preliminary_capture) { |
1186 if (load_id != page_id_) | 1199 if (load_id != page_id_) |
1187 return; // this capture call is no longer relevant due to navigation | 1200 return; // this capture call is no longer relevant due to navigation |
1188 if (load_id == last_indexed_page_id_) | 1201 if (load_id == last_indexed_page_id_) |
1189 return; // we already indexed this page | 1202 return; // we already indexed this page |
1190 | 1203 |
1191 if (!webview()) | 1204 if (!webview()) |
1192 return; | 1205 return; |
1193 | 1206 |
1194 WebFrame* main_frame = webview()->mainFrame(); | 1207 WebFrame* main_frame = webview()->mainFrame(); |
(...skipping 1291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 if (spelled_right) | 2499 if (spelled_right) |
2487 params.misspelled_word.clear(); | 2500 params.misspelled_word.clear(); |
2488 } | 2501 } |
2489 // Serializing a GURL longer than chrome::kMaxURLChars will fail, so don't do | 2502 // Serializing a GURL longer than chrome::kMaxURLChars will fail, so don't do |
2490 // it. We replace it with an empty GURL so the appropriate items are disabled | 2503 // it. We replace it with an empty GURL so the appropriate items are disabled |
2491 // in the context menu. | 2504 // in the context menu. |
2492 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large | 2505 // TODO(jcivelli): http://crbug.com/45160 This prevents us from saving large |
2493 // data encoded images. We should have a way to save them. | 2506 // data encoded images. We should have a way to save them. |
2494 if (params.src_url.spec().size() > chrome::kMaxURLChars) | 2507 if (params.src_url.spec().size() > chrome::kMaxURLChars) |
2495 params.src_url = GURL(); | 2508 params.src_url = GURL(); |
| 2509 context_menu_node_ = data.node; |
2496 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); | 2510 Send(new ViewHostMsg_ContextMenu(routing_id_, params)); |
2497 } | 2511 } |
2498 | 2512 |
2499 bool RenderView::supportsFullscreen() { | 2513 bool RenderView::supportsFullscreen() { |
2500 return CommandLine::ForCurrentProcess()->HasSwitch( | 2514 return CommandLine::ForCurrentProcess()->HasSwitch( |
2501 switches::kEnableVideoFullscreen); | 2515 switches::kEnableVideoFullscreen); |
2502 } | 2516 } |
2503 | 2517 |
2504 void RenderView::enterFullscreenForNode(const WebKit::WebNode& node) { | 2518 void RenderView::enterFullscreenForNode(const WebKit::WebNode& node) { |
2505 NOTIMPLEMENTED(); | 2519 NOTIMPLEMENTED(); |
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5378 FROM_HERE, | 5392 FROM_HERE, |
5379 accessibility_method_factory_.NewRunnableMethod( | 5393 accessibility_method_factory_.NewRunnableMethod( |
5380 &RenderView::SendPendingAccessibilityNotifications)); | 5394 &RenderView::SendPendingAccessibilityNotifications)); |
5381 } | 5395 } |
5382 } | 5396 } |
5383 | 5397 |
5384 void RenderView::Print(WebFrame* frame, | 5398 void RenderView::Print(WebFrame* frame, |
5385 bool script_initiated, | 5399 bool script_initiated, |
5386 bool is_preview) { | 5400 bool is_preview) { |
5387 DCHECK(frame); | 5401 DCHECK(frame); |
5388 if (print_helper_.get() == NULL) { | 5402 GetPrintWebViewHelper()->Print(frame, script_initiated, is_preview); |
| 5403 } |
| 5404 |
| 5405 PrintWebViewHelper* RenderView::GetPrintWebViewHelper() { |
| 5406 if (print_helper_.get() == NULL) |
5389 print_helper_.reset(new PrintWebViewHelper(this)); | 5407 print_helper_.reset(new PrintWebViewHelper(this)); |
5390 } | 5408 return print_helper_.get(); |
5391 print_helper_->Print(frame, script_initiated, is_preview); | |
5392 } | 5409 } |
5393 | 5410 |
5394 void RenderView::OnSetEditCommandsForNextKeyEvent( | 5411 void RenderView::OnSetEditCommandsForNextKeyEvent( |
5395 const EditCommands& edit_commands) { | 5412 const EditCommands& edit_commands) { |
5396 edit_commands_ = edit_commands; | 5413 edit_commands_ = edit_commands; |
5397 } | 5414 } |
5398 | 5415 |
5399 void RenderView::OnExecuteCode(const ViewMsg_ExecuteCode_Params& params) { | 5416 void RenderView::OnExecuteCode(const ViewMsg_ExecuteCode_Params& params) { |
5400 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; | 5417 WebFrame* main_frame = webview() ? webview()->mainFrame() : NULL; |
5401 if (!main_frame) { | 5418 if (!main_frame) { |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5763 IPC::PlatformFileForTransit socket_for_transit, | 5780 IPC::PlatformFileForTransit socket_for_transit, |
5764 const PP_Flash_NetAddress& local_addr, | 5781 const PP_Flash_NetAddress& local_addr, |
5765 const PP_Flash_NetAddress& remote_addr) { | 5782 const PP_Flash_NetAddress& remote_addr) { |
5766 pepper_delegate_.OnConnectTcpACK( | 5783 pepper_delegate_.OnConnectTcpACK( |
5767 request_id, | 5784 request_id, |
5768 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), | 5785 IPC::PlatformFileForTransitToPlatformFile(socket_for_transit), |
5769 local_addr, | 5786 local_addr, |
5770 remote_addr); | 5787 remote_addr); |
5771 } | 5788 } |
5772 #endif | 5789 #endif |
| 5790 |
| 5791 void RenderView::OnContextMenuClosed() { |
| 5792 context_menu_node_.reset(); |
| 5793 } |
OLD | NEW |