OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/renderer_host/render_view_host_impl.h" | 5 #include "content/browser/renderer_host/render_view_host_impl.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 12 matching lines...) Expand all Loading... | |
23 #endif | 23 #endif |
24 #include "content/browser/child_process_security_policy_impl.h" | 24 #include "content/browser/child_process_security_policy_impl.h" |
25 #include "content/browser/cross_site_request_manager.h" | 25 #include "content/browser/cross_site_request_manager.h" |
26 #include "content/browser/dom_storage/dom_storage_context_impl.h" | 26 #include "content/browser/dom_storage/dom_storage_context_impl.h" |
27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" | 27 #include "content/browser/dom_storage/session_storage_namespace_impl.h" |
28 #include "content/browser/gpu/gpu_surface_tracker.h" | 28 #include "content/browser/gpu/gpu_surface_tracker.h" |
29 #include "content/browser/host_zoom_map_impl.h" | 29 #include "content/browser/host_zoom_map_impl.h" |
30 #include "content/browser/power_save_blocker.h" | 30 #include "content/browser/power_save_blocker.h" |
31 #include "content/browser/renderer_host/render_process_host_impl.h" | 31 #include "content/browser/renderer_host/render_process_host_impl.h" |
32 #include "content/common/accessibility_messages.h" | 32 #include "content/common/accessibility_messages.h" |
33 #include "content/common/browser_plugin_messages.h" | |
33 #include "content/common/desktop_notification_messages.h" | 34 #include "content/common/desktop_notification_messages.h" |
34 #include "content/common/drag_messages.h" | 35 #include "content/common/drag_messages.h" |
35 #include "content/common/inter_process_time_ticks_converter.h" | 36 #include "content/common/inter_process_time_ticks_converter.h" |
36 #include "content/common/speech_recognition_messages.h" | 37 #include "content/common/speech_recognition_messages.h" |
37 #include "content/common/swapped_out_messages.h" | 38 #include "content/common/swapped_out_messages.h" |
38 #include "content/common/view_messages.h" | 39 #include "content/common/view_messages.h" |
39 #include "content/port/browser/render_widget_host_view_port.h" | 40 #include "content/port/browser/render_widget_host_view_port.h" |
40 #include "content/public/browser/browser_accessibility_state.h" | 41 #include "content/public/browser/browser_accessibility_state.h" |
41 #include "content/public/browser/browser_context.h" | 42 #include "content/public/browser/browser_context.h" |
42 #include "content/public/browser/browser_message_filter.h" | 43 #include "content/public/browser/browser_message_filter.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
98 | 99 |
99 } // namespace | 100 } // namespace |
100 | 101 |
101 namespace content { | 102 namespace content { |
102 | 103 |
103 /////////////////////////////////////////////////////////////////////////////// | 104 /////////////////////////////////////////////////////////////////////////////// |
104 // RenderViewHost, public: | 105 // RenderViewHost, public: |
105 | 106 |
106 // static | 107 // static |
107 RenderViewHost* RenderViewHost::FromID(int render_process_id, | 108 RenderViewHost* RenderViewHost::FromID(int render_process_id, |
108 int render_view_id) { | 109 int render_view_id) { |
109 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); | 110 RenderProcessHost* process = RenderProcessHost::FromID(render_process_id); |
110 if (!process) | 111 if (!process) |
111 return NULL; | 112 return NULL; |
112 RenderWidgetHost* widget = process->GetRenderWidgetHostByID(render_view_id); | 113 RenderWidgetHost* widget = process->GetRenderWidgetHostByID(render_view_id); |
113 if (!widget || !widget->IsRenderView()) | 114 if (!widget || !widget->IsRenderView()) |
114 return NULL; | 115 return NULL; |
115 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget)); | 116 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(widget)); |
116 } | 117 } |
117 | 118 |
118 // static | 119 // static |
119 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { | 120 RenderViewHost* RenderViewHost::From(RenderWidgetHost* rwh) { |
120 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); | 121 return static_cast<RenderViewHostImpl*>(RenderWidgetHostImpl::From(rwh)); |
121 } | 122 } |
122 | 123 |
123 /////////////////////////////////////////////////////////////////////////////// | 124 /////////////////////////////////////////////////////////////////////////////// |
124 // RenderViewHostImpl, public: | 125 // RenderViewHostImpl, public: |
125 | 126 |
126 // static | 127 // static |
127 RenderViewHostImpl* RenderViewHostImpl::FromID(int render_process_id, | 128 RenderViewHostImpl* RenderViewHostImpl::FromID(int render_process_id, |
128 int render_view_id) { | 129 int render_view_id) { |
Charlie Reis
2012/05/18 20:35:24
Wrong indent.
Fady Samuel
2012/05/21 14:30:17
Done.
| |
129 return static_cast<RenderViewHostImpl*>( | 130 return static_cast<RenderViewHostImpl*>( |
130 RenderViewHost::FromID(render_process_id, render_view_id)); | 131 RenderViewHost::FromID(render_process_id, render_view_id)); |
131 } | 132 } |
132 | 133 |
133 RenderViewHostImpl::RenderViewHostImpl( | 134 RenderViewHostImpl::RenderViewHostImpl( |
134 SiteInstance* instance, | 135 SiteInstance* instance, |
135 RenderViewHostDelegate* delegate, | 136 RenderViewHostDelegate* delegate, |
136 RenderWidgetHostDelegate* widget_delegate, | 137 RenderWidgetHostDelegate* widget_delegate, |
137 int routing_id, | 138 int routing_id, |
138 bool swapped_out, | 139 bool swapped_out, |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 } else { | 251 } else { |
251 content::RenderWidgetHostViewPort::GetDefaultScreenInfo( | 252 content::RenderWidgetHostViewPort::GetDefaultScreenInfo( |
252 ¶ms.screen_info); | 253 ¶ms.screen_info); |
253 } | 254 } |
254 #else | 255 #else |
255 params.screen_info = | 256 params.screen_info = |
256 WebKit::WebScreenInfoFactory::screenInfo( | 257 WebKit::WebScreenInfoFactory::screenInfo( |
257 gfx::NativeViewFromId(GetNativeViewId())); | 258 gfx::NativeViewFromId(GetNativeViewId())); |
258 #endif | 259 #endif |
259 | 260 |
260 if (embedder_process_id != -1) | 261 if (embedder_process_id != -1) { |
261 params.embedder_channel_name = | 262 params.embedder_channel_name = |
262 StringPrintf("%d.r%d", GetProcess()->GetID(), embedder_process_id); | 263 StringPrintf("%d.r%d", GetProcess()->GetID(), embedder_process_id); |
264 } | |
263 | 265 |
264 params.accessibility_mode = | 266 params.accessibility_mode = |
265 BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser() ? | 267 BrowserAccessibilityState::GetInstance()->IsAccessibleBrowser() ? |
266 AccessibilityModeComplete : | 268 AccessibilityModeComplete : |
267 AccessibilityModeOff; | 269 AccessibilityModeOff; |
268 | 270 |
269 #if defined(OS_WIN) | 271 #if defined(OS_WIN) |
270 // On Windows 8, always enable accessibility for editable text controls | 272 // On Windows 8, always enable accessibility for editable text controls |
271 // so we can show the virtual keyboard when one is enabled. | 273 // so we can show the virtual keyboard when one is enabled. |
272 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && | 274 if (base::win::GetVersion() >= base::win::VERSION_WIN8 && |
(...skipping 633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
906 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, | 908 IPC_MESSAGE_HANDLER(DesktopNotificationHostMsg_Cancel, |
907 OnCancelDesktopNotification) | 909 OnCancelDesktopNotification) |
908 #if defined(OS_MACOSX) | 910 #if defined(OS_MACOSX) |
909 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 911 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
910 #endif | 912 #endif |
911 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 913 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
912 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, | 914 IPC_MESSAGE_HANDLER(ViewHostMsg_DomOperationResponse, |
913 OnDomOperationResponse) | 915 OnDomOperationResponse) |
914 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications, | 916 IPC_MESSAGE_HANDLER(AccessibilityHostMsg_Notifications, |
915 OnAccessibilityNotifications) | 917 OnAccessibilityNotifications) |
918 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_ResizeGuest, OnResizeGuest) | |
919 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_NavigateFromEmbedder, | |
920 OnNavigateGuestFromEmbedder) | |
916 // Have the super handle all other messages. | 921 // Have the super handle all other messages. |
917 IPC_MESSAGE_UNHANDLED( | 922 IPC_MESSAGE_UNHANDLED( |
918 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) | 923 handled = RenderWidgetHostImpl::OnMessageReceived(msg)) |
919 IPC_END_MESSAGE_MAP_EX() | 924 IPC_END_MESSAGE_MAP_EX() |
920 | 925 |
921 if (!msg_is_ok) { | 926 if (!msg_is_ok) { |
922 // The message had a handler, but its de-serialization failed. | 927 // The message had a handler, but its de-serialization failed. |
923 // Kill the renderer. | 928 // Kill the renderer. |
924 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 929 content::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
925 GetProcess()->ReceivedBadMessage(); | 930 GetProcess()->ReceivedBadMessage(); |
(...skipping 887 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1813 | 1818 |
1814 void RenderViewHostImpl::OnDomOperationResponse( | 1819 void RenderViewHostImpl::OnDomOperationResponse( |
1815 const std::string& json_string, int automation_id) { | 1820 const std::string& json_string, int automation_id) { |
1816 DomOperationNotificationDetails details(json_string, automation_id); | 1821 DomOperationNotificationDetails details(json_string, automation_id); |
1817 content::NotificationService::current()->Notify( | 1822 content::NotificationService::current()->Notify( |
1818 content::NOTIFICATION_DOM_OPERATION_RESPONSE, | 1823 content::NOTIFICATION_DOM_OPERATION_RESPONSE, |
1819 content::Source<RenderViewHost>(this), | 1824 content::Source<RenderViewHost>(this), |
1820 content::Details<DomOperationNotificationDetails>(&details)); | 1825 content::Details<DomOperationNotificationDetails>(&details)); |
1821 } | 1826 } |
1822 | 1827 |
1828 void RenderViewHostImpl::OnResizeGuest(int width, int height) { | |
1829 DCHECK(GetView()); | |
1830 GetView()->SetSize(gfx::Size(width, height)); | |
1831 } | |
1832 | |
1833 void RenderViewHostImpl::OnNavigateGuestFromEmbedder(int32 instance_id, | |
1834 long long frame_id, | |
1835 const std::string& src, | |
1836 const gfx::Size& size) { | |
1837 | |
Charlie Reis
2012/05/18 20:35:24
Remove blank line.
Fady Samuel
2012/05/21 14:30:17
Done.
| |
1838 delegate_->NavigateGuestFromEmbedder( | |
1839 this, | |
1840 instance_id, | |
1841 frame_id, | |
1842 src, | |
1843 size); | |
1844 } | |
1845 | |
1823 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { | 1846 void RenderViewHostImpl::SetSwappedOut(bool is_swapped_out) { |
1824 is_swapped_out_ = is_swapped_out; | 1847 is_swapped_out_ = is_swapped_out; |
1825 | 1848 |
1826 // Whenever we change swap out state, we should not be waiting for | 1849 // Whenever we change swap out state, we should not be waiting for |
1827 // beforeunload or unload acks. We clear them here to be safe, since they | 1850 // beforeunload or unload acks. We clear them here to be safe, since they |
1828 // can cause navigations to be ignored in OnMsgNavigate. | 1851 // can cause navigations to be ignored in OnMsgNavigate. |
1829 is_waiting_for_beforeunload_ack_ = false; | 1852 is_waiting_for_beforeunload_ack_ = false; |
1830 is_waiting_for_unload_ack_ = false; | 1853 is_waiting_for_unload_ack_ = false; |
1831 } | 1854 } |
1832 | 1855 |
1833 void RenderViewHostImpl::ClearPowerSaveBlockers() { | 1856 void RenderViewHostImpl::ClearPowerSaveBlockers() { |
1834 STLDeleteValues(&power_save_blockers_); | 1857 STLDeleteValues(&power_save_blockers_); |
1835 } | 1858 } |
1836 | 1859 |
1837 } // namespace content | 1860 } // namespace content |
OLD | NEW |