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

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

Issue 2931393003: [Content] Update V8ValueConverter::create to return a std::unique_ptr (Closed)
Patch Set: Created 3 years, 6 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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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/web_ui_extension.h" 5 #include "content/renderer/web_ui_extension.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 std::unique_ptr<base::ListValue> content; 115 std::unique_ptr<base::ListValue> content;
116 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { 116 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) {
117 content.reset(new base::ListValue()); 117 content.reset(new base::ListValue());
118 } else { 118 } else {
119 v8::Local<v8::Object> obj; 119 v8::Local<v8::Object> obj;
120 if (!args->GetNext(&obj)) { 120 if (!args->GetNext(&obj)) {
121 args->ThrowError(); 121 args->ThrowError();
122 return; 122 return;
123 } 123 }
124 124
125 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); 125 content = base::ListValue::From(V8ValueConverter::Create()->FromV8Value(
126 content = base::ListValue::From( 126 obj, frame->MainWorldScriptContext()));
127 converter->FromV8Value(obj, frame->MainWorldScriptContext()));
128 DCHECK(content); 127 DCHECK(content);
129 } 128 }
130 129
131 // Send the message up to the browser. 130 // Send the message up to the browser.
132 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(), 131 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(),
133 frame->GetDocument().Url(), 132 frame->GetDocument().Url(),
134 message, *content)); 133 message, *content));
135 } 134 }
136 135
137 // static 136 // static
138 std::string WebUIExtension::GetVariableValue(const std::string& name) { 137 std::string WebUIExtension::GetVariableValue(const std::string& name) {
139 blink::WebFrame* frame; 138 blink::WebFrame* frame;
140 RenderView* render_view; 139 RenderView* render_view;
141 if (!ShouldRespondToRequest(&frame, &render_view)) 140 if (!ShouldRespondToRequest(&frame, &render_view))
142 return std::string(); 141 return std::string();
143 142
144 return WebUIExtensionData::Get(render_view)->GetValue(name); 143 return WebUIExtensionData::Get(render_view)->GetValue(name);
145 } 144 }
146 145
147 } // namespace content 146 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698