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, | 707 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
708 OnSetHistoryLengthAndClear) | 708 OnSetHistoryLengthAndPrune) |
709 | |
709 // Have the super handle all other messages. | 710 // Have the super handle all other messages. |
710 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 711 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
711 IPC_END_MESSAGE_MAP() | 712 IPC_END_MESSAGE_MAP() |
712 return handled; | 713 return handled; |
713 } | 714 } |
714 | 715 |
715 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 716 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
716 if (!webview()) | 717 if (!webview()) |
717 return; | 718 return; |
718 | 719 |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
986 | 987 |
987 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { | 988 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { |
988 if (!webview()) | 989 if (!webview()) |
989 return; | 990 return; |
990 | 991 |
991 handling_select_range_ = true; | 992 handling_select_range_ = true; |
992 webview()->focusedFrame()->selectRange(start, end); | 993 webview()->focusedFrame()->selectRange(start, end); |
993 handling_select_range_ = false; | 994 handling_select_range_ = false; |
994 } | 995 } |
995 | 996 |
997 void RenderView::OnSetHistoryLengthAndPrune(int history_length, | |
998 int32 minimum_page_id) { | |
999 DCHECK(history_length >= 0); | |
1000 DCHECK(minimum_page_id >= -1); | |
1001 | |
1002 // Generate the new list. | |
1003 std::vector<int32> new_history_page_ids(history_length, -1); | |
1004 for (size_t i = 0; i < history_page_ids_.size(); ++i) { | |
1005 DCHECK(history_page_ids_[i] >= 0); | |
Charlie Reis
2011/08/13 18:39:24
This isn't guaranteed, is it? history_page_ids_ c
cbentzel
2011/08/13 21:24:28
That's correct. In that case we will still want to
| |
1006 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) | |
1007 continue; | |
1008 new_history_page_ids.push_back(history_page_ids_[i]); | |
1009 } | |
1010 new_history_page_ids.swap(history_page_ids_); | |
1011 | |
1012 // Update indexes. | |
1013 history_list_length_ = history_page_ids_.size(); | |
1014 // TODO(cbentzel): What do we do if the history_list_offset_ was not at | |
1015 // the end of the list before? | |
Charlie Reis
2011/08/13 18:39:24
Can we be pointing to a page that we've pruned? W
cbentzel
2011/08/13 21:24:28
At this point, we can't. If the page was pruned it
| |
1016 history_list_offset_ = history_list_length_ - 1; | |
1017 } | |
1018 | |
1019 | |
996 void RenderView::OnSetInitialFocus(bool reverse) { | 1020 void RenderView::OnSetInitialFocus(bool reverse) { |
997 if (!webview()) | 1021 if (!webview()) |
998 return; | 1022 return; |
999 webview()->setInitialFocus(reverse); | 1023 webview()->setInitialFocus(reverse); |
1000 } | 1024 } |
1001 | 1025 |
1002 #if defined(OS_MACOSX) | 1026 #if defined(OS_MACOSX) |
1003 void RenderView::OnSetInLiveResize(bool in_live_resize) { | 1027 void RenderView::OnSetInLiveResize(bool in_live_resize) { |
1004 if (!webview()) | 1028 if (!webview()) |
1005 return; | 1029 return; |
1006 if (in_live_resize) | 1030 if (in_live_resize) |
1007 webview()->willStartLiveResize(); | 1031 webview()->willStartLiveResize(); |
1008 else | 1032 else |
1009 webview()->willEndLiveResize(); | 1033 webview()->willEndLiveResize(); |
1010 } | 1034 } |
1011 #endif | 1035 #endif |
1012 | 1036 |
1013 void RenderView::OnScrollFocusedEditableNodeIntoView() { | 1037 void RenderView::OnScrollFocusedEditableNodeIntoView() { |
1014 WebKit::WebNode node = GetFocusedNode(); | 1038 WebKit::WebNode node = GetFocusedNode(); |
1015 if (!node.isNull()) { | 1039 if (!node.isNull()) { |
1016 if (IsEditableNode(node)) | 1040 if (IsEditableNode(node)) |
1017 // TODO(varunjain): Change webkit API to scroll a particular node into | 1041 // TODO(varunjain): Change webkit API to scroll a particular node into |
1018 // view and use that API here instead. | 1042 // view and use that API here instead. |
1019 webview()->scrollFocusedNodeIntoView(); | 1043 webview()->scrollFocusedNodeIntoView(); |
1020 } | 1044 } |
1021 } | 1045 } |
1022 | 1046 |
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 | |
1049 /////////////////////////////////////////////////////////////////////////////// | 1047 /////////////////////////////////////////////////////////////////////////////// |
1050 | 1048 |
1051 // Tell the embedding application that the URL of the active page has changed | 1049 // Tell the embedding application that the URL of the active page has changed |
1052 void RenderView::UpdateURL(WebFrame* frame) { | 1050 void RenderView::UpdateURL(WebFrame* frame) { |
1053 WebDataSource* ds = frame->dataSource(); | 1051 WebDataSource* ds = frame->dataSource(); |
1054 DCHECK(ds); | 1052 DCHECK(ds); |
1055 | 1053 |
1056 const WebURLRequest& request = ds->request(); | 1054 const WebURLRequest& request = ds->request(); |
1057 const WebURLRequest& original_request = ds->originalRequest(); | 1055 const WebURLRequest& original_request = ds->originalRequest(); |
1058 const WebURLResponse& response = ds->response(); | 1056 const WebURLResponse& response = ds->response(); |
(...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4484 } | 4482 } |
4485 #endif | 4483 #endif |
4486 | 4484 |
4487 void RenderView::OnContextMenuClosed( | 4485 void RenderView::OnContextMenuClosed( |
4488 const webkit_glue::CustomContextMenuContext& custom_context) { | 4486 const webkit_glue::CustomContextMenuContext& custom_context) { |
4489 if (custom_context.is_pepper_menu) | 4487 if (custom_context.is_pepper_menu) |
4490 pepper_delegate_.OnContextMenuClosed(custom_context); | 4488 pepper_delegate_.OnContextMenuClosed(custom_context); |
4491 else | 4489 else |
4492 context_menu_node_.reset(); | 4490 context_menu_node_.reset(); |
4493 } | 4491 } |
OLD | NEW |