| 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 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 #ifdef CHROME_PERSONALIZATION | 190 #ifdef CHROME_PERSONALIZATION |
| 191 Personalization::CleanupRendererPersonalization(personalization_); | 191 Personalization::CleanupRendererPersonalization(personalization_); |
| 192 personalization_ = NULL; | 192 personalization_ = NULL; |
| 193 #endif | 193 #endif |
| 194 } | 194 } |
| 195 | 195 |
| 196 /*static*/ | 196 /*static*/ |
| 197 RenderView* RenderView::Create( | 197 RenderView* RenderView::Create( |
| 198 RenderThreadBase* render_thread, | 198 RenderThreadBase* render_thread, |
| 199 HWND parent_hwnd, | 199 HWND parent_hwnd, |
| 200 HANDLE modal_dialog_event, | 200 base::WaitableEvent* modal_dialog_event, |
| 201 int32 opener_id, | 201 int32 opener_id, |
| 202 const WebPreferences& webkit_prefs, | 202 const WebPreferences& webkit_prefs, |
| 203 SharedRenderViewCounter* counter, | 203 SharedRenderViewCounter* counter, |
| 204 int32 routing_id) { | 204 int32 routing_id) { |
| 205 DCHECK(routing_id != MSG_ROUTING_NONE); | 205 DCHECK(routing_id != MSG_ROUTING_NONE); |
| 206 scoped_refptr<RenderView> view = new RenderView(render_thread); | 206 scoped_refptr<RenderView> view = new RenderView(render_thread); |
| 207 view->Init(parent_hwnd, | 207 view->Init(parent_hwnd, |
| 208 modal_dialog_event, | 208 modal_dialog_event, |
| 209 opener_id, | 209 opener_id, |
| 210 webkit_prefs, | 210 webkit_prefs, |
| (...skipping 27 matching lines...) Expand all Loading... |
| 238 void RenderView::PluginCrashed(const FilePath& plugin_path) { | 238 void RenderView::PluginCrashed(const FilePath& plugin_path) { |
| 239 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); | 239 Send(new ViewHostMsg_CrashedPlugin(routing_id_, plugin_path)); |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 void RenderView::JSOutOfMemory() { | 243 void RenderView::JSOutOfMemory() { |
| 244 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); | 244 Send(new ViewHostMsg_JSOutOfMemory(routing_id_)); |
| 245 } | 245 } |
| 246 | 246 |
| 247 void RenderView::Init(HWND parent_hwnd, | 247 void RenderView::Init(HWND parent_hwnd, |
| 248 HANDLE modal_dialog_event, | 248 base::WaitableEvent* modal_dialog_event, |
| 249 int32 opener_id, | 249 int32 opener_id, |
| 250 const WebPreferences& webkit_prefs, | 250 const WebPreferences& webkit_prefs, |
| 251 SharedRenderViewCounter* counter, | 251 SharedRenderViewCounter* counter, |
| 252 int32 routing_id) { | 252 int32 routing_id) { |
| 253 DCHECK(!webview()); | 253 DCHECK(!webview()); |
| 254 | 254 |
| 255 if (opener_id != MSG_ROUTING_NONE) | 255 if (opener_id != MSG_ROUTING_NONE) |
| 256 opener_id_ = opener_id; | 256 opener_id_ = opener_id; |
| 257 | 257 |
| 258 if (counter) { | 258 if (counter) { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 280 AddRef(); | 280 AddRef(); |
| 281 | 281 |
| 282 // If this is a popup, we must wait for the CreatingNew_ACK message before | 282 // If this is a popup, we must wait for the CreatingNew_ACK message before |
| 283 // completing initialization. Otherwise, we can finish it now. | 283 // completing initialization. Otherwise, we can finish it now. |
| 284 if (opener_id == MSG_ROUTING_NONE) { | 284 if (opener_id == MSG_ROUTING_NONE) { |
| 285 did_show_ = true; | 285 did_show_ = true; |
| 286 CompleteInit(parent_hwnd); | 286 CompleteInit(parent_hwnd); |
| 287 } | 287 } |
| 288 | 288 |
| 289 host_window_ = parent_hwnd; | 289 host_window_ = parent_hwnd; |
| 290 modal_dialog_event_.Set(modal_dialog_event); | 290 modal_dialog_event_.reset(modal_dialog_event); |
| 291 | 291 |
| 292 CommandLine command_line; | 292 CommandLine command_line; |
| 293 enable_dom_automation_ = | 293 enable_dom_automation_ = |
| 294 command_line.HasSwitch(switches::kDomAutomationController); | 294 command_line.HasSwitch(switches::kDomAutomationController); |
| 295 disable_popup_blocking_ = | 295 disable_popup_blocking_ = |
| 296 command_line.HasSwitch(switches::kDisablePopupBlocking); | 296 command_line.HasSwitch(switches::kDisablePopupBlocking); |
| 297 user_scripts_enabled_ = | 297 user_scripts_enabled_ = |
| 298 command_line.HasSwitch(switches::kEnableUserScripts); | 298 command_line.HasSwitch(switches::kEnableUserScripts); |
| 299 | 299 |
| 300 debug_message_handler_ = new DebugMessageHandler(this); | 300 debug_message_handler_ = new DebugMessageHandler(this); |
| (...skipping 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 const std::wstring& message, | 1641 const std::wstring& message, |
| 1642 const std::wstring& default_value, | 1642 const std::wstring& default_value, |
| 1643 std::wstring* result) { | 1643 std::wstring* result) { |
| 1644 bool success = false; | 1644 bool success = false; |
| 1645 std::wstring result_temp; | 1645 std::wstring result_temp; |
| 1646 if (!result) | 1646 if (!result) |
| 1647 result = &result_temp; | 1647 result = &result_temp; |
| 1648 IPC::SyncMessage* msg = new ViewHostMsg_RunJavaScriptMessage( | 1648 IPC::SyncMessage* msg = new ViewHostMsg_RunJavaScriptMessage( |
| 1649 routing_id_, message, default_value, type, &success, result); | 1649 routing_id_, message, default_value, type, &success, result); |
| 1650 | 1650 |
| 1651 msg->set_pump_messages_event(modal_dialog_event_); | 1651 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 1652 Send(msg); | 1652 Send(msg); |
| 1653 | 1653 |
| 1654 return success; | 1654 return success; |
| 1655 } | 1655 } |
| 1656 | 1656 |
| 1657 void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) { | 1657 void RenderView::AddGURLSearchProvider(const GURL& osd_url, bool autodetected) { |
| 1658 if (!osd_url.is_empty()) | 1658 if (!osd_url.is_empty()) |
| 1659 Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url, | 1659 Send(new ViewHostMsg_PageHasOSDD(routing_id_, page_id_, osd_url, |
| 1660 autodetected)); | 1660 autodetected)); |
| 1661 } | 1661 } |
| 1662 | 1662 |
| 1663 bool RenderView::RunBeforeUnloadConfirm(WebView* webview, | 1663 bool RenderView::RunBeforeUnloadConfirm(WebView* webview, |
| 1664 const std::wstring& message) { | 1664 const std::wstring& message) { |
| 1665 bool success = false; | 1665 bool success = false; |
| 1666 // This is an ignored return value, but is included so we can accept the same | 1666 // This is an ignored return value, but is included so we can accept the same |
| 1667 // response as RunJavaScriptMessage. | 1667 // response as RunJavaScriptMessage. |
| 1668 std::wstring ignored_result; | 1668 std::wstring ignored_result; |
| 1669 IPC::SyncMessage* msg = new ViewHostMsg_RunBeforeUnloadConfirm( | 1669 IPC::SyncMessage* msg = new ViewHostMsg_RunBeforeUnloadConfirm( |
| 1670 routing_id_, message, &success, &ignored_result); | 1670 routing_id_, message, &success, &ignored_result); |
| 1671 | 1671 |
| 1672 msg->set_pump_messages_event(modal_dialog_event_); | 1672 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 1673 Send(msg); | 1673 Send(msg); |
| 1674 | 1674 |
| 1675 return success; | 1675 return success; |
| 1676 } | 1676 } |
| 1677 | 1677 |
| 1678 void RenderView::EnableSuddenTermination() { | 1678 void RenderView::EnableSuddenTermination() { |
| 1679 Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, false)); | 1679 Send(new ViewHostMsg_UnloadListenerChanged(routing_id_, false)); |
| 1680 } | 1680 } |
| 1681 | 1681 |
| 1682 void RenderView::DisableSuddenTermination() { | 1682 void RenderView::DisableSuddenTermination() { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1709 void RenderView::OnPopupNotificationVisiblityChanged(bool visible) { | 1709 void RenderView::OnPopupNotificationVisiblityChanged(bool visible) { |
| 1710 popup_notification_visible_ = visible; | 1710 popup_notification_visible_ = visible; |
| 1711 } | 1711 } |
| 1712 | 1712 |
| 1713 void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height, | 1713 void RenderView::ShowModalHTMLDialog(const GURL& url, int width, int height, |
| 1714 const std::string& json_arguments, | 1714 const std::string& json_arguments, |
| 1715 std::string* json_retval) { | 1715 std::string* json_retval) { |
| 1716 IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( | 1716 IPC::SyncMessage* msg = new ViewHostMsg_ShowModalHTMLDialog( |
| 1717 routing_id_, url, width, height, json_arguments, json_retval); | 1717 routing_id_, url, width, height, json_arguments, json_retval); |
| 1718 | 1718 |
| 1719 msg->set_pump_messages_event(modal_dialog_event_); | 1719 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 1720 Send(msg); | 1720 Send(msg); |
| 1721 } | 1721 } |
| 1722 | 1722 |
| 1723 uint32 RenderView::GetCPBrowsingContext() { | 1723 uint32 RenderView::GetCPBrowsingContext() { |
| 1724 uint32 context = 0; | 1724 uint32 context = 0; |
| 1725 Send(new ViewHostMsg_GetCPBrowsingContext(&context)); | 1725 Send(new ViewHostMsg_GetCPBrowsingContext(&context)); |
| 1726 return context; | 1726 return context; |
| 1727 } | 1727 } |
| 1728 | 1728 |
| 1729 // Tell the browser to display a destination link. | 1729 // Tell the browser to display a destination link. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1796 bool result = render_thread_->Send( | 1796 bool result = render_thread_->Send( |
| 1797 new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id, | 1797 new ViewHostMsg_CreateWindow(routing_id_, user_gesture, &routing_id, |
| 1798 &modal_dialog_event)); | 1798 &modal_dialog_event)); |
| 1799 if (routing_id == MSG_ROUTING_NONE) { | 1799 if (routing_id == MSG_ROUTING_NONE) { |
| 1800 DCHECK(modal_dialog_event == NULL); | 1800 DCHECK(modal_dialog_event == NULL); |
| 1801 return NULL; | 1801 return NULL; |
| 1802 } | 1802 } |
| 1803 | 1803 |
| 1804 // The WebView holds a reference to this new RenderView | 1804 // The WebView holds a reference to this new RenderView |
| 1805 const WebPreferences& prefs = webview->GetPreferences(); | 1805 const WebPreferences& prefs = webview->GetPreferences(); |
| 1806 base::WaitableEvent* waitable_event = |
| 1807 new base::WaitableEvent(modal_dialog_event); |
| 1806 RenderView* view = RenderView::Create(render_thread_, | 1808 RenderView* view = RenderView::Create(render_thread_, |
| 1807 NULL, modal_dialog_event, routing_id_, | 1809 NULL, waitable_event, routing_id_, |
| 1808 prefs, shared_popup_counter_, | 1810 prefs, shared_popup_counter_, |
| 1809 routing_id); | 1811 routing_id); |
| 1810 view->set_opened_by_user_gesture(user_gesture); | 1812 view->set_opened_by_user_gesture(user_gesture); |
| 1811 view->set_waiting_for_create_window_ack(true); | 1813 view->set_waiting_for_create_window_ack(true); |
| 1812 | 1814 |
| 1813 // Copy over the alternate error page URL so we can have alt error pages in | 1815 // Copy over the alternate error page URL so we can have alt error pages in |
| 1814 // the new render view (we don't need the browser to send the URL back down). | 1816 // the new render view (we don't need the browser to send the URL back down). |
| 1815 view->alternate_error_page_url_ = alternate_error_page_url_; | 1817 view->alternate_error_page_url_ = alternate_error_page_url_; |
| 1816 | 1818 |
| 1817 return view->webview(); | 1819 return view->webview(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1931 void RenderView::CloseWidgetSoon(WebWidget* webwidget) { | 1933 void RenderView::CloseWidgetSoon(WebWidget* webwidget) { |
| 1932 if (popup_notification_visible_ == false) | 1934 if (popup_notification_visible_ == false) |
| 1933 RenderWidget::CloseWidgetSoon(webwidget); | 1935 RenderWidget::CloseWidgetSoon(webwidget); |
| 1934 } | 1936 } |
| 1935 | 1937 |
| 1936 void RenderView::RunModal(WebWidget* webwidget) { | 1938 void RenderView::RunModal(WebWidget* webwidget) { |
| 1937 DCHECK(did_show_) << "should already have shown the view"; | 1939 DCHECK(did_show_) << "should already have shown the view"; |
| 1938 | 1940 |
| 1939 IPC::SyncMessage* msg = new ViewHostMsg_RunModal(routing_id_); | 1941 IPC::SyncMessage* msg = new ViewHostMsg_RunModal(routing_id_); |
| 1940 | 1942 |
| 1941 msg->set_pump_messages_event(modal_dialog_event_); | 1943 msg->set_pump_messages_event(modal_dialog_event_.get()); |
| 1942 Send(msg); | 1944 Send(msg); |
| 1943 } | 1945 } |
| 1944 | 1946 |
| 1945 void RenderView::SyncNavigationState() { | 1947 void RenderView::SyncNavigationState() { |
| 1946 if (!webview()) | 1948 if (!webview()) |
| 1947 return; | 1949 return; |
| 1948 | 1950 |
| 1949 std::string state; | 1951 std::string state; |
| 1950 if (!webview()->GetMainFrame()->GetCurrentHistoryState(&state)) | 1952 if (!webview()->GetMainFrame()->GetCurrentHistoryState(&state)) |
| 1951 return; | 1953 return; |
| (...skipping 815 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2767 template_resource_id)); | 2769 template_resource_id)); |
| 2768 | 2770 |
| 2769 if (template_html.empty()) { | 2771 if (template_html.empty()) { |
| 2770 NOTREACHED() << "unable to load template. ID: " << template_resource_id; | 2772 NOTREACHED() << "unable to load template. ID: " << template_resource_id; |
| 2771 return ""; | 2773 return ""; |
| 2772 } | 2774 } |
| 2773 // "t" is the id of the templates root node. | 2775 // "t" is the id of the templates root node. |
| 2774 return jstemplate_builder::GetTemplateHtml( | 2776 return jstemplate_builder::GetTemplateHtml( |
| 2775 template_html, &error_strings, "t"); | 2777 template_html, &error_strings, "t"); |
| 2776 } | 2778 } |
| OLD | NEW |