| 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/renderer/render_thread_impl.h" | 5 #include "content/renderer/render_thread_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 | 1739 |
| 1740 // Some messages are handled by delegates. | 1740 // Some messages are handled by delegates. |
| 1741 if (appcache_dispatcher_->OnMessageReceived(msg) || | 1741 if (appcache_dispatcher_->OnMessageReceived(msg) || |
| 1742 dom_storage_dispatcher_->OnMessageReceived(msg) || | 1742 dom_storage_dispatcher_->OnMessageReceived(msg) || |
| 1743 embedded_worker_dispatcher_->OnMessageReceived(msg)) { | 1743 embedded_worker_dispatcher_->OnMessageReceived(msg)) { |
| 1744 return true; | 1744 return true; |
| 1745 } | 1745 } |
| 1746 | 1746 |
| 1747 bool handled = true; | 1747 bool handled = true; |
| 1748 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) | 1748 IPC_BEGIN_MESSAGE_MAP(RenderThreadImpl, msg) |
| 1749 // TODO(port): removed from render_messages_internal.h; | |
| 1750 // is there a new non-windows message I should add here? | |
| 1751 IPC_MESSAGE_HANDLER(ViewMsg_NetworkConnectionChanged, | |
| 1752 OnNetworkConnectionChanged) | |
| 1753 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateNewSharedWorker) | 1749 IPC_MESSAGE_HANDLER(WorkerProcessMsg_CreateWorker, OnCreateNewSharedWorker) |
| 1754 #if defined(OS_ANDROID) | |
| 1755 IPC_MESSAGE_HANDLER(ViewMsg_SetWebKitSharedTimersSuspended, | |
| 1756 OnSetWebKitSharedTimersSuspended) | |
| 1757 #endif | |
| 1758 #if defined(OS_MACOSX) | |
| 1759 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScrollbarTheme, OnUpdateScrollbarTheme) | |
| 1760 IPC_MESSAGE_HANDLER(ViewMsg_SystemColorsChanged, OnSystemColorsChanged) | |
| 1761 #endif | |
| 1762 #if defined(ENABLE_PLUGINS) | |
| 1763 IPC_MESSAGE_HANDLER(ViewMsg_PurgePluginListCache, OnPurgePluginListCache) | |
| 1764 #endif | |
| 1765 IPC_MESSAGE_UNHANDLED(handled = false) | 1750 IPC_MESSAGE_UNHANDLED(handled = false) |
| 1766 IPC_END_MESSAGE_MAP() | 1751 IPC_END_MESSAGE_MAP() |
| 1767 return handled; | 1752 return handled; |
| 1768 } | 1753 } |
| 1769 | 1754 |
| 1770 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { | 1755 void RenderThreadImpl::OnProcessBackgrounded(bool backgrounded) { |
| 1771 ChildThreadImpl::OnProcessBackgrounded(backgrounded); | 1756 ChildThreadImpl::OnProcessBackgrounded(backgrounded); |
| 1772 | 1757 |
| 1773 if (backgrounded) { | 1758 if (backgrounded) { |
| 1774 renderer_scheduler_->OnRendererBackgrounded(); | 1759 renderer_scheduler_->OnRendererBackgrounded(); |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2108 } | 2093 } |
| 2109 | 2094 |
| 2110 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { | 2095 gpu::GpuChannelHost* RenderThreadImpl::GetGpuChannel() { |
| 2111 if (!gpu_channel_) | 2096 if (!gpu_channel_) |
| 2112 return nullptr; | 2097 return nullptr; |
| 2113 if (gpu_channel_->IsLost()) | 2098 if (gpu_channel_->IsLost()) |
| 2114 return nullptr; | 2099 return nullptr; |
| 2115 return gpu_channel_.get(); | 2100 return gpu_channel_.get(); |
| 2116 } | 2101 } |
| 2117 | 2102 |
| 2118 #if defined(ENABLE_PLUGINS) | |
| 2119 void RenderThreadImpl::OnPurgePluginListCache(bool reload_pages) { | |
| 2120 // The call below will cause a GetPlugins call with refresh=true, but at this | |
| 2121 // point we already know that the browser has refreshed its list, so disable | |
| 2122 // refresh temporarily to prevent each renderer process causing the list to be | |
| 2123 // regenerated. | |
| 2124 blink_platform_impl_->set_plugin_refresh_allowed(false); | |
| 2125 blink::resetPluginCache(reload_pages); | |
| 2126 blink_platform_impl_->set_plugin_refresh_allowed(true); | |
| 2127 | |
| 2128 for (auto& observer : observers_) | |
| 2129 observer.PluginListChanged(); | |
| 2130 } | |
| 2131 #endif | |
| 2132 | |
| 2133 void RenderThreadImpl::OnNetworkConnectionChanged( | |
| 2134 net::NetworkChangeNotifier::ConnectionType type, | |
| 2135 double max_bandwidth_mbps) { | |
| 2136 bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; | |
| 2137 WebNetworkStateNotifier::setOnLine(online); | |
| 2138 for (auto& observer : observers_) | |
| 2139 observer.NetworkStateChanged(online); | |
| 2140 WebNetworkStateNotifier::setWebConnection( | |
| 2141 NetConnectionTypeToWebConnectionType(type), max_bandwidth_mbps); | |
| 2142 } | |
| 2143 | |
| 2144 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { | 2103 void RenderThreadImpl::CreateView(mojom::CreateViewParamsPtr params) { |
| 2145 CompositorDependencies* compositor_deps = this; | 2104 CompositorDependencies* compositor_deps = this; |
| 2146 // When bringing in render_view, also bring in webkit's glue and jsbindings. | 2105 // When bringing in render_view, also bring in webkit's glue and jsbindings. |
| 2147 RenderViewImpl::Create(compositor_deps, *params, false); | 2106 RenderViewImpl::Create(compositor_deps, *params, false); |
| 2148 } | 2107 } |
| 2149 | 2108 |
| 2150 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { | 2109 void RenderThreadImpl::CreateFrame(mojom::CreateFrameParamsPtr params) { |
| 2151 // Debug cases of https://crbug.com/626802. | 2110 // Debug cases of https://crbug.com/626802. |
| 2152 base::debug::SetCrashKeyValue("newframe_routing_id", | 2111 base::debug::SetCrashKeyValue("newframe_routing_id", |
| 2153 base::IntToString(params->routing_id)); | 2112 base::IntToString(params->routing_id)); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2187 base::IntToString(render_view_routing_id)); | 2146 base::IntToString(render_view_routing_id)); |
| 2188 base::debug::SetCrashKeyValue("newproxy_opener_id", | 2147 base::debug::SetCrashKeyValue("newproxy_opener_id", |
| 2189 base::IntToString(opener_routing_id)); | 2148 base::IntToString(opener_routing_id)); |
| 2190 base::debug::SetCrashKeyValue("newproxy_parent_id", | 2149 base::debug::SetCrashKeyValue("newproxy_parent_id", |
| 2191 base::IntToString(parent_routing_id)); | 2150 base::IntToString(parent_routing_id)); |
| 2192 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id, | 2151 RenderFrameProxy::CreateFrameProxy(routing_id, render_view_routing_id, |
| 2193 opener_routing_id, parent_routing_id, | 2152 opener_routing_id, parent_routing_id, |
| 2194 replicated_state); | 2153 replicated_state); |
| 2195 } | 2154 } |
| 2196 | 2155 |
| 2156 void RenderThreadImpl::OnNetworkConnectionChanged( |
| 2157 net::NetworkChangeNotifier::ConnectionType type, |
| 2158 double max_bandwidth_mbps) { |
| 2159 bool online = type != net::NetworkChangeNotifier::CONNECTION_NONE; |
| 2160 WebNetworkStateNotifier::setOnLine(online); |
| 2161 for (auto& observer : observers_) |
| 2162 observer.NetworkStateChanged(online); |
| 2163 WebNetworkStateNotifier::setWebConnection( |
| 2164 NetConnectionTypeToWebConnectionType(type), max_bandwidth_mbps); |
| 2165 } |
| 2166 |
| 2167 void RenderThreadImpl::SetWebKitSharedTimersSuspended(bool suspend) { |
| 2168 #if defined(OS_ANDROID) |
| 2169 if (suspend) { |
| 2170 renderer_scheduler_->SuspendTimerQueue(); |
| 2171 } else { |
| 2172 renderer_scheduler_->ResumeTimerQueue(); |
| 2173 } |
| 2174 webkit_shared_timer_suspended_ = suspend; |
| 2175 #else |
| 2176 NOTREACHED(); |
| 2177 #endif |
| 2178 } |
| 2179 |
| 2180 void RenderThreadImpl::UpdateScrollbarTheme( |
| 2181 mojom::UpdateScrollbarThemeParamsPtr params) { |
| 2182 #if defined(OS_MACOSX) |
| 2183 static_cast<WebScrollbarBehaviorImpl*>( |
| 2184 blink_platform_impl_->scrollbarBehavior()) |
| 2185 ->set_jump_on_track_click(params->jump_on_track_click); |
| 2186 |
| 2187 blink::WebScrollbarTheme::updateScrollbarsWithNSDefaults( |
| 2188 params->initial_button_delay, params->autoscroll_button_delay, |
| 2189 params->preferred_scroller_style, params->redraw, |
| 2190 params->button_placement); |
| 2191 #else |
| 2192 NOTREACHED(); |
| 2193 #endif |
| 2194 } |
| 2195 |
| 2196 void RenderThreadImpl::OnSystemColorsChanged( |
| 2197 int32_t aqua_color_variant, |
| 2198 const std::string& highlight_text_color, |
| 2199 const std::string& highlight_color) { |
| 2200 #if defined(OS_MACOSX) |
| 2201 SystemColorsDidChange(aqua_color_variant, highlight_text_color, |
| 2202 highlight_color); |
| 2203 #else |
| 2204 NOTREACHED(); |
| 2205 #endif |
| 2206 } |
| 2207 |
| 2208 void RenderThreadImpl::PurgePluginListCache(bool reload_pages) { |
| 2209 #if defined(ENABLE_PLUGINS) |
| 2210 // The call below will cause a GetPlugins call with refresh=true, but at this |
| 2211 // point we already know that the browser has refreshed its list, so disable |
| 2212 // refresh temporarily to prevent each renderer process causing the list to be |
| 2213 // regenerated. |
| 2214 blink_platform_impl_->set_plugin_refresh_allowed(false); |
| 2215 blink::resetPluginCache(reload_pages); |
| 2216 blink_platform_impl_->set_plugin_refresh_allowed(true); |
| 2217 |
| 2218 for (auto& observer : observers_) |
| 2219 observer.PluginListChanged(); |
| 2220 #else |
| 2221 NOTREACHED(); |
| 2222 #endif |
| 2223 } |
| 2224 |
| 2197 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) { | 2225 void RenderThreadImpl::OnTimeZoneChange(const std::string& zone_id) { |
| 2198 if (!blink_platform_impl_) | 2226 if (!blink_platform_impl_) |
| 2199 return; | 2227 return; |
| 2200 if (!zone_id.empty()) { | 2228 if (!zone_id.empty()) { |
| 2201 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( | 2229 icu::TimeZone *new_zone = icu::TimeZone::createTimeZone( |
| 2202 icu::UnicodeString::fromUTF8(zone_id)); | 2230 icu::UnicodeString::fromUTF8(zone_id)); |
| 2203 icu::TimeZone::adoptDefault(new_zone); | 2231 icu::TimeZone::adoptDefault(new_zone); |
| 2204 VLOG(1) << "ICU default timezone is set to " << zone_id; | 2232 VLOG(1) << "ICU default timezone is set to " << zone_id; |
| 2205 } | 2233 } |
| 2206 NotifyTimezoneChange(); | 2234 NotifyTimezoneChange(); |
| 2207 } | 2235 } |
| 2208 | 2236 |
| 2209 #if defined(OS_ANDROID) | |
| 2210 void RenderThreadImpl::OnSetWebKitSharedTimersSuspended(bool suspend) { | |
| 2211 if (suspend) { | |
| 2212 renderer_scheduler_->SuspendTimerQueue(); | |
| 2213 } else { | |
| 2214 renderer_scheduler_->ResumeTimerQueue(); | |
| 2215 } | |
| 2216 webkit_shared_timer_suspended_ = suspend; | |
| 2217 } | |
| 2218 #endif | |
| 2219 | |
| 2220 #if defined(OS_MACOSX) | |
| 2221 void RenderThreadImpl::OnUpdateScrollbarTheme( | |
| 2222 const ViewMsg_UpdateScrollbarTheme_Params& params) { | |
| 2223 static_cast<WebScrollbarBehaviorImpl*>( | |
| 2224 blink_platform_impl_->scrollbarBehavior()) | |
| 2225 ->set_jump_on_track_click(params.jump_on_track_click); | |
| 2226 | |
| 2227 blink::WebScrollbarTheme::updateScrollbarsWithNSDefaults( | |
| 2228 params.initial_button_delay, params.autoscroll_button_delay, | |
| 2229 params.preferred_scroller_style, params.redraw, | |
| 2230 params.button_placement); | |
| 2231 } | |
| 2232 | |
| 2233 void RenderThreadImpl::OnSystemColorsChanged( | |
| 2234 int aqua_color_variant, | |
| 2235 const std::string& highlight_text_color, | |
| 2236 const std::string& highlight_color) { | |
| 2237 SystemColorsDidChange(aqua_color_variant, highlight_text_color, | |
| 2238 highlight_color); | |
| 2239 } | |
| 2240 #endif | |
| 2241 | |
| 2242 void RenderThreadImpl::OnCreateNewSharedWorker( | 2237 void RenderThreadImpl::OnCreateNewSharedWorker( |
| 2243 const WorkerProcessMsg_CreateWorker_Params& params) { | 2238 const WorkerProcessMsg_CreateWorker_Params& params) { |
| 2244 // EmbeddedSharedWorkerStub will self-destruct. | 2239 // EmbeddedSharedWorkerStub will self-destruct. |
| 2245 new EmbeddedSharedWorkerStub( | 2240 new EmbeddedSharedWorkerStub( |
| 2246 params.url, params.name, params.content_security_policy, | 2241 params.url, params.name, params.content_security_policy, |
| 2247 params.security_policy_type, params.creation_address_space, | 2242 params.security_policy_type, params.creation_address_space, |
| 2248 params.pause_on_start, params.route_id); | 2243 params.pause_on_start, params.route_id); |
| 2249 } | 2244 } |
| 2250 | 2245 |
| 2251 void RenderThreadImpl::OnMemoryPressure( | 2246 void RenderThreadImpl::OnMemoryPressure( |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 } | 2471 } |
| 2477 } | 2472 } |
| 2478 | 2473 |
| 2479 void RenderThreadImpl::OnRendererInterfaceRequest( | 2474 void RenderThreadImpl::OnRendererInterfaceRequest( |
| 2480 mojom::RendererAssociatedRequest request) { | 2475 mojom::RendererAssociatedRequest request) { |
| 2481 DCHECK(!renderer_binding_.is_bound()); | 2476 DCHECK(!renderer_binding_.is_bound()); |
| 2482 renderer_binding_.Bind(std::move(request)); | 2477 renderer_binding_.Bind(std::move(request)); |
| 2483 } | 2478 } |
| 2484 | 2479 |
| 2485 } // namespace content | 2480 } // namespace content |
| OLD | NEW |