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

Side by Side Diff: android_webview/renderer/aw_message_port_client.cc

Issue 956763002: Implement the close() API for Message ports (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "android_webview/renderer/aw_message_port_client.h" 5 #include "android_webview/renderer/aw_message_port_client.h"
6 6
7 #include "android_webview/common/aw_message_port_messages.h" 7 #include "android_webview/common/aw_message_port_messages.h"
8 #include "content/public/child/v8_value_converter.h" 8 #include "content/public/child/v8_value_converter.h"
9 #include "content/public/renderer/render_frame.h" 9 #include "content/public/renderer/render_frame.h"
10 #include "content/public/renderer/render_view.h" 10 #include "content/public/renderer/render_view.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 base::ListValue result; 63 base::ListValue result;
64 result.Append(converter->FromV8Value(v8value, context)); 64 result.Append(converter->FromV8Value(v8value, context));
65 Send(new AwMessagePortHostMsg_ConvertedWebToAppMessage( 65 Send(new AwMessagePortHostMsg_ConvertedWebToAppMessage(
66 render_frame()->GetRoutingID(), message_port_id, 66 render_frame()->GetRoutingID(), message_port_id,
67 result, sent_message_port_ids)); 67 result, sent_message_port_ids));
68 } 68 }
69 69
70 void AwMessagePortClient::OnAppToWebMessage( 70 void AwMessagePortClient::OnAppToWebMessage(
71 int message_port_id, 71 int message_port_id,
72 const base::string16& message, 72 const base::string16& message,
73 const vector<int>& sent_message_port_ids) { 73 const vector<int>& sent_message_port_ids,
74 bool close_port) {
74 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 75 v8::HandleScope handle_scope(blink::mainThreadIsolate());
75 blink::WebFrame* main_frame = 76 blink::WebFrame* main_frame =
76 render_frame()->GetRenderView()->GetWebView()->mainFrame(); 77 render_frame()->GetRenderView()->GetWebView()->mainFrame();
77 if (main_frame == nullptr) { 78 if (main_frame == nullptr) {
78 return; 79 return;
79 } 80 }
80 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext(); 81 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext();
81 v8::Context::Scope context_scope(context); 82 v8::Context::Scope context_scope(context);
82 DCHECK(!context.IsEmpty()); 83 DCHECK(!context.IsEmpty());
83 scoped_ptr<V8ValueConverter> converter; 84 scoped_ptr<V8ValueConverter> converter;
84 converter.reset(V8ValueConverter::create()); 85 converter.reset(V8ValueConverter::create());
85 converter->SetDateAllowed(true); 86 converter->SetDateAllowed(true);
86 converter->SetRegExpAllowed(true); 87 converter->SetRegExpAllowed(true);
87 scoped_ptr<base::Value> value(new base::StringValue(message)); 88 scoped_ptr<base::Value> value(new base::StringValue(message));
88 v8::Handle<v8::Value> result_value = converter->ToV8Value(value.get(), 89 v8::Handle<v8::Value> result_value = converter->ToV8Value(value.get(),
89 context); 90 context);
90 WebSerializedScriptValue serialized_script_value = 91 WebSerializedScriptValue serialized_script_value =
91 WebSerializedScriptValue::serialize(result_value); 92 WebSerializedScriptValue::serialize(result_value);
92 base::string16 result = serialized_script_value.toString(); 93 base::string16 result = serialized_script_value.toString();
93 Send(new AwMessagePortHostMsg_ConvertedAppToWebMessage( 94 Send(new AwMessagePortHostMsg_ConvertedAppToWebMessage(
94 render_frame()->GetRoutingID(), message_port_id, 95 render_frame()->GetRoutingID(), message_port_id,
95 result, sent_message_port_ids)); 96 result, sent_message_port_ids, close_port));
96 } 97 }
97 98
98 } 99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698