Chromium Code Reviews| 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 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 navigations_suspended_(false), | 192 navigations_suspended_(false), |
| 193 main_frame_routing_id_(main_frame_routing_id), | 193 main_frame_routing_id_(main_frame_routing_id), |
| 194 run_modal_reply_msg_(NULL), | 194 run_modal_reply_msg_(NULL), |
| 195 run_modal_opener_id_(MSG_ROUTING_NONE), | 195 run_modal_opener_id_(MSG_ROUTING_NONE), |
| 196 is_waiting_for_beforeunload_ack_(false), | 196 is_waiting_for_beforeunload_ack_(false), |
| 197 unload_ack_is_for_cross_site_transition_(false), | 197 unload_ack_is_for_cross_site_transition_(false), |
| 198 sudden_termination_allowed_(false), | 198 sudden_termination_allowed_(false), |
| 199 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 199 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 200 virtual_keyboard_requested_(false), | 200 virtual_keyboard_requested_(false), |
| 201 weak_factory_(this), | 201 weak_factory_(this), |
| 202 is_focused_element_editable_(false) { | 202 is_focused_element_editable_(false), |
| 203 updating_web_preferences_(false) { | |
| 203 DCHECK(instance_.get()); | 204 DCHECK(instance_.get()); |
| 204 CHECK(delegate_); // http://crbug.com/82827 | 205 CHECK(delegate_); // http://crbug.com/82827 |
| 205 | 206 |
| 206 GetProcess()->EnableSendQueue(); | 207 GetProcess()->EnableSendQueue(); |
| 207 | 208 |
| 208 if (swapped_out) { | 209 if (swapped_out) { |
| 209 rvh_state_ = STATE_SWAPPED_OUT; | 210 rvh_state_ = STATE_SWAPPED_OUT; |
| 210 } else { | 211 } else { |
| 211 rvh_state_ = STATE_DEFAULT; | 212 rvh_state_ = STATE_DEFAULT; |
| 212 instance_->increment_active_view_count(); | 213 instance_->increment_active_view_count(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 | 283 |
| 283 // Ensure the RenderView starts with a next_page_id larger than any existing | 284 // Ensure the RenderView starts with a next_page_id larger than any existing |
| 284 // page ID it might be asked to render. | 285 // page ID it might be asked to render. |
| 285 int32 next_page_id = 1; | 286 int32 next_page_id = 1; |
| 286 if (max_page_id > -1) | 287 if (max_page_id > -1) |
| 287 next_page_id = max_page_id + 1; | 288 next_page_id = max_page_id + 1; |
| 288 | 289 |
| 289 ViewMsg_New_Params params; | 290 ViewMsg_New_Params params; |
| 290 params.renderer_preferences = | 291 params.renderer_preferences = |
| 291 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 292 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
| 292 params.web_preferences = delegate_->GetWebkitPrefs(); | 293 params.web_preferences = GetWebkitPreferences(); |
| 293 params.view_id = GetRoutingID(); | 294 params.view_id = GetRoutingID(); |
| 294 params.main_frame_routing_id = main_frame_routing_id_; | 295 params.main_frame_routing_id = main_frame_routing_id_; |
| 295 params.surface_id = surface_id(); | 296 params.surface_id = surface_id(); |
| 296 params.session_storage_namespace_id = | 297 params.session_storage_namespace_id = |
| 297 delegate_->GetSessionStorageNamespace(instance_)->id(); | 298 delegate_->GetSessionStorageNamespace(instance_)->id(); |
| 298 params.frame_name = frame_name; | 299 params.frame_name = frame_name; |
| 299 // Ensure the RenderView sets its opener correctly. | 300 // Ensure the RenderView sets its opener correctly. |
| 300 params.opener_route_id = opener_route_id; | 301 params.opener_route_id = opener_route_id; |
| 301 params.swapped_out = !IsRVHStateActive(rvh_state_); | 302 params.swapped_out = !IsRVHStateActive(rvh_state_); |
| 302 params.proxy_routing_id = proxy_route_id; | 303 params.proxy_routing_id = proxy_route_id; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 322 bool RenderViewHostImpl::IsRenderViewLive() const { | 323 bool RenderViewHostImpl::IsRenderViewLive() const { |
| 323 return GetProcess()->HasConnection() && renderer_initialized_; | 324 return GetProcess()->HasConnection() && renderer_initialized_; |
| 324 } | 325 } |
| 325 | 326 |
| 326 void RenderViewHostImpl::SyncRendererPrefs() { | 327 void RenderViewHostImpl::SyncRendererPrefs() { |
| 327 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), | 328 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), |
| 328 delegate_->GetRendererPrefs( | 329 delegate_->GetRendererPrefs( |
| 329 GetProcess()->GetBrowserContext()))); | 330 GetProcess()->GetBrowserContext()))); |
| 330 } | 331 } |
| 331 | 332 |
| 332 WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) { | 333 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs(const GURL& url) { |
| 333 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); | 334 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); |
| 334 WebPreferences prefs; | 335 WebPreferences prefs; |
| 335 | 336 |
| 336 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 337 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 337 | 338 |
| 338 prefs.javascript_enabled = | 339 prefs.javascript_enabled = |
| 339 !command_line.HasSwitch(switches::kDisableJavaScript); | 340 !command_line.HasSwitch(switches::kDisableJavaScript); |
| 340 prefs.web_security_enabled = | 341 prefs.web_security_enabled = |
| 341 !command_line.HasSwitch(switches::kDisableWebSecurity); | 342 !command_line.HasSwitch(switches::kDisableWebSecurity); |
| 342 prefs.plugins_enabled = | 343 prefs.plugins_enabled = |
| (...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1411 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); | 1412 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); |
| 1412 } | 1413 } |
| 1413 | 1414 |
| 1414 void RenderViewHostImpl::ExitFullscreen() { | 1415 void RenderViewHostImpl::ExitFullscreen() { |
| 1415 RejectMouseLockOrUnlockIfNecessary(); | 1416 RejectMouseLockOrUnlockIfNecessary(); |
| 1416 // Notify delegate_ and renderer of fullscreen state change. | 1417 // Notify delegate_ and renderer of fullscreen state change. |
| 1417 OnToggleFullscreen(false); | 1418 OnToggleFullscreen(false); |
| 1418 } | 1419 } |
| 1419 | 1420 |
| 1420 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { | 1421 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { |
| 1421 return delegate_->GetWebkitPrefs(); | 1422 if (!web_preferences_.get()) { |
| 1423 OnWebkitPreferencesChanged(); | |
| 1424 } | |
| 1425 return *web_preferences_; | |
| 1422 } | 1426 } |
| 1423 | 1427 |
| 1424 void RenderViewHostImpl::DisownOpener() { | 1428 void RenderViewHostImpl::DisownOpener() { |
| 1425 // This should only be called when swapped out. | 1429 // This should only be called when swapped out. |
| 1426 DCHECK(IsSwappedOut()); | 1430 DCHECK(IsSwappedOut()); |
| 1427 | 1431 |
| 1428 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 1432 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
| 1429 } | 1433 } |
| 1430 | 1434 |
| 1431 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 1435 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
| 1436 web_preferences_.reset(new WebPreferences(prefs)); | |
| 1432 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 1437 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 1433 } | 1438 } |
| 1434 | 1439 |
| 1440 void RenderViewHostImpl::OnWebkitPreferencesChanged() { | |
| 1441 // This is defensive code to avoid infinite loops due to code run inside | |
|
chrishtr
2014/08/06 16:14:58
See additional defensive code here to avoid an inf
| |
| 1442 // UpdateWebkitPreferences() accidentally updating more preferences and thus | |
| 1443 // calling back into this code. See crbug.com/398751 for one past example. | |
| 1444 if (updating_web_preferences_) | |
| 1445 return; | |
| 1446 updating_web_preferences_ = true; | |
| 1447 UpdateWebkitPreferences(delegate_->ComputeWebkitPrefs()); | |
| 1448 updating_web_preferences_ = false; | |
| 1449 } | |
| 1450 | |
| 1435 void RenderViewHostImpl::GetAudioOutputControllers( | 1451 void RenderViewHostImpl::GetAudioOutputControllers( |
| 1436 const GetAudioOutputControllersCallback& callback) const { | 1452 const GetAudioOutputControllersCallback& callback) const { |
| 1437 AudioRendererHost* audio_host = | 1453 AudioRendererHost* audio_host = |
| 1438 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); | 1454 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); |
| 1439 audio_host->GetOutputControllers(GetRoutingID(), callback); | 1455 audio_host->GetOutputControllers(GetRoutingID(), callback); |
| 1440 } | 1456 } |
| 1441 | 1457 |
| 1442 void RenderViewHostImpl::ClearFocusedElement() { | 1458 void RenderViewHostImpl::ClearFocusedElement() { |
| 1443 is_focused_element_editable_ = false; | 1459 is_focused_element_editable_ = false; |
| 1444 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); | 1460 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1580 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1596 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1581 | 1597 |
| 1582 frame_tree->ResetForMainFrameSwap(); | 1598 frame_tree->ResetForMainFrameSwap(); |
| 1583 } | 1599 } |
| 1584 | 1600 |
| 1585 void RenderViewHostImpl::SelectWordAroundCaret() { | 1601 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1586 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1602 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1587 } | 1603 } |
| 1588 | 1604 |
| 1589 } // namespace content | 1605 } // namespace content |
| OLD | NEW |