| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 997 } | 997 } |
| 998 | 998 |
| 999 // RenderFrameImpl ---------------------------------------------------------- | 999 // RenderFrameImpl ---------------------------------------------------------- |
| 1000 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) | 1000 RenderFrameImpl::RenderFrameImpl(const CreateParams& params) |
| 1001 : frame_(NULL), | 1001 : frame_(NULL), |
| 1002 is_main_frame_(true), | 1002 is_main_frame_(true), |
| 1003 in_browser_initiated_detach_(false), | 1003 in_browser_initiated_detach_(false), |
| 1004 in_frame_tree_(false), | 1004 in_frame_tree_(false), |
| 1005 render_view_(params.render_view->AsWeakPtr()), | 1005 render_view_(params.render_view->AsWeakPtr()), |
| 1006 routing_id_(params.routing_id), | 1006 routing_id_(params.routing_id), |
| 1007 render_frame_proxy_(NULL), | |
| 1008 is_detaching_(false), | 1007 is_detaching_(false), |
| 1009 proxy_routing_id_(MSG_ROUTING_NONE), | 1008 proxy_routing_id_(MSG_ROUTING_NONE), |
| 1010 #if defined(ENABLE_PLUGINS) | 1009 #if defined(ENABLE_PLUGINS) |
| 1011 plugin_power_saver_helper_(nullptr), | 1010 plugin_power_saver_helper_(nullptr), |
| 1012 plugin_find_handler_(nullptr), | 1011 plugin_find_handler_(nullptr), |
| 1013 #endif | 1012 #endif |
| 1014 cookie_jar_(this), | 1013 cookie_jar_(this), |
| 1015 selection_text_offset_(0), | 1014 selection_text_offset_(0), |
| 1016 selection_range_(gfx::Range::InvalidRange()), | 1015 selection_range_(gfx::Range::InvalidRange()), |
| 1017 handling_select_range_(false), | 1016 handling_select_range_(false), |
| (...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 // Synchronously run the unload handler before sending the ACK. | 1565 // Synchronously run the unload handler before sending the ACK. |
| 1567 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support | 1566 // TODO(creis): Call dispatchUnloadEvent unconditionally here to support |
| 1568 // unload on subframes as well. | 1567 // unload on subframes as well. |
| 1569 if (is_main_frame_) | 1568 if (is_main_frame_) |
| 1570 frame_->dispatchUnloadEvent(); | 1569 frame_->dispatchUnloadEvent(); |
| 1571 | 1570 |
| 1572 // Swap out and stop sending any IPC messages that are not ACKs. | 1571 // Swap out and stop sending any IPC messages that are not ACKs. |
| 1573 if (is_main_frame_) | 1572 if (is_main_frame_) |
| 1574 render_view_->SetSwappedOut(true); | 1573 render_view_->SetSwappedOut(true); |
| 1575 | 1574 |
| 1576 // Set the proxy here, since OnStop() below could cause an onload event | |
| 1577 // handler to execute, which could trigger code such as | |
| 1578 // willCheckAndDispatchMessageEvent() that needs the proxy. | |
| 1579 set_render_frame_proxy(proxy); | |
| 1580 | |
| 1581 // Transfer settings such as initial drawing parameters to the remote frame, | 1575 // Transfer settings such as initial drawing parameters to the remote frame, |
| 1582 // if one is created, that will replace this frame. | 1576 // if one is created, that will replace this frame. |
| 1583 if (!is_main_frame_) | 1577 if (!is_main_frame_) |
| 1584 proxy->web_frame()->initializeFromFrame(frame_); | 1578 proxy->web_frame()->initializeFromFrame(frame_); |
| 1585 | 1579 |
| 1586 // Let WebKit know that this view is hidden so it can drop resources and | 1580 // Let WebKit know that this view is hidden so it can drop resources and |
| 1587 // stop compositing. | 1581 // stop compositing. |
| 1588 // TODO(creis): Support this for subframes as well. | 1582 // TODO(creis): Support this for subframes as well. |
| 1589 if (is_main_frame_) { | 1583 if (is_main_frame_) { |
| 1590 render_view_->webview()->setVisibilityState( | 1584 render_view_->webview()->setVisibilityState( |
| (...skipping 2552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4143 } | 4137 } |
| 4144 return web_encrypted_media_client_.get(); | 4138 return web_encrypted_media_client_.get(); |
| 4145 } | 4139 } |
| 4146 | 4140 |
| 4147 blink::WebMIDIClient* RenderFrameImpl::webMIDIClient() { | 4141 blink::WebMIDIClient* RenderFrameImpl::webMIDIClient() { |
| 4148 if (!midi_dispatcher_) | 4142 if (!midi_dispatcher_) |
| 4149 midi_dispatcher_ = new MidiDispatcher(this); | 4143 midi_dispatcher_ = new MidiDispatcher(this); |
| 4150 return midi_dispatcher_; | 4144 return midi_dispatcher_; |
| 4151 } | 4145 } |
| 4152 | 4146 |
| 4153 bool RenderFrameImpl::willCheckAndDispatchMessageEvent( | |
| 4154 blink::WebLocalFrame* source_frame, | |
| 4155 blink::WebFrame* target_frame, | |
| 4156 blink::WebSecurityOrigin target_origin, | |
| 4157 blink::WebDOMMessageEvent event) { | |
| 4158 DCHECK(!frame_ || frame_ == target_frame); | |
| 4159 | |
| 4160 // TODO(alexmos, nasko): When swapped-out:// disappears, this should be | |
| 4161 // cleaned up so that RenderFrameProxy::postMessageEvent is the only path for | |
| 4162 // cross-process postMessages. | |
| 4163 | |
| 4164 // It is possible to get here on a swapped-out frame without a | |
| 4165 // |render_frame_proxy_|. This happens when: | |
| 4166 // - This process only has one active RenderView and is about to go away | |
| 4167 // (e.g., due to cross-process navigation). | |
| 4168 // - The top frame has a subframe with an unload handler. | |
| 4169 // - The subframe sends a postMessage to the top-level frame in its unload | |
| 4170 // handler. | |
| 4171 // See https://crbug.com/475651 for details. We return false here, since we | |
| 4172 // don't want to deliver the message to the new process in this case. | |
| 4173 if (!render_frame_proxy_) | |
| 4174 return false; | |
| 4175 | |
| 4176 render_frame_proxy_->postMessageEvent( | |
| 4177 source_frame, render_frame_proxy_->web_frame(), target_origin, event); | |
| 4178 return true; | |
| 4179 } | |
| 4180 | |
| 4181 blink::WebString RenderFrameImpl::userAgentOverride() { | 4147 blink::WebString RenderFrameImpl::userAgentOverride() { |
| 4182 if (!render_view_->webview() || !render_view_->webview()->mainFrame() || | 4148 if (!render_view_->webview() || !render_view_->webview()->mainFrame() || |
| 4183 render_view_->renderer_preferences_.user_agent_override.empty()) { | 4149 render_view_->renderer_preferences_.user_agent_override.empty()) { |
| 4184 return blink::WebString(); | 4150 return blink::WebString(); |
| 4185 } | 4151 } |
| 4186 | 4152 |
| 4187 // TODO(nasko): When the top-level frame is remote, there is no WebDataSource | 4153 // TODO(nasko): When the top-level frame is remote, there is no WebDataSource |
| 4188 // associated with it, so the checks below are not valid. Temporarily | 4154 // associated with it, so the checks below are not valid. Temporarily |
| 4189 // return early and fix properly as part of https://crbug.com/426555. | 4155 // return early and fix properly as part of https://crbug.com/426555. |
| 4190 if (render_view_->webview()->mainFrame()->isWebRemoteFrame()) | 4156 if (render_view_->webview()->mainFrame()->isWebRemoteFrame()) |
| (...skipping 1948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6139 // event target. Potentially a Pepper plugin will receive the event. | 6105 // event target. Potentially a Pepper plugin will receive the event. |
| 6140 // In order to tell whether a plugin gets the last mouse event and which it | 6106 // In order to tell whether a plugin gets the last mouse event and which it |
| 6141 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6107 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6142 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6108 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6143 // |pepper_last_mouse_event_target_|. | 6109 // |pepper_last_mouse_event_target_|. |
| 6144 pepper_last_mouse_event_target_ = nullptr; | 6110 pepper_last_mouse_event_target_ = nullptr; |
| 6145 #endif | 6111 #endif |
| 6146 } | 6112 } |
| 6147 | 6113 |
| 6148 } // namespace content | 6114 } // namespace content |
| OLD | NEW |