Chromium Code Reviews| 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 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 421 if (command_line.HasSwitch(switches::kEnableMediaStream)) { | 421 if (command_line.HasSwitch(switches::kEnableMediaStream)) { |
| 422 media_stream_impl_ = new MediaStreamImpl( | 422 media_stream_impl_ = new MediaStreamImpl( |
| 423 RenderThread::current()->video_capture_impl_manager()); | 423 RenderThread::current()->video_capture_impl_manager()); |
| 424 } | 424 } |
| 425 | 425 |
| 426 content::GetContentClient()->renderer()->RenderViewCreated(this); | 426 content::GetContentClient()->renderer()->RenderViewCreated(this); |
| 427 } | 427 } |
| 428 | 428 |
| 429 RenderView::~RenderView() { | 429 RenderView::~RenderView() { |
| 430 history_page_ids_.clear(); | 430 history_page_ids_.clear(); |
| 431 | |
| 432 if (decrement_shared_popup_at_destruction_) | 431 if (decrement_shared_popup_at_destruction_) |
| 433 shared_popup_counter_->data--; | 432 shared_popup_counter_->data--; |
| 434 | |
|
Charlie Reis
2011/08/13 00:29:04
Any reason to remove these lines? Those blocks do
cbentzel
2011/08/13 02:19:12
Unrelated, sorry for not catching myself.
| |
| 435 // If file chooser is still waiting for answer, dispatch empty answer. | 433 // If file chooser is still waiting for answer, dispatch empty answer. |
| 436 while (!file_chooser_completions_.empty()) { | 434 while (!file_chooser_completions_.empty()) { |
| 437 if (file_chooser_completions_.front()->completion) { | 435 if (file_chooser_completions_.front()->completion) { |
| 438 file_chooser_completions_.front()->completion->didChooseFile( | 436 file_chooser_completions_.front()->completion->didChooseFile( |
| 439 WebVector<WebString>()); | 437 WebVector<WebString>()); |
| 440 } | 438 } |
| 441 file_chooser_completions_.pop_front(); | 439 file_chooser_completions_.pop_front(); |
| 442 } | 440 } |
| 443 | 441 |
| 444 #if defined(OS_MACOSX) | 442 #if defined(OS_MACOSX) |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 697 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) | 695 IPC_MESSAGE_HANDLER(ViewMsg_ContextMenuClosed, OnContextMenuClosed) |
| 698 // TODO(viettrungluu): Move to a separate message filter. | 696 // TODO(viettrungluu): Move to a separate message filter. |
| 699 #if defined(ENABLE_FLAPPER_HACKS) | 697 #if defined(ENABLE_FLAPPER_HACKS) |
| 700 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) | 698 IPC_MESSAGE_HANDLER(PepperMsg_ConnectTcpACK, OnConnectTcpACK) |
| 701 #endif | 699 #endif |
| 702 #if defined(OS_MACOSX) | 700 #if defined(OS_MACOSX) |
| 703 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 701 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
| 704 #endif | 702 #endif |
| 705 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, | 703 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRemoteAccessClientFirewallTraversal, |
| 706 OnUpdateRemoteAccessClientFirewallTraversal) | 704 OnUpdateRemoteAccessClientFirewallTraversal) |
| 707 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndClear, | 705 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
| 708 OnSetHistoryLengthAndClear) | 706 OnSetHistoryLengthAndPrune) |
| 709 // Have the super handle all other messages. | 707 // Have the super handle all other messages. |
| 710 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 708 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
| 711 IPC_END_MESSAGE_MAP() | 709 IPC_END_MESSAGE_MAP() |
| 712 return handled; | 710 return handled; |
| 713 } | 711 } |
| 714 | 712 |
| 715 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { | 713 void RenderView::OnNavigate(const ViewMsg_Navigate_Params& params) { |
| 716 if (!webview()) | 714 if (!webview()) |
| 717 return; | 715 return; |
| 718 | 716 |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 986 | 984 |
| 987 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { | 985 void RenderView::OnSelectRange(const gfx::Point& start, const gfx::Point& end) { |
| 988 if (!webview()) | 986 if (!webview()) |
| 989 return; | 987 return; |
| 990 | 988 |
| 991 handling_select_range_ = true; | 989 handling_select_range_ = true; |
| 992 webview()->focusedFrame()->selectRange(start, end); | 990 webview()->focusedFrame()->selectRange(start, end); |
| 993 handling_select_range_ = false; | 991 handling_select_range_ = false; |
| 994 } | 992 } |
| 995 | 993 |
| 994 void RenderView::OnSetHistoryLengthAndPrune(int history_length, | |
| 995 int32 minimum_page_id) { | |
| 996 DCHECK(history_length >= 0); | |
| 997 DCHECK(minimum_page_id >= -1); | |
| 998 | |
| 999 // Generate the new list. | |
| 1000 std::vector<int32> new_history_page_ids(history_length, -1); | |
| 1001 for (size_t i = 0; i < history_page_ids_.size(); ++i) { | |
| 1002 DCHECK(history_page_ids_[i] >= 0); | |
| 1003 if (minimum_page_id >= 0 && history_page_ids_[i] < minimum_page_id) | |
| 1004 continue; | |
| 1005 new_history_page_ids.push_back(history_page_ids_[i]); | |
| 1006 } | |
| 1007 new_history_page_ids.swap(history_page_ids_); | |
| 1008 | |
| 1009 // Update indexes. | |
| 1010 history_list_length_ = history_page_ids_.size(); | |
| 1011 // TODO(cbentzel): What do we do if the history_list_offset_ was not at | |
| 1012 // the end of the list before? | |
| 1013 history_list_offset_ = history_list_length_ - 1; | |
| 1014 } | |
| 1015 | |
| 1016 | |
| 996 void RenderView::OnSetInitialFocus(bool reverse) { | 1017 void RenderView::OnSetInitialFocus(bool reverse) { |
| 997 if (!webview()) | 1018 if (!webview()) |
| 998 return; | 1019 return; |
| 999 webview()->setInitialFocus(reverse); | 1020 webview()->setInitialFocus(reverse); |
| 1000 } | 1021 } |
| 1001 | 1022 |
| 1002 #if defined(OS_MACOSX) | 1023 #if defined(OS_MACOSX) |
| 1003 void RenderView::OnSetInLiveResize(bool in_live_resize) { | 1024 void RenderView::OnSetInLiveResize(bool in_live_resize) { |
| 1004 if (!webview()) | 1025 if (!webview()) |
| 1005 return; | 1026 return; |
| 1006 if (in_live_resize) | 1027 if (in_live_resize) |
| 1007 webview()->willStartLiveResize(); | 1028 webview()->willStartLiveResize(); |
| 1008 else | 1029 else |
| 1009 webview()->willEndLiveResize(); | 1030 webview()->willEndLiveResize(); |
| 1010 } | 1031 } |
| 1011 #endif | 1032 #endif |
| 1012 | 1033 |
| 1013 void RenderView::OnScrollFocusedEditableNodeIntoView() { | 1034 void RenderView::OnScrollFocusedEditableNodeIntoView() { |
| 1014 WebKit::WebNode node = GetFocusedNode(); | 1035 WebKit::WebNode node = GetFocusedNode(); |
| 1015 if (!node.isNull()) { | 1036 if (!node.isNull()) { |
| 1016 if (IsEditableNode(node)) | 1037 if (IsEditableNode(node)) |
| 1017 // TODO(varunjain): Change webkit API to scroll a particular node into | 1038 // TODO(varunjain): Change webkit API to scroll a particular node into |
| 1018 // view and use that API here instead. | 1039 // view and use that API here instead. |
| 1019 webview()->scrollFocusedNodeIntoView(); | 1040 webview()->scrollFocusedNodeIntoView(); |
| 1020 } | 1041 } |
| 1021 } | 1042 } |
| 1022 | 1043 |
| 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 /////////////////////////////////////////////////////////////////////////////// | 1044 /////////////////////////////////////////////////////////////////////////////// |
| 1050 | 1045 |
| 1051 // Tell the embedding application that the URL of the active page has changed | 1046 // Tell the embedding application that the URL of the active page has changed |
| 1052 void RenderView::UpdateURL(WebFrame* frame) { | 1047 void RenderView::UpdateURL(WebFrame* frame) { |
| 1053 WebDataSource* ds = frame->dataSource(); | 1048 WebDataSource* ds = frame->dataSource(); |
| 1054 DCHECK(ds); | 1049 DCHECK(ds); |
| 1055 | 1050 |
| 1056 const WebURLRequest& request = ds->request(); | 1051 const WebURLRequest& request = ds->request(); |
| 1057 const WebURLRequest& original_request = ds->originalRequest(); | 1052 const WebURLRequest& original_request = ds->originalRequest(); |
| 1058 const WebURLResponse& response = ds->response(); | 1053 const WebURLResponse& response = ds->response(); |
| (...skipping 3425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4484 } | 4479 } |
| 4485 #endif | 4480 #endif |
| 4486 | 4481 |
| 4487 void RenderView::OnContextMenuClosed( | 4482 void RenderView::OnContextMenuClosed( |
| 4488 const webkit_glue::CustomContextMenuContext& custom_context) { | 4483 const webkit_glue::CustomContextMenuContext& custom_context) { |
| 4489 if (custom_context.is_pepper_menu) | 4484 if (custom_context.is_pepper_menu) |
| 4490 pepper_delegate_.OnContextMenuClosed(custom_context); | 4485 pepper_delegate_.OnContextMenuClosed(custom_context); |
| 4491 else | 4486 else |
| 4492 context_menu_node_.reset(); | 4487 context_menu_node_.reset(); |
| 4493 } | 4488 } |
| OLD | NEW |