| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/renderer/render_view.h" | 5 #include "chrome/renderer/render_view.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 135 int32 pending_page_id_; | 135 int32 pending_page_id_; |
| 136 | 136 |
| 137 DISALLOW_EVIL_CONSTRUCTORS(RenderViewExtraRequestData); | 137 DISALLOW_EVIL_CONSTRUCTORS(RenderViewExtraRequestData); |
| 138 }; | 138 }; |
| 139 | 139 |
| 140 } // namespace | 140 } // namespace |
| 141 | 141 |
| 142 /////////////////////////////////////////////////////////////////////////////// | 142 /////////////////////////////////////////////////////////////////////////////// |
| 143 | 143 |
| 144 RenderView::RenderView() | 144 RenderView::RenderView() |
| 145 : RenderWidget(RenderThread::current()), | 145 : RenderWidget(RenderThread::current(), true), |
| 146 is_loading_(false), | 146 is_loading_(false), |
| 147 page_id_(-1), | 147 page_id_(-1), |
| 148 last_page_id_sent_to_browser_(-1), | 148 last_page_id_sent_to_browser_(-1), |
| 149 last_indexed_page_id_(-1), | 149 last_indexed_page_id_(-1), |
| 150 method_factory_(this), | 150 method_factory_(this), |
| 151 opened_by_user_gesture_(true), | 151 opened_by_user_gesture_(true), |
| 152 enable_dom_automation_(false), | 152 enable_dom_automation_(false), |
| 153 enable_dom_ui_bindings_(false), | 153 enable_dom_ui_bindings_(false), |
| 154 target_url_status_(TARGET_NONE), | 154 target_url_status_(TARGET_NONE), |
| 155 printed_document_width_(0), | 155 printed_document_width_(0), |
| 156 first_default_plugin_(NULL), | 156 first_default_plugin_(NULL), |
| 157 navigation_gesture_(NavigationGestureUnknown), | 157 navigation_gesture_(NavigationGestureUnknown), |
| 158 history_back_list_count_(0), | 158 history_back_list_count_(0), |
| 159 history_forward_list_count_(0), | 159 history_forward_list_count_(0), |
| 160 disable_popup_blocking_(false), | 160 disable_popup_blocking_(false), |
| 161 has_unload_listener_(false), | 161 has_unload_listener_(false), |
| 162 decrement_shared_popup_at_destruction_(false), | 162 decrement_shared_popup_at_destruction_(false), |
| 163 greasemonkey_enabled_(false), | 163 greasemonkey_enabled_(false), |
| 164 waiting_for_create_window_ack_(false) { | 164 waiting_for_create_window_ack_(false), |
| 165 form_field_autofill_request_id_(0) { |
| 165 resource_dispatcher_ = new ResourceDispatcher(this); | 166 resource_dispatcher_ = new ResourceDispatcher(this); |
| 166 #ifdef CHROME_PERSONALIZATION | 167 #ifdef CHROME_PERSONALIZATION |
| 167 personalization_ = Personalization::CreateRendererPersonalization(); | 168 personalization_ = Personalization::CreateRendererPersonalization(); |
| 168 #endif | 169 #endif |
| 169 } | 170 } |
| 170 | 171 |
| 171 RenderView::~RenderView() { | 172 RenderView::~RenderView() { |
| 172 if (decrement_shared_popup_at_destruction_) | 173 if (decrement_shared_popup_at_destruction_) |
| 173 shared_popup_counter_->data--; | 174 shared_popup_counter_->data--; |
| 174 | 175 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnMsgShouldClose) | 378 IPC_MESSAGE_HANDLER(ViewMsg_ShouldClose, OnMsgShouldClose) |
| 378 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) | 379 IPC_MESSAGE_HANDLER(ViewMsg_ClosePage, OnClosePage) |
| 379 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) | 380 IPC_MESSAGE_HANDLER(ViewMsg_ThemeChanged, OnThemeChanged) |
| 380 #ifdef CHROME_PERSONALIZATION | 381 #ifdef CHROME_PERSONALIZATION |
| 381 IPC_MESSAGE_HANDLER(ViewMsg_PersonalizationEvent, OnPersonalizationEvent) | 382 IPC_MESSAGE_HANDLER(ViewMsg_PersonalizationEvent, OnPersonalizationEvent) |
| 382 #endif | 383 #endif |
| 383 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, | 384 IPC_MESSAGE_HANDLER(ViewMsg_HandleMessageFromExternalHost, |
| 384 OnMessageFromExternalHost) | 385 OnMessageFromExternalHost) |
| 385 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, | 386 IPC_MESSAGE_HANDLER(ViewMsg_DisassociateFromPopupCount, |
| 386 OnDisassociateFromPopupCount) | 387 OnDisassociateFromPopupCount) |
| 388 IPC_MESSAGE_HANDLER(ViewMsg_AutofillSuggestions, |
| 389 OnReceivedAutofillSuggestions) |
| 387 // Have the super handle all other messages. | 390 // Have the super handle all other messages. |
| 388 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) | 391 IPC_MESSAGE_UNHANDLED(RenderWidget::OnMessageReceived(message)) |
| 389 IPC_END_MESSAGE_MAP() | 392 IPC_END_MESSAGE_MAP() |
| 390 } | 393 } |
| 391 | 394 |
| 392 // Got a response from the browser after the renderer decided to create a new | 395 // Got a response from the browser after the renderer decided to create a new |
| 393 // view. | 396 // view. |
| 394 void RenderView::OnCreatingNewAck(HWND parent) { | 397 void RenderView::OnCreatingNewAck(HWND parent) { |
| 395 CompleteInit(parent); | 398 CompleteInit(parent); |
| 396 | 399 |
| (...skipping 1260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 } | 1660 } |
| 1658 frame = webview->GetNextFrameAfter(frame, false); | 1661 frame = webview->GetNextFrameAfter(frame, false); |
| 1659 } | 1662 } |
| 1660 } | 1663 } |
| 1661 if (has_listener != has_unload_listener_) { | 1664 if (has_listener != has_unload_listener_) { |
| 1662 has_unload_listener_ = has_listener; | 1665 has_unload_listener_ = has_listener; |
| 1663 Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, has_listener)); | 1666 Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, has_listener)); |
| 1664 } | 1667 } |
| 1665 } | 1668 } |
| 1666 | 1669 |
| 1670 void RenderView::QueryFormFieldAutofill(const std::wstring& field_name, |
| 1671 const std::wstring& text, |
| 1672 int64 node_id) { |
| 1673 static int message_id_counter = 0; |
| 1674 form_field_autofill_request_id_ = message_id_counter++; |
| 1675 Send(new ViewHostMsg_QueryFormFieldAutofill(routing_id_, |
| 1676 field_name, text, |
| 1677 node_id, |
| 1678 form_field_autofill_request_id_)); |
| 1679 } |
| 1680 |
| 1681 void RenderView::OnReceivedAutofillSuggestions( |
| 1682 int64 node_id, |
| 1683 int request_id, |
| 1684 const std::vector<std::wstring> suggestions, |
| 1685 int default_suggestion_index) { |
| 1686 if (!webview() || request_id != form_field_autofill_request_id_) |
| 1687 return; |
| 1688 |
| 1689 webview()->AutofillSuggestionsForNode(node_id, suggestions, |
| 1690 default_suggestion_index); |
| 1691 } |
| 1692 |
| 1667 void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height, | 1693 void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height, |
| 1668 const std::string& json_arguments, | 1694 const std::string& json_arguments, |
| 1669 std::string* json_retval) { | 1695 std::string* json_retval) { |
| 1670 IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( | 1696 IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( |
| 1671 routing_id_, url, width, height, json_arguments, json_retval); | 1697 routing_id_, url, width, height, json_arguments, json_retval); |
| 1672 | 1698 |
| 1673 msg->set_pump_messages_event(modal_dialog_event_); | 1699 msg->set_pump_messages_event(modal_dialog_event_); |
| 1674 Send(msg); | 1700 Send(msg); |
| 1675 } | 1701 } |
| 1676 | 1702 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1755 view->set_opened_by_user_gesture(user_gesture); | 1781 view->set_opened_by_user_gesture(user_gesture); |
| 1756 view->set_waiting_for_create_window_ack(true); | 1782 view->set_waiting_for_create_window_ack(true); |
| 1757 | 1783 |
| 1758 // Copy over the alternate error page URL so we can have alt error pages in | 1784 // Copy over the alternate error page URL so we can have alt error pages in |
| 1759 // the new render view (we don't need the browser to send the URL back down). | 1785 // the new render view (we don't need the browser to send the URL back down). |
| 1760 view->alternate_error_page_url_ = alternate_error_page_url_; | 1786 view->alternate_error_page_url_ = alternate_error_page_url_; |
| 1761 | 1787 |
| 1762 return view->webview(); | 1788 return view->webview(); |
| 1763 } | 1789 } |
| 1764 | 1790 |
| 1765 WebWidget* RenderView::CreatePopupWidget(WebView* webview) { | 1791 WebWidget* RenderView::CreatePopupWidget(WebView* webview, |
| 1792 bool focus_on_show) { |
| 1766 RenderWidget* widget = RenderWidget::Create(routing_id_, | 1793 RenderWidget* widget = RenderWidget::Create(routing_id_, |
| 1767 RenderThread::current()); | 1794 RenderThread::current(), |
| 1795 focus_on_show); |
| 1768 return widget->webwidget(); | 1796 return widget->webwidget(); |
| 1769 } | 1797 } |
| 1770 | 1798 |
| 1771 static bool ShouldLoadPluginInProcess(const std::string& mime_type, | 1799 static bool ShouldLoadPluginInProcess(const std::string& mime_type, |
| 1772 bool* is_gears) { | 1800 bool* is_gears) { |
| 1773 if (RenderProcess::ShouldLoadPluginsInProcess()) | 1801 if (RenderProcess::ShouldLoadPluginsInProcess()) |
| 1774 return true; | 1802 return true; |
| 1775 | 1803 |
| 1776 if (mime_type == "application/x-googlegears") { | 1804 if (mime_type == "application/x-googlegears") { |
| 1777 *is_gears = true; | 1805 *is_gears = true; |
| (...skipping 919 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 template_resource_id)); | 2725 template_resource_id)); |
| 2698 | 2726 |
| 2699 if (template_html.empty()) { | 2727 if (template_html.empty()) { |
| 2700 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2728 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
| 2701 return ""; | 2729 return ""; |
| 2702 } | 2730 } |
| 2703 // "t" is the id of the templates root node. | 2731 // "t" is the id of the templates root node. |
| 2704 return jstemplate_builder::GetTemplateHtml( | 2732 return jstemplate_builder::GetTemplateHtml( |
| 2705 template_html, &error_strings, "t"); | 2733 template_html, &error_strings, "t"); |
| 2706 } | 2734 } |
| OLD | NEW |