| OLD | NEW |
| 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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 std::unique_ptr<base::ListValue> content; | 114 std::unique_ptr<base::ListValue> content; |
| 115 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { | 115 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { |
| 116 content.reset(new base::ListValue()); | 116 content.reset(new base::ListValue()); |
| 117 } else { | 117 } else { |
| 118 v8::Local<v8::Object> obj; | 118 v8::Local<v8::Object> obj; |
| 119 if (!args->GetNext(&obj)) { | 119 if (!args->GetNext(&obj)) { |
| 120 args->ThrowError(); | 120 args->ThrowError(); |
| 121 return; | 121 return; |
| 122 } | 122 } |
| 123 | 123 |
| 124 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 124 content = base::ListValue::From(V8ValueConverter::Create()->FromV8Value( |
| 125 content = base::ListValue::From( | 125 obj, frame->MainWorldScriptContext())); |
| 126 converter->FromV8Value(obj, frame->MainWorldScriptContext())); | |
| 127 DCHECK(content); | 126 DCHECK(content); |
| 128 } | 127 } |
| 129 | 128 |
| 130 // Send the message up to the browser. | 129 // Send the message up to the browser. |
| 131 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(), | 130 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(), |
| 132 frame->GetDocument().Url(), | 131 frame->GetDocument().Url(), |
| 133 message, *content)); | 132 message, *content)); |
| 134 } | 133 } |
| 135 | 134 |
| 136 // static | 135 // static |
| 137 std::string WebUIExtension::GetVariableValue(const std::string& name) { | 136 std::string WebUIExtension::GetVariableValue(const std::string& name) { |
| 138 blink::WebLocalFrame* frame; | 137 blink::WebLocalFrame* frame; |
| 139 RenderView* render_view; | 138 RenderView* render_view; |
| 140 if (!ShouldRespondToRequest(&frame, &render_view)) | 139 if (!ShouldRespondToRequest(&frame, &render_view)) |
| 141 return std::string(); | 140 return std::string(); |
| 142 | 141 |
| 143 return WebUIExtensionData::Get(render_view)->GetValue(name); | 142 return WebUIExtensionData::Get(render_view)->GetValue(name); |
| 144 } | 143 } |
| 145 | 144 |
| 146 } // namespace content | 145 } // namespace content |
| OLD | NEW |