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_view_impl.h" | 5 #include "content/renderer/render_view_impl.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 #include "content/public/common/content_switches.h" | 46 #include "content/public/common/content_switches.h" |
47 #include "content/public/common/context_menu_params.h" | 47 #include "content/public/common/context_menu_params.h" |
48 #include "content/public/common/file_chooser_params.h" | 48 #include "content/public/common/file_chooser_params.h" |
49 #include "content/public/common/selected_file_info.h" | 49 #include "content/public/common/selected_file_info.h" |
50 #include "content/public/common/url_constants.h" | 50 #include "content/public/common/url_constants.h" |
51 #include "content/public/renderer/content_renderer_client.h" | 51 #include "content/public/renderer/content_renderer_client.h" |
52 #include "content/public/renderer/document_state.h" | 52 #include "content/public/renderer/document_state.h" |
53 #include "content/public/renderer/navigation_state.h" | 53 #include "content/public/renderer/navigation_state.h" |
54 #include "content/public/renderer/render_view_observer.h" | 54 #include "content/public/renderer/render_view_observer.h" |
55 #include "content/public/renderer/render_view_visitor.h" | 55 #include "content/public/renderer/render_view_visitor.h" |
56 #include "content/renderer/browser_plugin/guest_render_view_observer.h" | |
56 #include "content/renderer/device_orientation_dispatcher.h" | 57 #include "content/renderer/device_orientation_dispatcher.h" |
57 #include "content/renderer/devtools_agent.h" | 58 #include "content/renderer/devtools_agent.h" |
58 #include "content/renderer/dom_automation_controller.h" | 59 #include "content/renderer/dom_automation_controller.h" |
59 #include "content/renderer/external_popup_menu.h" | 60 #include "content/renderer/external_popup_menu.h" |
60 #include "content/renderer/geolocation_dispatcher.h" | 61 #include "content/renderer/geolocation_dispatcher.h" |
61 #include "content/renderer/gpu/compositor_thread.h" | 62 #include "content/renderer/gpu/compositor_thread.h" |
62 #include "content/renderer/idle_user_detector.h" | 63 #include "content/renderer/idle_user_detector.h" |
63 #include "content/renderer/input_tag_speech_dispatcher.h" | 64 #include "content/renderer/input_tag_speech_dispatcher.h" |
64 #include "content/renderer/java/java_bridge_dispatcher.h" | 65 #include "content/renderer/java/java_bridge_dispatcher.h" |
65 #include "content/renderer/load_progress_tracker.h" | 66 #include "content/renderer/load_progress_tracker.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 selection_text_offset_(0), | 448 selection_text_offset_(0), |
448 cached_is_main_frame_pinned_to_left_(false), | 449 cached_is_main_frame_pinned_to_left_(false), |
449 cached_is_main_frame_pinned_to_right_(false), | 450 cached_is_main_frame_pinned_to_right_(false), |
450 cached_has_main_frame_horizontal_scrollbar_(false), | 451 cached_has_main_frame_horizontal_scrollbar_(false), |
451 cached_has_main_frame_vertical_scrollbar_(false), | 452 cached_has_main_frame_vertical_scrollbar_(false), |
452 context_has_swapbuffers_complete_callback_(false), | 453 context_has_swapbuffers_complete_callback_(false), |
453 queried_for_swapbuffers_complete_callback_(false), | 454 queried_for_swapbuffers_complete_callback_(false), |
454 context_is_web_graphics_context_3d_command_buffer_impl_(false), | 455 context_is_web_graphics_context_3d_command_buffer_impl_(false), |
455 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), | 456 ALLOW_THIS_IN_INITIALIZER_LIST(cookie_jar_(this)), |
456 geolocation_dispatcher_(NULL), | 457 geolocation_dispatcher_(NULL), |
458 guest_observer_(NULL), | |
457 input_tag_speech_dispatcher_(NULL), | 459 input_tag_speech_dispatcher_(NULL), |
458 device_orientation_dispatcher_(NULL), | 460 device_orientation_dispatcher_(NULL), |
459 media_stream_dispatcher_(NULL), | 461 media_stream_dispatcher_(NULL), |
460 p2p_socket_dispatcher_(NULL), | 462 p2p_socket_dispatcher_(NULL), |
461 devtools_agent_(NULL), | 463 devtools_agent_(NULL), |
462 renderer_accessibility_(NULL), | 464 renderer_accessibility_(NULL), |
463 mouse_lock_dispatcher_(NULL), | 465 mouse_lock_dispatcher_(NULL), |
464 session_storage_namespace_id_(session_storage_namespace_id), | 466 session_storage_namespace_id_(session_storage_namespace_id), |
465 handling_select_range_(false), | 467 handling_select_range_(false), |
466 #if defined(OS_WIN) | 468 #if defined(OS_WIN) |
(...skipping 27 matching lines...) Expand all Loading... | |
494 decrement_shared_popup_at_destruction_ = false; | 496 decrement_shared_popup_at_destruction_ = false; |
495 } | 497 } |
496 | 498 |
497 RenderThread::Get()->AddRoute(routing_id_, this); | 499 RenderThread::Get()->AddRoute(routing_id_, this); |
498 // Take a reference on behalf of the RenderThread. This will be balanced | 500 // Take a reference on behalf of the RenderThread. This will be balanced |
499 // when we receive ViewMsg_ClosePage. | 501 // when we receive ViewMsg_ClosePage. |
500 AddRef(); | 502 AddRef(); |
501 | 503 |
502 // If this is a popup, we must wait for the CreatingNew_ACK message before | 504 // If this is a popup, we must wait for the CreatingNew_ACK message before |
503 // completing initialization. Otherwise, we can finish it now. | 505 // completing initialization. Otherwise, we can finish it now. |
504 if (opener_id == MSG_ROUTING_NONE) { | 506 if (!guest_ && opener_id == MSG_ROUTING_NONE) { |
505 did_show_ = true; | 507 did_show_ = true; |
506 CompleteInit(parent_hwnd); | 508 CompleteInit(parent_hwnd); |
507 } | 509 } |
508 | 510 |
509 g_view_map.Get().insert(std::make_pair(webview(), this)); | 511 g_view_map.Get().insert(std::make_pair(webview(), this)); |
510 webkit_preferences_.Apply(webview()); | 512 webkit_preferences_.Apply(webview()); |
513 | |
514 // This needs to be before initializeMainFrame it seems. | |
515 // PpapiMsg_CreateChannel messages can get lost if the guest | |
516 // observer has not been constructed before a sync message. | |
517 if (!guest_observer_) | |
jam
2012/04/06 21:05:23
you're in the constructor, so how else would guest
Fady Samuel
2012/04/06 22:46:32
Doh! Lots of unnecessary code sticks around as one
| |
518 guest_observer_ = new GuestRenderViewObserver(this); | |
519 | |
511 webview()->initializeMainFrame(this); | 520 webview()->initializeMainFrame(this); |
512 if (!frame_name.empty()) | 521 if (!frame_name.empty()) |
513 webview()->mainFrame()->setName(frame_name); | 522 webview()->mainFrame()->setName(frame_name); |
514 webview()->settings()->setMinimumTimerInterval( | 523 webview()->settings()->setMinimumTimerInterval( |
515 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : | 524 is_hidden() ? webkit_glue::kBackgroundTabTimerInterval : |
516 webkit_glue::kForegroundTabTimerInterval); | 525 webkit_glue::kForegroundTabTimerInterval); |
517 | 526 |
518 OnSetRendererPrefs(renderer_prefs); | 527 OnSetRendererPrefs(renderer_prefs); |
519 | 528 |
520 host_window_ = parent_hwnd; | 529 host_window_ = parent_hwnd; |
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
831 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) | 840 IPC_MESSAGE_HANDLER(ViewMsg_SetInLiveResize, OnSetInLiveResize) |
832 #endif | 841 #endif |
833 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, | 842 IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune, |
834 OnSetHistoryLengthAndPrune) | 843 OnSetHistoryLengthAndPrune) |
835 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) | 844 IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode) |
836 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) | 845 IPC_MESSAGE_HANDLER(JavaBridgeMsg_Init, OnJavaBridgeInit) |
837 | 846 |
838 // Have the super handle all other messages. | 847 // Have the super handle all other messages. |
839 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) | 848 IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message)) |
840 IPC_END_MESSAGE_MAP() | 849 IPC_END_MESSAGE_MAP() |
841 | |
842 if (!msg_is_ok) { | 850 if (!msg_is_ok) { |
843 // The message had a handler, but its deserialization failed. | 851 // The message had a handler, but its deserialization failed. |
844 // Kill the renderer to avoid potential spoofing attacks. | 852 // Kill the renderer to avoid potential spoofing attacks. |
845 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; | 853 CHECK(false) << "Unable to deserialize message in RenderViewImpl."; |
846 } | 854 } |
847 | |
848 return handled; | 855 return handled; |
849 } | 856 } |
850 | 857 |
851 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { | 858 void RenderViewImpl::OnNavigate(const ViewMsg_Navigate_Params& params) { |
852 MaybeHandleDebugURL(params.url); | 859 MaybeHandleDebugURL(params.url); |
853 if (!webview()) | 860 if (!webview()) |
854 return; | 861 return; |
855 | 862 |
856 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); | 863 FOR_EACH_OBSERVER(RenderViewObserver, observers_, Navigate(params.url)); |
857 | 864 |
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1565 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); | 1572 CHECK(session_storage_namespace_id_ != kInvalidSessionStorageNamespaceId); |
1566 return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, | 1573 return new RendererWebStorageNamespaceImpl(DOM_STORAGE_SESSION, |
1567 session_storage_namespace_id_); | 1574 session_storage_namespace_id_); |
1568 #endif | 1575 #endif |
1569 } | 1576 } |
1570 | 1577 |
1571 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( | 1578 WebGraphicsContext3D* RenderViewImpl::createGraphicsContext3D( |
1572 const WebGraphicsContext3D::Attributes& attributes) { | 1579 const WebGraphicsContext3D::Attributes& attributes) { |
1573 if (!webview()) | 1580 if (!webview()) |
1574 return NULL; | 1581 return NULL; |
1582 | |
1583 if (guest_) { | |
1584 context_is_web_graphics_context_3d_command_buffer_impl_ = true; | |
1585 return guest_observer_->GetWebGraphicsContext3D(attributes); | |
piman
2012/04/06 23:19:26
When the context gets lost, we usually are in a st
Fady Samuel
2012/04/11 22:06:34
I can have the context inform the GuestToHostChann
| |
1586 } | |
1575 // The WebGraphicsContext3DInProcessImpl code path is used for | 1587 // The WebGraphicsContext3DInProcessImpl code path is used for |
1576 // layout tests (though not through this code) as well as for | 1588 // layout tests (though not through this code) as well as for |
1577 // debugging and bringing up new ports. | 1589 // debugging and bringing up new ports. |
1578 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { | 1590 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kInProcessWebGL)) { |
1579 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( | 1591 return webkit::gpu::WebGraphicsContext3DInProcessImpl::CreateForWebView( |
1580 attributes, true); | 1592 attributes, true); |
1581 } else { | 1593 } else { |
1582 GURL url; | 1594 GURL url; |
1583 if (webview()->mainFrame()) | 1595 if (webview()->mainFrame()) |
1584 url = GURL(webview()->mainFrame()->document().url()); | 1596 url = GURL(webview()->mainFrame()->document().url()); |
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3528 if (node.isContentEditable()) { | 3540 if (node.isContentEditable()) { |
3529 is_editable_node = true; | 3541 is_editable_node = true; |
3530 } else if (node.isElementNode()) { | 3542 } else if (node.isElementNode()) { |
3531 is_editable_node = | 3543 is_editable_node = |
3532 node.toConst<WebElement>().isTextFormControlElement(); | 3544 node.toConst<WebElement>().isTextFormControlElement(); |
3533 } | 3545 } |
3534 } | 3546 } |
3535 return is_editable_node; | 3547 return is_editable_node; |
3536 } | 3548 } |
3537 | 3549 |
3550 WebKit::WebPlugin* RenderViewImpl::CreateBrowserPlugin( | |
3551 base::ProcessHandle process_handle, | |
3552 const IPC::ChannelHandle& channel_handle, | |
3553 const WebKit::WebPluginParams& params) { | |
3554 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | |
3555 pepper_delegate_.CreateBrowserPluginModule(process_handle, | |
3556 channel_handle)); | |
3557 return new webkit::ppapi::WebPluginImpl( | |
3558 pepper_module.get(), params, pepper_delegate_.AsWeakPtr()); | |
3559 } | |
3560 | |
3538 WebKit::WebPlugin* RenderViewImpl::CreatePlugin( | 3561 WebKit::WebPlugin* RenderViewImpl::CreatePlugin( |
3539 WebKit::WebFrame* frame, | 3562 WebKit::WebFrame* frame, |
3540 const webkit::WebPluginInfo& info, | 3563 const webkit::WebPluginInfo& info, |
3541 const WebKit::WebPluginParams& params) { | 3564 const WebKit::WebPluginParams& params) { |
3542 bool pepper_plugin_was_registered = false; | 3565 bool pepper_plugin_was_registered = false; |
3543 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( | 3566 scoped_refptr<webkit::ppapi::PluginModule> pepper_module( |
3544 pepper_delegate_.CreatePepperPluginModule(info, | 3567 pepper_delegate_.CreatePepperPluginModule(info, |
3545 &pepper_plugin_was_registered)); | 3568 &pepper_plugin_was_registered)); |
3546 if (pepper_plugin_was_registered) { | 3569 if (pepper_plugin_was_registered) { |
3547 if (!pepper_module) | 3570 if (!pepper_module) |
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4559 } | 4582 } |
4560 | 4583 |
4561 void RenderViewImpl::WillInitiatePaint() { | 4584 void RenderViewImpl::WillInitiatePaint() { |
4562 // Notify the pepper plugins that we're about to paint. | 4585 // Notify the pepper plugins that we're about to paint. |
4563 pepper_delegate_.ViewWillInitiatePaint(); | 4586 pepper_delegate_.ViewWillInitiatePaint(); |
4564 } | 4587 } |
4565 | 4588 |
4566 void RenderViewImpl::DidInitiatePaint() { | 4589 void RenderViewImpl::DidInitiatePaint() { |
4567 // Notify the pepper plugins that we've painted, and are waiting to flush. | 4590 // Notify the pepper plugins that we've painted, and are waiting to flush. |
4568 pepper_delegate_.ViewInitiatedPaint(); | 4591 pepper_delegate_.ViewInitiatedPaint(); |
4592 if (guest()) | |
4593 guest_observer_->IssueSwapBuffers(); | |
4569 } | 4594 } |
4570 | 4595 |
4571 void RenderViewImpl::DidFlushPaint() { | 4596 void RenderViewImpl::DidFlushPaint() { |
4572 // Notify any pepper plugins that we painted. This will call into the plugin, | 4597 // Notify any pepper plugins that we painted. This will call into the plugin, |
4573 // and we it may ask to close itself as a result. This will, in turn, modify | 4598 // and we it may ask to close itself as a result. This will, in turn, modify |
4574 // our set, possibly invalidating the iterator. So we iterate on a copy that | 4599 // our set, possibly invalidating the iterator. So we iterate on a copy that |
4575 // won't change out from under us. | 4600 // won't change out from under us. |
4576 pepper_delegate_.ViewFlushedPaint(); | 4601 pepper_delegate_.ViewFlushedPaint(); |
4577 | 4602 |
4578 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. | 4603 // If the RenderWidget is closing down then early-exit, otherwise we'll crash. |
(...skipping 27 matching lines...) Expand all Loading... | |
4606 } | 4631 } |
4607 | 4632 |
4608 void RenderViewImpl::OnViewContextSwapBuffersComplete() { | 4633 void RenderViewImpl::OnViewContextSwapBuffersComplete() { |
4609 RenderWidget::OnSwapBuffersComplete(); | 4634 RenderWidget::OnSwapBuffersComplete(); |
4610 } | 4635 } |
4611 | 4636 |
4612 void RenderViewImpl::OnViewContextSwapBuffersAborted() { | 4637 void RenderViewImpl::OnViewContextSwapBuffersAborted() { |
4613 RenderWidget::OnSwapBuffersAborted(); | 4638 RenderWidget::OnSwapBuffersAborted(); |
4614 } | 4639 } |
4615 | 4640 |
4641 void RenderViewImpl::OnGuestReady() { | |
4642 CompleteInit(host_window_); | |
4643 } | |
4644 | |
4616 webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( | 4645 webkit::ppapi::PluginInstance* RenderViewImpl::GetBitmapForOptimizedPluginPaint( |
4617 const gfx::Rect& paint_bounds, | 4646 const gfx::Rect& paint_bounds, |
4618 TransportDIB** dib, | 4647 TransportDIB** dib, |
4619 gfx::Rect* location, | 4648 gfx::Rect* location, |
4620 gfx::Rect* clip) { | 4649 gfx::Rect* clip) { |
4621 return pepper_delegate_.GetBitmapForOptimizedPluginPaint( | 4650 return pepper_delegate_.GetBitmapForOptimizedPluginPaint( |
4622 paint_bounds, dib, location, clip); | 4651 paint_bounds, dib, location, clip); |
4623 } | 4652 } |
4624 | 4653 |
4625 gfx::Point RenderViewImpl::GetScrollOffset() { | 4654 gfx::Point RenderViewImpl::GetScrollOffset() { |
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5233 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { | 5262 bool RenderViewImpl::WebWidgetHandlesCompositorScheduling() const { |
5234 return !!RenderThreadImpl::current()->compositor_thread(); | 5263 return !!RenderThreadImpl::current()->compositor_thread(); |
5235 } | 5264 } |
5236 | 5265 |
5237 void RenderViewImpl::OnJavaBridgeInit() { | 5266 void RenderViewImpl::OnJavaBridgeInit() { |
5238 DCHECK(!java_bridge_dispatcher_.get()); | 5267 DCHECK(!java_bridge_dispatcher_.get()); |
5239 #if defined(ENABLE_JAVA_BRIDGE) | 5268 #if defined(ENABLE_JAVA_BRIDGE) |
5240 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); | 5269 java_bridge_dispatcher_.reset(new JavaBridgeDispatcher(this)); |
5241 #endif | 5270 #endif |
5242 } | 5271 } |
OLD | NEW |