| 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 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 697 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 698 // TODO(viettrungluu): Move to a separate message filter. | 698 // TODO(viettrungluu): Move to a separate message filter. |
| 699 #if defined(ENABLE_FLAPPER_HACKS) | 699 #if defined(ENABLE_FLAPPER_HACKS) |
| 700 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 700 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 701 #endif | 701 #endif |
| 702 #if defined(OS_MACOSX) | 702 #if defined(OS_MACOSX) |
| 703 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 703 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 704 #endif | 704 #endif |
| 705 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, | 705 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, |
| 706 OnUpdateRemoteAccessClientFirewallTraversal) | 706 OnUpdateRemoteAccessClientFirewallTraversal) |
| 707 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndClear, |
| 708 OnSetHistoryLengthAndClear) |
| 707 // Have the super handle all other messages. | 709 // Have the super handle all other messages. |
| 708 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 710 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 709 IPC_END_MESSAGE_MAP() | 711 IPC_END_MESSAGE_MAP() |
| 710 return handled; | 712 return handled; |
| 711 } | 713 } |
| 712 | 714 |
| 713 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 715 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 714 if (!webview()) | 716 if (!webview()) |
| 715 return; | 717 return; |
| 716 | 718 |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1011 void RenderView::OnScrollFocusedEditableNodeIntoView() { | 1013 void RenderView::OnScrollFocusedEditableNodeIntoView() { |
| 1012 WebKit::WebNode node = GetFocusedNode(); | 1014 WebKit::WebNode node = GetFocusedNode(); |
| 1013 if (!node.isNull()) { | 1015 if (!node.isNull()) { |
| 1014 if (IsEditableNode(node)) | 1016 if (IsEditableNode(node)) |
| 1015 // TODO(varunjain): Change webkit API to scroll a particular node into | 1017 // TODO(varunjain): Change webkit API to scroll a particular node into |
| 1016 // view and use that API here instead. | 1018 // view and use that API here instead. |
| 1017 webview()->scrollFocusedNodeIntoView(); | 1019 webview()->scrollFocusedNodeIntoView(); |
| 1018 } | 1020 } |
| 1019 } | 1021 } |
| 1020 | 1022 |
| 1023 void RenderView::OnSetHistoryLengthAndClear(int history_length) { |
| 1024 DCHECK(history_length >= 0); |
| 1025 |
| 1026 // history_list_length_ may be 0 if this is called between |
| 1027 // a navigate and a commit of the provisional load. Otherwise, |
| 1028 // only add one entry, regardless of how long the current history is. |
| 1029 // TODO(cbentzel): Investigate what happens if a prerendered page |
| 1030 // navigates to several entries before it is swapped in. Cropping |
| 1031 // those may be a bad idea. |
| 1032 int new_history_list_length = history_length; |
| 1033 if (history_list_length_ > 0) |
| 1034 ++new_history_list_length; |
| 1035 |
| 1036 DCHECK(page_id_ == -1 || |
| 1037 (history_list_offset_ >= 0 && |
| 1038 page_id_ == history_page_ids_[history_list_offset_])); |
| 1039 |
| 1040 // Generate the new list. |
| 1041 std::vector<int32> new_history_page_ids(new_history_list_length, -1); |
| 1042 if (page_id_ != -1) |
| 1043 new_history_page_ids[new_history_list_length - 1] = page_id_; |
| 1044 new_history_page_ids.swap(history_page_ids_); |
| 1045 history_list_offset_ = new_history_list_length - 1; |
| 1046 history_list_length_ = new_history_list_length; |
| 1047 } |
| 1048 |
| 1021 /////////////////////////////////////////////////////////////////////////////// | 1049 /////////////////////////////////////////////////////////////////////////////// |
| 1022 | 1050 |
| 1023 // Tell the embedding application that the URL of the active page has changed | 1051 // Tell the embedding application that the URL of the active page has changed |
| 1024 void RenderView::UpdateURL(WebFrame* frame) { | 1052 void RenderView::UpdateURL(WebFrame* frame) { |
| 1025 WebDataSource* ds = frame->dataSource(); | 1053 WebDataSource* ds = frame->dataSource(); |
| 1026 DCHECK(ds); | 1054 DCHECK(ds); |
| 1027 | 1055 |
| 1028 const WebURLRequest& request = ds->request(); | 1056 const WebURLRequest& request = ds->request(); |
| 1029 const WebURLRequest& original_request = ds->originalRequest(); | 1057 const WebURLRequest& original_request = ds->originalRequest(); |
| 1030 const WebURLResponse& response = ds->response(); | 1058 const WebURLResponse& response = ds->response(); |
| (...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4456 } | 4484 } |
| 4457 #endif | 4485 #endif |
| 4458 | 4486 |
| 4459 void RenderView::OnContextMenuClosed( | 4487 void RenderView::OnContextMenuClosed( |
| 4460 const webkit_glue::CustomContextMenuContext& custom_context) { | 4488 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4461 if (custom_context.is_pepper_menu) | 4489 if (custom_context.is_pepper_menu) |
| 4462 pepper_delegate_.OnContextMenuClosed(custom_context); | 4490 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4463 else | 4491 else |
| 4464 context_menu_node_.reset(); | 4492 context_menu_node_.reset(); |
| 4465 } | 4493 } |
| OLD | NEW |