| 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.h" | 8 #include "base/stl_util.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" |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 const std::string message = args[0].ToString(); | 70 const std::string message = args[0].ToString(); |
| 71 | 71 |
| 72 // If they've provided an optional message parameter, convert that into a | 72 // If they've provided an optional message parameter, convert that into a |
| 73 // Value to send to the browser process. | 73 // Value to send to the browser process. |
| 74 scoped_ptr<Value> content; | 74 scoped_ptr<Value> content; |
| 75 if (args.size() == 2) { | 75 if (args.size() == 2) { |
| 76 if (!args[1].isObject()) | 76 if (!args[1].isObject()) |
| 77 return; | 77 return; |
| 78 | 78 |
| 79 content.reset(CreateValueFromCppVariant(args[1])); | 79 content.reset(CreateValueFromCppVariant(args[1])); |
| 80 CHECK(content->AsList()); | 80 CHECK(content->IsType(Value::TYPE_LIST)); |
| 81 } else { | 81 } else { |
| 82 content.reset(new ListValue()); | 82 content.reset(new ListValue()); |
| 83 } | 83 } |
| 84 | 84 |
| 85 // Retrieve the source document's url | 85 // Retrieve the source document's url |
| 86 GURL source_url; | 86 GURL source_url; |
| 87 WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext(); | 87 WebKit::WebFrame* frame = WebKit::WebFrame::frameForCurrentContext(); |
| 88 if (frame) | 88 if (frame) |
| 89 source_url = frame->document().url(); | 89 source_url = frame->document().url(); |
| 90 | 90 |
| 91 // Send the message up to the browser. | 91 // Send the message up to the browser. |
| 92 sender()->Send(new ViewHostMsg_WebUISend( | 92 sender()->Send(new ViewHostMsg_WebUISend( |
| 93 routing_id(), | 93 routing_id(), |
| 94 source_url, | 94 source_url, |
| 95 message, | 95 message, |
| 96 *(static_cast<ListValue*>(content.get())))); | 96 *(static_cast<ListValue*>(content.get())))); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void DOMBoundBrowserObject::SetProperty(const std::string& name, | 99 void DOMBoundBrowserObject::SetProperty(const std::string& name, |
| 100 const std::string& value) { | 100 const std::string& value) { |
| 101 CppVariant* cpp_value = new CppVariant; | 101 CppVariant* cpp_value = new CppVariant; |
| 102 cpp_value->Set(value); | 102 cpp_value->Set(value); |
| 103 BindProperty(name, cpp_value); | 103 BindProperty(name, cpp_value); |
| 104 properties_.push_back(cpp_value); | 104 properties_.push_back(cpp_value); |
| 105 } | 105 } |
| OLD | NEW |