Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(906)

Side by Side Diff: content/renderer/render_frame_impl.cc

Issue 2422793002: HTML MessagePort as mojo::MessagePipeHandle (Closed)
Patch Set: Rebase Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 2209 matching lines...) Expand 10 before | Expand all | Expand 10 after
2220 WebFrame* source_frame = NULL; 2220 WebFrame* source_frame = NULL;
2221 if (params.source_routing_id != MSG_ROUTING_NONE) { 2221 if (params.source_routing_id != MSG_ROUTING_NONE) {
2222 RenderFrameProxy* source_proxy = 2222 RenderFrameProxy* source_proxy =
2223 RenderFrameProxy::FromRoutingID(params.source_routing_id); 2223 RenderFrameProxy::FromRoutingID(params.source_routing_id);
2224 if (source_proxy) 2224 if (source_proxy)
2225 source_frame = source_proxy->web_frame(); 2225 source_frame = source_proxy->web_frame();
2226 } 2226 }
2227 2227
2228 // If the message contained MessagePorts, create the corresponding endpoints. 2228 // If the message contained MessagePorts, create the corresponding endpoints.
2229 blink::WebMessagePortChannelArray channels = 2229 blink::WebMessagePortChannelArray channels =
2230 WebMessagePortChannelImpl::CreatePorts( 2230 WebMessagePortChannelImpl::CreateFromMessagePorts(params.message_ports);
2231 params.message_ports, params.new_routing_ids,
2232 base::ThreadTaskRunnerHandle::Get().get());
2233 2231
2234 WebSerializedScriptValue serialized_script_value; 2232 WebSerializedScriptValue serialized_script_value;
2235 if (params.is_data_raw_string) { 2233 if (params.is_data_raw_string) {
2236 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 2234 v8::HandleScope handle_scope(blink::mainThreadIsolate());
2237 v8::Local<v8::Context> context = frame_->mainWorldScriptContext(); 2235 v8::Local<v8::Context> context = frame_->mainWorldScriptContext();
2238 v8::Context::Scope context_scope(context); 2236 v8::Context::Scope context_scope(context);
2239 V8ValueConverterImpl converter; 2237 V8ValueConverterImpl converter;
2240 converter.SetDateAllowed(true); 2238 converter.SetDateAllowed(true);
2241 converter.SetRegExpAllowed(true); 2239 converter.SetRegExpAllowed(true);
2242 std::unique_ptr<base::Value> value(new base::StringValue(params.data)); 2240 std::unique_ptr<base::Value> value(new base::StringValue(params.data));
2243 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(), 2241 v8::Local<v8::Value> result_value = converter.ToV8Value(value.get(),
2244 context); 2242 context);
2245 serialized_script_value = WebSerializedScriptValue::serialize(result_value); 2243 serialized_script_value = WebSerializedScriptValue::serialize(result_value);
2246 } else { 2244 } else {
2247 serialized_script_value = 2245 serialized_script_value =
2248 WebSerializedScriptValue::fromString(WebString::fromUTF16(params.data)); 2246 WebSerializedScriptValue::fromString(WebString::fromUTF16(params.data));
2249 } 2247 }
2250 2248
2251 // We must pass in the target_origin to do the security check on this side, 2249 // We must pass in the target_origin to do the security check on this side,
2252 // since it may have changed since the original postMessage call was made. 2250 // since it may have changed since the original postMessage call was made.
2253 WebSecurityOrigin target_origin; 2251 WebSecurityOrigin target_origin;
2254 if (!params.target_origin.empty()) { 2252 if (!params.target_origin.empty()) {
2255 target_origin = WebSecurityOrigin::createFromString( 2253 target_origin = WebSecurityOrigin::createFromString(
2256 WebString::fromUTF16(params.target_origin)); 2254 WebString::fromUTF16(params.target_origin));
2257 } 2255 }
2258 2256
2259 WebDOMMessageEvent msg_event(serialized_script_value, 2257 WebDOMMessageEvent msg_event(serialized_script_value,
2260 WebString::fromUTF16(params.source_origin), 2258 WebString::fromUTF16(params.source_origin),
2261 source_frame, frame_->document(), channels); 2259 source_frame,
2260 frame_->document(),
2261 std::move(channels));
2262 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); 2262 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event);
2263 } 2263 }
2264 2264
2265 void RenderFrameImpl::OnReload(bool bypass_cache) { 2265 void RenderFrameImpl::OnReload(bool bypass_cache) {
2266 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache 2266 frame_->reload(bypass_cache ? WebFrameLoadType::ReloadBypassingCache
2267 : WebFrameLoadType::ReloadMainResource); 2267 : WebFrameLoadType::ReloadMainResource);
2268 } 2268 }
2269 2269
2270 void RenderFrameImpl::OnReloadLoFiImages() { 2270 void RenderFrameImpl::OnReloadLoFiImages() {
2271 previews_state_ = PREVIEWS_NO_TRANSFORM; 2271 previews_state_ = PREVIEWS_NO_TRANSFORM;
(...skipping 4557 matching lines...) Expand 10 before | Expand all | Expand 10 after
6829 // event target. Potentially a Pepper plugin will receive the event. 6829 // event target. Potentially a Pepper plugin will receive the event.
6830 // In order to tell whether a plugin gets the last mouse event and which it 6830 // In order to tell whether a plugin gets the last mouse event and which it
6831 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets 6831 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
6832 // the event, it will notify us via DidReceiveMouseEvent() and set itself as 6832 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
6833 // |pepper_last_mouse_event_target_|. 6833 // |pepper_last_mouse_event_target_|.
6834 pepper_last_mouse_event_target_ = nullptr; 6834 pepper_last_mouse_event_target_ = nullptr;
6835 #endif 6835 #endif
6836 } 6836 }
6837 6837
6838 } // namespace content 6838 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698