| 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 page_id_(-1), | 193 page_id_(-1), |
| 194 main_frame_routing_id_(main_frame_routing_id), | 194 main_frame_routing_id_(main_frame_routing_id), |
| 195 run_modal_reply_msg_(NULL), | 195 run_modal_reply_msg_(NULL), |
| 196 run_modal_opener_id_(MSG_ROUTING_NONE), | 196 run_modal_opener_id_(MSG_ROUTING_NONE), |
| 197 is_waiting_for_beforeunload_ack_(false), | 197 is_waiting_for_beforeunload_ack_(false), |
| 198 unload_ack_is_for_cross_site_transition_(false), | 198 unload_ack_is_for_cross_site_transition_(false), |
| 199 sudden_termination_allowed_(false), | 199 sudden_termination_allowed_(false), |
| 200 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), | 200 render_view_termination_status_(base::TERMINATION_STATUS_STILL_RUNNING), |
| 201 virtual_keyboard_requested_(false), | 201 virtual_keyboard_requested_(false), |
| 202 weak_factory_(this), | 202 weak_factory_(this), |
| 203 is_focused_element_editable_(false) { | 203 is_focused_element_editable_(false), |
| 204 updating_web_preferences_(false) { |
| 204 DCHECK(instance_.get()); | 205 DCHECK(instance_.get()); |
| 205 CHECK(delegate_); // http://crbug.com/82827 | 206 CHECK(delegate_); // http://crbug.com/82827 |
| 206 | 207 |
| 207 GetProcess()->EnableSendQueue(); | 208 GetProcess()->EnableSendQueue(); |
| 208 | 209 |
| 209 if (swapped_out) { | 210 if (swapped_out) { |
| 210 rvh_state_ = STATE_SWAPPED_OUT; | 211 rvh_state_ = STATE_SWAPPED_OUT; |
| 211 } else { | 212 } else { |
| 212 rvh_state_ = STATE_DEFAULT; | 213 rvh_state_ = STATE_DEFAULT; |
| 213 instance_->increment_active_view_count(); | 214 instance_->increment_active_view_count(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 // page ID it might be asked to render. | 286 // page ID it might be asked to render. |
| 286 int32 next_page_id = 1; | 287 int32 next_page_id = 1; |
| 287 if (max_page_id > -1) { | 288 if (max_page_id > -1) { |
| 288 next_page_id = max_page_id + 1; | 289 next_page_id = max_page_id + 1; |
| 289 page_id_ = max_page_id; | 290 page_id_ = max_page_id; |
| 290 } | 291 } |
| 291 | 292 |
| 292 ViewMsg_New_Params params; | 293 ViewMsg_New_Params params; |
| 293 params.renderer_preferences = | 294 params.renderer_preferences = |
| 294 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); | 295 delegate_->GetRendererPrefs(GetProcess()->GetBrowserContext()); |
| 295 params.web_preferences = delegate_->GetWebkitPrefs(); | 296 params.web_preferences = GetWebkitPreferences(); |
| 296 params.view_id = GetRoutingID(); | 297 params.view_id = GetRoutingID(); |
| 297 params.main_frame_routing_id = main_frame_routing_id_; | 298 params.main_frame_routing_id = main_frame_routing_id_; |
| 298 params.surface_id = surface_id(); | 299 params.surface_id = surface_id(); |
| 299 params.session_storage_namespace_id = | 300 params.session_storage_namespace_id = |
| 300 delegate_->GetSessionStorageNamespace(instance_)->id(); | 301 delegate_->GetSessionStorageNamespace(instance_)->id(); |
| 301 params.frame_name = frame_name; | 302 params.frame_name = frame_name; |
| 302 // Ensure the RenderView sets its opener correctly. | 303 // Ensure the RenderView sets its opener correctly. |
| 303 params.opener_route_id = opener_route_id; | 304 params.opener_route_id = opener_route_id; |
| 304 params.swapped_out = !IsRVHStateActive(rvh_state_); | 305 params.swapped_out = !IsRVHStateActive(rvh_state_); |
| 305 params.proxy_routing_id = proxy_route_id; | 306 params.proxy_routing_id = proxy_route_id; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 325 bool RenderViewHostImpl::IsRenderViewLive() const { | 326 bool RenderViewHostImpl::IsRenderViewLive() const { |
| 326 return GetProcess()->HasConnection() && renderer_initialized_; | 327 return GetProcess()->HasConnection() && renderer_initialized_; |
| 327 } | 328 } |
| 328 | 329 |
| 329 void RenderViewHostImpl::SyncRendererPrefs() { | 330 void RenderViewHostImpl::SyncRendererPrefs() { |
| 330 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), | 331 Send(new ViewMsg_SetRendererPrefs(GetRoutingID(), |
| 331 delegate_->GetRendererPrefs( | 332 delegate_->GetRendererPrefs( |
| 332 GetProcess()->GetBrowserContext()))); | 333 GetProcess()->GetBrowserContext()))); |
| 333 } | 334 } |
| 334 | 335 |
| 335 WebPreferences RenderViewHostImpl::GetWebkitPrefs(const GURL& url) { | 336 WebPreferences RenderViewHostImpl::ComputeWebkitPrefs(const GURL& url) { |
| 336 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); | 337 TRACE_EVENT0("browser", "RenderViewHostImpl::GetWebkitPrefs"); |
| 337 WebPreferences prefs; | 338 WebPreferences prefs; |
| 338 | 339 |
| 339 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 340 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 340 | 341 |
| 341 prefs.javascript_enabled = | 342 prefs.javascript_enabled = |
| 342 !command_line.HasSwitch(switches::kDisableJavaScript); | 343 !command_line.HasSwitch(switches::kDisableJavaScript); |
| 343 prefs.web_security_enabled = | 344 prefs.web_security_enabled = |
| 344 !command_line.HasSwitch(switches::kDisableWebSecurity); | 345 !command_line.HasSwitch(switches::kDisableWebSecurity); |
| 345 prefs.plugins_enabled = | 346 prefs.plugins_enabled = |
| (...skipping 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1416 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); | 1417 view_->OnTextSurroundingSelectionResponse(content, start_offset, end_offset); |
| 1417 } | 1418 } |
| 1418 | 1419 |
| 1419 void RenderViewHostImpl::ExitFullscreen() { | 1420 void RenderViewHostImpl::ExitFullscreen() { |
| 1420 RejectMouseLockOrUnlockIfNecessary(); | 1421 RejectMouseLockOrUnlockIfNecessary(); |
| 1421 // Notify delegate_ and renderer of fullscreen state change. | 1422 // Notify delegate_ and renderer of fullscreen state change. |
| 1422 OnToggleFullscreen(false); | 1423 OnToggleFullscreen(false); |
| 1423 } | 1424 } |
| 1424 | 1425 |
| 1425 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { | 1426 WebPreferences RenderViewHostImpl::GetWebkitPreferences() { |
| 1426 return delegate_->GetWebkitPrefs(); | 1427 if (!web_preferences_.get()) { |
| 1428 OnWebkitPreferencesChanged(); |
| 1429 } |
| 1430 return *web_preferences_; |
| 1427 } | 1431 } |
| 1428 | 1432 |
| 1429 void RenderViewHostImpl::DisownOpener() { | 1433 void RenderViewHostImpl::DisownOpener() { |
| 1430 // This should only be called when swapped out. | 1434 // This should only be called when swapped out. |
| 1431 DCHECK(IsSwappedOut()); | 1435 DCHECK(IsSwappedOut()); |
| 1432 | 1436 |
| 1433 Send(new ViewMsg_DisownOpener(GetRoutingID())); | 1437 Send(new ViewMsg_DisownOpener(GetRoutingID())); |
| 1434 } | 1438 } |
| 1435 | 1439 |
| 1436 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { | 1440 void RenderViewHostImpl::UpdateWebkitPreferences(const WebPreferences& prefs) { |
| 1441 web_preferences_.reset(new WebPreferences(prefs)); |
| 1437 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); | 1442 Send(new ViewMsg_UpdateWebPreferences(GetRoutingID(), prefs)); |
| 1438 } | 1443 } |
| 1439 | 1444 |
| 1445 void RenderViewHostImpl::OnWebkitPreferencesChanged() { |
| 1446 // This is defensive code to avoid infinite loops due to code run inside |
| 1447 // UpdateWebkitPreferences() accidentally updating more preferences and thus |
| 1448 // calling back into this code. See crbug.com/398751 for one past example. |
| 1449 if (updating_web_preferences_) |
| 1450 return; |
| 1451 updating_web_preferences_ = true; |
| 1452 UpdateWebkitPreferences(delegate_->ComputeWebkitPrefs()); |
| 1453 updating_web_preferences_ = false; |
| 1454 } |
| 1455 |
| 1440 void RenderViewHostImpl::GetAudioOutputControllers( | 1456 void RenderViewHostImpl::GetAudioOutputControllers( |
| 1441 const GetAudioOutputControllersCallback& callback) const { | 1457 const GetAudioOutputControllersCallback& callback) const { |
| 1442 AudioRendererHost* audio_host = | 1458 AudioRendererHost* audio_host = |
| 1443 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); | 1459 static_cast<RenderProcessHostImpl*>(GetProcess())->audio_renderer_host(); |
| 1444 audio_host->GetOutputControllers(GetRoutingID(), callback); | 1460 audio_host->GetOutputControllers(GetRoutingID(), callback); |
| 1445 } | 1461 } |
| 1446 | 1462 |
| 1447 void RenderViewHostImpl::ClearFocusedElement() { | 1463 void RenderViewHostImpl::ClearFocusedElement() { |
| 1448 is_focused_element_editable_ = false; | 1464 is_focused_element_editable_ = false; |
| 1449 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); | 1465 Send(new ViewMsg_ClearFocusedElement(GetRoutingID())); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1587 FrameTree* frame_tree = delegate_->GetFrameTree(); | 1603 FrameTree* frame_tree = delegate_->GetFrameTree(); |
| 1588 | 1604 |
| 1589 frame_tree->ResetForMainFrameSwap(); | 1605 frame_tree->ResetForMainFrameSwap(); |
| 1590 } | 1606 } |
| 1591 | 1607 |
| 1592 void RenderViewHostImpl::SelectWordAroundCaret() { | 1608 void RenderViewHostImpl::SelectWordAroundCaret() { |
| 1593 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); | 1609 Send(new ViewMsg_SelectWordAroundCaret(GetRoutingID())); |
| 1594 } | 1610 } |
| 1595 | 1611 |
| 1596 } // namespace content | 1612 } // namespace content |
| OLD | NEW |