| 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 "content/renderer/render_view.h" | 5 #include "content/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 681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 692 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 692 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 693 // TODO(viettrungluu): Move to a separate message filter. | 693 // TODO(viettrungluu): Move to a separate message filter. |
| 694 #if defined(ENABLE_FLAPPER_HACKS) | 694 #if defined(ENABLE_FLAPPER_HACKS) |
| 695 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 695 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 696 #endif | 696 #endif |
| 697 #if defined(OS_MACOSX) | 697 #if defined(OS_MACOSX) |
| 698 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 698 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 699 #endif | 699 #endif |
| 700 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, | 700 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, |
| 701 OnUpdateRemoteAccessClientFirewallTraversal) | 701 OnUpdateRemoteAccessClientFirewallTraversal) |
| 702 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndClear, | 702 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 703 OnSetHistoryLengthAndClear) | 703 OnSetHistoryLengthAndPrune) |
| 704 |
| 704 // Have the super handle all other messages. | 705 // Have the super handle all other messages. |
| 705 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 706 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 706 IPC_END_MESSAGE_MAP() | 707 IPC_END_MESSAGE_MAP() |
| 707 return handled; | 708 return handled; |
| 708 } | 709 } |
| 709 | 710 |
| 710 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 711 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 711 if (!webview()) | 712 if (!webview()) |
| 712 return; | 713 return; |
| 713 | 714 |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 972 } | 973 } |
| 973 | 974 |
| 974 void RenderView::OnSelectAll() { | 975 void RenderView::OnSelectAll() { |
| 975 if (!webview()) | 976 if (!webview()) |
| 976 return; | 977 return; |
| 977 | 978 |
| 978 webview()->focusedFrame()->executeCommand( | 979 webview()->focusedFrame()->executeCommand( |
| 979 WebString::fromUTF8("SelectAll")); | 980 WebString::fromUTF8("SelectAll")); |
| 980 } | 981 } |
| 981 | 982 |
| 983 void RenderView::OnSetHistoryLengthAndPrune(int history_length, |
| 984 int32 minimum_page_id) { |
| 985 DCHECK(history_length >= 0); |
| 986 DCHECK(history_list_offset_ == history_list_length_ - 1); |
| 987 DCHECK(minimum_page_id >= -1); |
| 988 |
| 989 // Generate the new list. |
| 990 std::vector<int32> new_history_page_ids(history_length, -1); |
| 991 for (size_t i = 0; i < history_page_ids_.size(); ++i) { |
| 992 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) |
| 993 continue; |
| 994 new_history_page_ids.push_back(history_page_ids_[i]); |
| 995 } |
| 996 new_history_page_ids.swap(history_page_ids_); |
| 997 |
| 998 // Update indexes. |
| 999 history_list_length_ = history_page_ids_.size(); |
| 1000 history_list_offset_ = history_list_length_ - 1; |
| 1001 } |
| 1002 |
| 1003 |
| 982 void RenderView::OnSetInitialFocus(bool reverse) { | 1004 void RenderView::OnSetInitialFocus(bool reverse) { |
| 983 if (!webview()) | 1005 if (!webview()) |
| 984 return; | 1006 return; |
| 985 webview()->setInitialFocus(reverse); | 1007 webview()->setInitialFocus(reverse); |
| 986 } | 1008 } |
| 987 | 1009 |
| 988 #if defined(OS_MACOSX) | 1010 #if defined(OS_MACOSX) |
| 989 void RenderView::OnSetInLiveResize(bool in_live_resize) { | 1011 void RenderView::OnSetInLiveResize(bool in_live_resize) { |
| 990 if (!webview()) | 1012 if (!webview()) |
| 991 return; | 1013 return; |
| 992 if (in_live_resize) | 1014 if (in_live_resize) |
| 993 webview()->willStartLiveResize(); | 1015 webview()->willStartLiveResize(); |
| 994 else | 1016 else |
| 995 webview()->willEndLiveResize(); | 1017 webview()->willEndLiveResize(); |
| 996 } | 1018 } |
| 997 #endif | 1019 #endif |
| 998 | 1020 |
| 999 void RenderView::OnScrollFocusedEditableNodeIntoView() { | 1021 void RenderView::OnScrollFocusedEditableNodeIntoView() { |
| 1000 WebKit::WebNode node = GetFocusedNode(); | 1022 WebKit::WebNode node = GetFocusedNode(); |
| 1001 if (!node.isNull()) { | 1023 if (!node.isNull()) { |
| 1002 if (IsEditableNode(node)) | 1024 if (IsEditableNode(node)) |
| 1003 // TODO(varunjain): Change webkit API to scroll a particular node into | 1025 // TODO(varunjain): Change webkit API to scroll a particular node into |
| 1004 // view and use that API here instead. | 1026 // view and use that API here instead. |
| 1005 webview()->scrollFocusedNodeIntoView(); | 1027 webview()->scrollFocusedNodeIntoView(); |
| 1006 } | 1028 } |
| 1007 } | 1029 } |
| 1008 | 1030 |
| 1009 void RenderView::OnSetHistoryLengthAndClear(int history_length) { | |
| 1010 DCHECK(history_length >= 0); | |
| 1011 | |
| 1012 // history_list_length_ may be 0 if this is called between | |
| 1013 // a navigate and a commit of the provisional load. Otherwise, | |
| 1014 // only add one entry, regardless of how long the current history is. | |
| 1015 // TODO(cbentzel): Investigate what happens if a prerendered page | |
| 1016 // navigates to several entries before it is swapped in. Cropping | |
| 1017 // those may be a bad idea. | |
| 1018 int new_history_list_length = history_length; | |
| 1019 if (history_list_length_ > 0) | |
| 1020 ++new_history_list_length; | |
| 1021 | |
| 1022 DCHECK(page_id_ == -1 || | |
| 1023 (history_list_offset_ >= 0 && | |
| 1024 page_id_ == history_page_ids_[history_list_offset_])); | |
| 1025 | |
| 1026 // Generate the new list. | |
| 1027 std::vector<int32> new_history_page_ids(new_history_list_length, -1); | |
| 1028 if (page_id_ != -1) | |
| 1029 new_history_page_ids[new_history_list_length - 1] = page_id_; | |
| 1030 new_history_page_ids.swap(history_page_ids_); | |
| 1031 history_list_offset_ = new_history_list_length - 1; | |
| 1032 history_list_length_ = new_history_list_length; | |
| 1033 } | |
| 1034 | |
| 1035 /////////////////////////////////////////////////////////////////////////////// | 1031 /////////////////////////////////////////////////////////////////////////////// |
| 1036 | 1032 |
| 1037 // Tell the embedding application that the URL of the active page has changed | 1033 // Tell the embedding application that the URL of the active page has changed |
| 1038 void RenderView::UpdateURL(WebFrame* frame) { | 1034 void RenderView::UpdateURL(WebFrame* frame) { |
| 1039 WebDataSource* ds = frame->dataSource(); | 1035 WebDataSource* ds = frame->dataSource(); |
| 1040 DCHECK(ds); | 1036 DCHECK(ds); |
| 1041 | 1037 |
| 1042 const WebURLRequest& request = ds->request(); | 1038 const WebURLRequest& request = ds->request(); |
| 1043 const WebURLRequest& original_request = ds->originalRequest(); | 1039 const WebURLRequest& original_request = ds->originalRequest(); |
| 1044 const WebURLResponse& response = ds->response(); | 1040 const WebURLResponse& response = ds->response(); |
| (...skipping 3382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4427 } | 4423 } |
| 4428 #endif | 4424 #endif |
| 4429 | 4425 |
| 4430 void RenderView::OnContextMenuClosed( | 4426 void RenderView::OnContextMenuClosed( |
| 4431 const webkit_glue::CustomContextMenuContext& custom_context) { | 4427 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4432 if (custom_context.is_pepper_menu) | 4428 if (custom_context.is_pepper_menu) |
| 4433 pepper_delegate_.OnContextMenuClosed(custom_context); | 4429 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4434 else | 4430 else |
| 4435 context_menu_node_.reset(); | 4431 context_menu_node_.reset(); |
| 4436 } | 4432 } |
| OLD | NEW |