OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_bindings.h" | 5 #include "content/renderer/web_ui_bindings.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/stl_util-inl.h" | 8 #include "base/stl_util-inl.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "content/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebURL.h" |
13 | 14 |
14 namespace { | 15 namespace { |
15 | 16 |
16 // Creates a Value which is a copy of the CppVariant |value|. All objects are | 17 // Creates a Value which is a copy of the CppVariant |value|. All objects are |
17 // treated as Lists for now since CppVariant does not distinguish arrays in any | 18 // treated as Lists for now since CppVariant does not distinguish arrays in any |
18 // convenient way and we currently have no need of non array objects. | 19 // convenient way and we currently have no need of non array objects. |
19 Value* CreateValueFromCppVariant(const CppVariant& value) { | 20 Value* CreateValueFromCppVariant(const CppVariant& value) { |
20 if (value.isBool()) | 21 if (value.isBool()) |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 if (args.size() == 2) { | 75 if (args.size() == 2) { |
75 if (!args[1].isObject()) | 76 if (!args[1].isObject()) |
76 return; | 77 return; |
77 | 78 |
78 content.reset(CreateValueFromCppVariant(args[1])); | 79 content.reset(CreateValueFromCppVariant(args[1])); |
79 CHECK(content->IsType(Value::TYPE_LIST)); | 80 CHECK(content->IsType(Value::TYPE_LIST)); |
80 } else { | 81 } else { |
81 content.reset(new ListValue()); | 82 content.reset(new ListValue()); |
82 } | 83 } |
83 | 84 |
84 // Retrieve the source frame's url | 85 // Retrieve the source document's url |
85 GURL source_url; | 86 GURL source_url; |
86 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); | 87 WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext(); |
87 if (webframe) | 88 if (frame) |
88 source_url = webframe->url(); | 89 source_url = frame->document().url(); |
89 | 90 |
90 // Send the message up to the browser. | 91 // Send the message up to the browser. |
91 sender()->Send(new ViewHostMsg_WebUISend( | 92 sender()->Send(new ViewHostMsg_WebUISend( |
92 routing_id(), | 93 routing_id(), |
93 source_url, | 94 source_url, |
94 message, | 95 message, |
95 *(static_cast<ListValue*>(content.get())))); | 96 *(static_cast<ListValue*>(content.get())))); |
96 } | 97 } |
97 | 98 |
98 void DOMBoundBrowserObject::SetProperty(const std::string& name, | 99 void DOMBoundBrowserObject::SetProperty(const std::string& name, |
99 const std::string& value) { | 100 const std::string& value) { |
100 CppVariant* cpp_value = new CppVariant; | 101 CppVariant* cpp_value = new CppVariant; |
101 cpp_value->Set(value); | 102 cpp_value->Set(value); |
102 BindProperty(name, cpp_value); | 103 BindProperty(name, cpp_value); |
103 properties_.push_back(cpp_value); | 104 properties_.push_back(cpp_value); |
104 } | 105 } |
OLD | NEW |