| 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 | 9 |
| 9 #include "base/values.h" | 10 #include "base/values.h" |
| 10 #include "content/common/view_messages.h" | 11 #include "content/common/view_messages.h" |
| 11 #include "content/public/child/v8_value_converter.h" | 12 #include "content/public/child/v8_value_converter.h" |
| 12 #include "content/public/common/bindings_policy.h" | 13 #include "content/public/common/bindings_policy.h" |
| 13 #include "content/public/common/url_constants.h" | 14 #include "content/public/common/url_constants.h" |
| 14 #include "content/public/renderer/chrome_object_extensions_utils.h" | 15 #include "content/public/renderer/chrome_object_extensions_utils.h" |
| 15 #include "content/public/renderer/render_thread.h" | 16 #include "content/public/renderer/render_thread.h" |
| 16 #include "content/public/renderer/render_view.h" | 17 #include "content/public/renderer/render_view.h" |
| 17 #include "content/renderer/web_ui_extension_data.h" | 18 #include "content/renderer/web_ui_extension_data.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { | 102 if (args->PeekNext().IsEmpty() || args->PeekNext()->IsUndefined()) { |
| 102 content.reset(new base::ListValue()); | 103 content.reset(new base::ListValue()); |
| 103 } else { | 104 } else { |
| 104 v8::Local<v8::Object> obj; | 105 v8::Local<v8::Object> obj; |
| 105 if (!args->GetNext(&obj)) { | 106 if (!args->GetNext(&obj)) { |
| 106 args->ThrowError(); | 107 args->ThrowError(); |
| 107 return; | 108 return; |
| 108 } | 109 } |
| 109 | 110 |
| 110 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); | 111 std::unique_ptr<V8ValueConverter> converter(V8ValueConverter::create()); |
| 111 | 112 content = base::ListValue::From( |
| 112 base::Value* value = | 113 converter->FromV8Value(obj, frame->mainWorldScriptContext())); |
| 113 converter->FromV8Value(obj, frame->mainWorldScriptContext()); | 114 DCHECK(content); |
| 114 base::ListValue* list = NULL; | |
| 115 value->GetAsList(&list); | |
| 116 DCHECK(list); | |
| 117 content.reset(list); | |
| 118 } | 115 } |
| 119 | 116 |
| 120 // Send the message up to the browser. | 117 // Send the message up to the browser. |
| 121 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(), | 118 render_view->Send(new ViewHostMsg_WebUISend(render_view->GetRoutingID(), |
| 122 frame->document().url(), | 119 frame->document().url(), |
| 123 message, | 120 message, |
| 124 *content)); | 121 *content)); |
| 125 } | 122 } |
| 126 | 123 |
| 127 // static | 124 // static |
| 128 std::string WebUIExtension::GetVariableValue(const std::string& name) { | 125 std::string WebUIExtension::GetVariableValue(const std::string& name) { |
| 129 blink::WebFrame* frame; | 126 blink::WebFrame* frame; |
| 130 RenderView* render_view; | 127 RenderView* render_view; |
| 131 if (!ShouldRespondToRequest(&frame, &render_view)) | 128 if (!ShouldRespondToRequest(&frame, &render_view)) |
| 132 return std::string(); | 129 return std::string(); |
| 133 | 130 |
| 134 return WebUIExtensionData::Get(render_view)->GetValue(name); | 131 return WebUIExtensionData::Get(render_view)->GetValue(name); |
| 135 } | 132 } |
| 136 | 133 |
| 137 } // namespace content | 134 } // namespace content |
| OLD | NEW |