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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 696 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
697 // TODO(viettrungluu): Move to a separate message filter. | 697 // TODO(viettrungluu): Move to a separate message filter. |
698 #if defined(ENABLE_FLAPPER_HACKS) | 698 #if defined(ENABLE_FLAPPER_HACKS) |
699 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 699 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
700 #endif | 700 #endif |
701 #if defined(OS_MACOSX) | 701 #if defined(OS_MACOSX) |
702 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 702 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
703 #endif | 703 #endif |
704 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, | 704 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, |
705 OnUpdateRemoteAccessClientFirewallTraversal) | 705 OnUpdateRemoteAccessClientFirewallTraversal) |
| 706 IPC_MESSAGE_HANDLER(ViewMsg_OffsetAndPruneHistory, |
| 707 OnOffsetAndPruneHistory) |
706 // Have the super handle all other messages. | 708 // Have the super handle all other messages. |
707 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 709 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
708 IPC_END_MESSAGE_MAP() | 710 IPC_END_MESSAGE_MAP() |
709 return handled; | 711 return handled; |
710 } | 712 } |
711 | 713 |
712 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 714 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
713 if (!webview()) | 715 if (!webview()) |
714 return; | 716 return; |
715 | 717 |
| 718 LOG(ERROR) << "OnNavigate." |
| 719 << " rv=" << this |
| 720 << " url=" << params.url.spec() |
| 721 << " history_list_offset_=" << history_list_offset_ |
| 722 << " history_list_length_=" << history_list_length_ |
| 723 << " params.current_history_list_offset=" |
| 724 << params.current_history_list_offset |
| 725 << " params.current_history_list_length=" |
| 726 << params.current_history_list_length; |
| 727 |
716 bool is_reload = | 728 bool is_reload = |
717 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || | 729 params.navigation_type == ViewMsg_Navigate_Type::RELOAD || |
718 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; | 730 params.navigation_type == ViewMsg_Navigate_Type::RELOAD_IGNORING_CACHE; |
719 | 731 |
720 // If this is a stale back/forward (due to a recent navigation the browser | 732 // If this is a stale back/forward (due to a recent navigation the browser |
721 // didn't know about), ignore it. | 733 // didn't know about), ignore it. |
722 if (IsBackForwardToStaleEntry(params, is_reload)) | 734 if (IsBackForwardToStaleEntry(params, is_reload)) |
723 return; | 735 return; |
724 | 736 |
725 // Swap this renderer back in if necessary. | 737 // Swap this renderer back in if necessary. |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
838 | 850 |
839 // Note: if the history_list_length_ is 0 for a back/forward, we must be | 851 // Note: if the history_list_length_ is 0 for a back/forward, we must be |
840 // restoring from a previous session. We'll update our state in OnNavigate. | 852 // restoring from a previous session. We'll update our state in OnNavigate. |
841 if (!is_back_forward || history_list_length_ <= 0) | 853 if (!is_back_forward || history_list_length_ <= 0) |
842 return false; | 854 return false; |
843 | 855 |
844 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); | 856 DCHECK_EQ(static_cast<int>(history_page_ids_.size()), history_list_length_); |
845 | 857 |
846 // Check for whether the forward history has been cropped due to a recent | 858 // Check for whether the forward history has been cropped due to a recent |
847 // navigation the browser didn't know about. | 859 // navigation the browser didn't know about. |
848 if (params.pending_history_list_offset >= history_list_length_) | 860 if (params.pending_history_list_offset >= history_list_length_) { |
| 861 LOG(ERROR) << "History Length is cropped." |
| 862 << " rv=" << this |
| 863 << " pending=" << params.pending_history_list_offset |
| 864 << " stored=" << history_list_length_; |
849 return true; | 865 return true; |
| 866 } |
850 | 867 |
851 // Check for whether this entry has been replaced with a new one. | 868 // Check for whether this entry has been replaced with a new one. |
852 int expected_page_id = | 869 int expected_page_id = |
853 history_page_ids_[params.pending_history_list_offset]; | 870 history_page_ids_[params.pending_history_list_offset]; |
854 if (expected_page_id > 0 && params.page_id != expected_page_id) | 871 if (expected_page_id > 0 && params.page_id != expected_page_id) { |
| 872 LOG(ERROR) << "Mismatched page id"; |
855 return true; | 873 return true; |
| 874 } |
856 | 875 |
857 return false; | 876 return false; |
858 } | 877 } |
859 | 878 |
860 // Stop loading the current page | 879 // Stop loading the current page |
861 void RenderView::OnStop() { | 880 void RenderView::OnStop() { |
862 if (webview()) { | 881 if (webview()) { |
863 WebFrame* main_frame = webview()->mainFrame(); | 882 WebFrame* main_frame = webview()->mainFrame(); |
864 // Stop the alt error page fetcher. If we let it continue it may complete | 883 // Stop the alt error page fetcher. If we let it continue it may complete |
865 // and cause RenderViewHostManager to swap to this RenderView, even though | 884 // and cause RenderViewHostManager to swap to this RenderView, even though |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1010 void RenderView::OnScrollFocusedEditableNodeIntoView() { | 1029 void RenderView::OnScrollFocusedEditableNodeIntoView() { |
1011 WebKit::WebNode node = GetFocusedNode(); | 1030 WebKit::WebNode node = GetFocusedNode(); |
1012 if (!node.isNull()) { | 1031 if (!node.isNull()) { |
1013 if (IsEditableNode(node)) | 1032 if (IsEditableNode(node)) |
1014 // TODO(varunjain): Change webkit API to scroll a particular node into | 1033 // TODO(varunjain): Change webkit API to scroll a particular node into |
1015 // view and use that API here instead. | 1034 // view and use that API here instead. |
1016 webview()->scrollFocusedNodeIntoView(); | 1035 webview()->scrollFocusedNodeIntoView(); |
1017 } | 1036 } |
1018 } | 1037 } |
1019 | 1038 |
| 1039 void RenderView::OnOffsetAndPruneHistory(int offset) { |
| 1040 LOG(ERROR) << "OnOffsetAndPruneHistory." |
| 1041 << " offset=" << offset; |
| 1042 int current_page_id = -1; |
| 1043 if (history_list_offset_ >= 0) { |
| 1044 current_page_id = history_page_ids_[history_list_offset_]; |
| 1045 } |
| 1046 |
| 1047 // We may have multiple things in the list? Or just one? |
| 1048 history_list_offset_ = offset; |
| 1049 history_list_length_ = offset + 1; |
| 1050 if (history_list_length_ >= 0) |
| 1051 history_page_ids_.resize(history_list_length_, -1); |
| 1052 history_page_ids_[history_list_offset_] = current_page_id; |
| 1053 } |
| 1054 |
1020 /////////////////////////////////////////////////////////////////////////////// | 1055 /////////////////////////////////////////////////////////////////////////////// |
1021 | 1056 |
1022 // Tell the embedding application that the URL of the active page has changed | 1057 // Tell the embedding application that the URL of the active page has changed |
1023 void RenderView::UpdateURL(WebFrame* frame) { | 1058 void RenderView::UpdateURL(WebFrame* frame) { |
1024 WebDataSource* ds = frame->dataSource(); | 1059 WebDataSource* ds = frame->dataSource(); |
1025 DCHECK(ds); | 1060 DCHECK(ds); |
1026 | 1061 |
1027 const WebURLRequest& request = ds->request(); | 1062 const WebURLRequest& request = ds->request(); |
1028 const WebURLRequest& original_request = ds->originalRequest(); | 1063 const WebURLRequest& original_request = ds->originalRequest(); |
1029 const WebURLResponse& response = ds->response(); | 1064 const WebURLResponse& response = ds->response(); |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1223 // we are navigating away from. Otherwise, this is the first navigation, so | 1258 // we are navigating away from. Otherwise, this is the first navigation, so |
1224 // there is no past session history to record. | 1259 // there is no past session history to record. |
1225 if (page_id_ == -1) | 1260 if (page_id_ == -1) |
1226 return; | 1261 return; |
1227 | 1262 |
1228 const WebHistoryItem& item = | 1263 const WebHistoryItem& item = |
1229 webview()->mainFrame()->previousHistoryItem(); | 1264 webview()->mainFrame()->previousHistoryItem(); |
1230 if (item.isNull()) | 1265 if (item.isNull()) |
1231 return; | 1266 return; |
1232 | 1267 |
| 1268 LOG(ERROR) << "Updating session history." |
| 1269 << " rv=" << this |
| 1270 << " page_id_=" << page_id_; |
1233 Send(new ViewHostMsg_UpdateState( | 1271 Send(new ViewHostMsg_UpdateState( |
1234 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); | 1272 routing_id_, page_id_, webkit_glue::HistoryItemToString(item))); |
1235 } | 1273 } |
1236 | 1274 |
1237 void RenderView::OpenURL( | 1275 void RenderView::OpenURL( |
1238 const GURL& url, const GURL& referrer, WebNavigationPolicy policy) { | 1276 const GURL& url, const GURL& referrer, WebNavigationPolicy policy) { |
1239 Send(new ViewHostMsg_OpenURL( | 1277 Send(new ViewHostMsg_OpenURL( |
1240 routing_id_, url, referrer, NavigationPolicyToDisposition(policy))); | 1278 routing_id_, url, referrer, NavigationPolicyToDisposition(policy))); |
1241 } | 1279 } |
1242 | 1280 |
(...skipping 1243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2486 | 2524 |
2487 // We bump our Page ID to correspond with the new session history entry. | 2525 // We bump our Page ID to correspond with the new session history entry. |
2488 page_id_ = next_page_id_++; | 2526 page_id_ = next_page_id_++; |
2489 | 2527 |
2490 // Advance our offset in session history, applying the length limit. There | 2528 // Advance our offset in session history, applying the length limit. There |
2491 // is now no forward history. | 2529 // is now no forward history. |
2492 history_list_offset_++; | 2530 history_list_offset_++; |
2493 if (history_list_offset_ >= content::kMaxSessionHistoryEntries) | 2531 if (history_list_offset_ >= content::kMaxSessionHistoryEntries) |
2494 history_list_offset_ = content::kMaxSessionHistoryEntries - 1; | 2532 history_list_offset_ = content::kMaxSessionHistoryEntries - 1; |
2495 history_list_length_ = history_list_offset_ + 1; | 2533 history_list_length_ = history_list_offset_ + 1; |
| 2534 LOG(ERROR) << "didCommitProvisionalLoad." |
| 2535 << " rv=" << this |
| 2536 << " page_id_" << page_id_ |
| 2537 << " history_list_length_=" << history_list_length_; |
2496 history_page_ids_.resize(history_list_length_, -1); | 2538 history_page_ids_.resize(history_list_length_, -1); |
2497 history_page_ids_[history_list_offset_] = page_id_; | 2539 history_page_ids_[history_list_offset_] = page_id_; |
2498 } else { | 2540 } else { |
2499 // Inspect the navigation_state on this frame to see if the navigation | 2541 // Inspect the navigation_state on this frame to see if the navigation |
2500 // corresponds to a session history navigation... Note: |frame| may or | 2542 // corresponds to a session history navigation... Note: |frame| may or |
2501 // may not be the toplevel frame, but for the case of capturing session | 2543 // may not be the toplevel frame, but for the case of capturing session |
2502 // history, the first committed frame suffices. We keep track of whether | 2544 // history, the first committed frame suffices. We keep track of whether |
2503 // we've seen this commit before so that only capture session history once | 2545 // we've seen this commit before so that only capture session history once |
2504 // per navigation. | 2546 // per navigation. |
2505 // | 2547 // |
(...skipping 1956 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4462 } | 4504 } |
4463 #endif | 4505 #endif |
4464 | 4506 |
4465 void RenderView::OnContextMenuClosed( | 4507 void RenderView::OnContextMenuClosed( |
4466 const webkit_glue::CustomContextMenuContext& custom_context) { | 4508 const webkit_glue::CustomContextMenuContext& custom_context) { |
4467 if (custom_context.is_pepper_menu) | 4509 if (custom_context.is_pepper_menu) |
4468 pepper_delegate_.OnContextMenuClosed(custom_context); | 4510 pepper_delegate_.OnContextMenuClosed(custom_context); |
4469 else | 4511 else |
4470 context_menu_node_.reset(); | 4512 context_menu_node_.reset(); |
4471 } | 4513 } |
OLD | NEW |