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

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

Issue 1852513003: Convert //android_webview to use std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: git is hard Created 4 years, 8 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
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 render_frame()->GetRenderView()->GetWebView()->mainFrame(); 50 render_frame()->GetRenderView()->GetWebView()->mainFrame();
51 if (main_frame == nullptr) { 51 if (main_frame == nullptr) {
52 return; 52 return;
53 } 53 }
54 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext(); 54 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext();
55 v8::Context::Scope context_scope(context); 55 v8::Context::Scope context_scope(context);
56 DCHECK(!context.IsEmpty()); 56 DCHECK(!context.IsEmpty());
57 WebSerializedScriptValue v = WebSerializedScriptValue::fromString(message); 57 WebSerializedScriptValue v = WebSerializedScriptValue::fromString(message);
58 v8::Local<v8::Value> v8value = v.deserialize(); 58 v8::Local<v8::Value> v8value = v.deserialize();
59 59
60 scoped_ptr<V8ValueConverter> converter; 60 std::unique_ptr<V8ValueConverter> converter;
61 converter.reset(V8ValueConverter::create()); 61 converter.reset(V8ValueConverter::create());
62 converter->SetDateAllowed(true); 62 converter->SetDateAllowed(true);
63 converter->SetRegExpAllowed(true); 63 converter->SetRegExpAllowed(true);
64 base::ListValue result; 64 base::ListValue result;
65 base::Value* value = converter->FromV8Value(v8value, context); 65 base::Value* value = converter->FromV8Value(v8value, context);
66 if (value) { 66 if (value) {
67 result.Append(value); 67 result.Append(value);
68 } 68 }
69 69
70 Send(new AwMessagePortHostMsg_ConvertedWebToAppMessage( 70 Send(new AwMessagePortHostMsg_ConvertedWebToAppMessage(
71 render_frame()->GetRoutingID(), message_port_id, result, 71 render_frame()->GetRoutingID(), message_port_id, result,
72 sent_message_port_ids)); 72 sent_message_port_ids));
73 } 73 }
74 74
75 void AwMessagePortClient::OnAppToWebMessage( 75 void AwMessagePortClient::OnAppToWebMessage(
76 int message_port_id, 76 int message_port_id,
77 const base::string16& message, 77 const base::string16& message,
78 const vector<int>& sent_message_port_ids) { 78 const vector<int>& sent_message_port_ids) {
79 v8::HandleScope handle_scope(blink::mainThreadIsolate()); 79 v8::HandleScope handle_scope(blink::mainThreadIsolate());
80 blink::WebFrame* main_frame = 80 blink::WebFrame* main_frame =
81 render_frame()->GetRenderView()->GetWebView()->mainFrame(); 81 render_frame()->GetRenderView()->GetWebView()->mainFrame();
82 if (main_frame == nullptr) { 82 if (main_frame == nullptr) {
83 return; 83 return;
84 } 84 }
85 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext(); 85 v8::Local<v8::Context> context = main_frame->mainWorldScriptContext();
86 v8::Context::Scope context_scope(context); 86 v8::Context::Scope context_scope(context);
87 DCHECK(!context.IsEmpty()); 87 DCHECK(!context.IsEmpty());
88 scoped_ptr<V8ValueConverter> converter; 88 std::unique_ptr<V8ValueConverter> converter;
89 converter.reset(V8ValueConverter::create()); 89 converter.reset(V8ValueConverter::create());
90 converter->SetDateAllowed(true); 90 converter->SetDateAllowed(true);
91 converter->SetRegExpAllowed(true); 91 converter->SetRegExpAllowed(true);
92 scoped_ptr<base::Value> value(new base::StringValue(message)); 92 std::unique_ptr<base::Value> value(new base::StringValue(message));
93 v8::Local<v8::Value> result_value = 93 v8::Local<v8::Value> result_value =
94 converter->ToV8Value(value.get(), context); 94 converter->ToV8Value(value.get(), context);
95 WebSerializedScriptValue serialized_script_value = 95 WebSerializedScriptValue serialized_script_value =
96 WebSerializedScriptValue::serialize(result_value); 96 WebSerializedScriptValue::serialize(result_value);
97 base::string16 result = serialized_script_value.toString(); 97 base::string16 result = serialized_script_value.toString();
98 Send(new AwMessagePortHostMsg_ConvertedAppToWebMessage( 98 Send(new AwMessagePortHostMsg_ConvertedAppToWebMessage(
99 render_frame()->GetRoutingID(), message_port_id, 99 render_frame()->GetRoutingID(), message_port_id,
100 result, sent_message_port_ids)); 100 result, sent_message_port_ids));
101 } 101 }
102 102
103 void AwMessagePortClient::OnClosePort(int message_port_id) { 103 void AwMessagePortClient::OnClosePort(int message_port_id) {
104 Send(new AwMessagePortHostMsg_ClosePortAck(render_frame()->GetRoutingID(), 104 Send(new AwMessagePortHostMsg_ClosePortAck(render_frame()->GetRoutingID(),
105 message_port_id)); 105 message_port_id));
106 } 106 }
107 107
108 } 108 }
OLDNEW
« no previous file with comments | « android_webview/renderer/aw_content_renderer_client.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698