summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/external_host_bindings.cc
diff options
context:
space:
mode:
authorjoshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 20:34:45 +0000
committerjoshia@google.com <joshia@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-08-21 20:34:45 +0000
commit18cb257530f2a7b6a5d8ce74d3486c1784fcdbf0 (patch)
treedaa421607577ba79de24e9d9d8c62f60dff60a29 /chrome/renderer/external_host_bindings.cc
parent8c026e7a5ab2077eb8381e7b79a78020624a5a64 (diff)
downloadchromium_src-18cb257530f2a7b6a5d8ce74d3486c1784fcdbf0.zip
chromium_src-18cb257530f2a7b6a5d8ce74d3486c1784fcdbf0.tar.gz
chromium_src-18cb257530f2a7b6a5d8ce74d3486c1784fcdbf0.tar.bz2
Code review changes. Incorporated all the suggestions from previous review.
One item not changed yet is to rename 'receiver' in ForwardMessageToExternalHost. The idea is to invoke receiver("message") at the other end. So for example if the args to ForwardMessageToExternalHost("hello", "world") then we will invoke a script hello("world") on the other side. 'receiver' doesn't really describe the first argument here so if there is a better suggestion, I would be happy to change it :) git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1176 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/external_host_bindings.cc')
-rw-r--r--chrome/renderer/external_host_bindings.cc32
1 files changed, 9 insertions, 23 deletions
diff --git a/chrome/renderer/external_host_bindings.cc b/chrome/renderer/external_host_bindings.cc
index ffcd5fd..9ff8a54 100644
--- a/chrome/renderer/external_host_bindings.cc
+++ b/chrome/renderer/external_host_bindings.cc
@@ -29,22 +29,16 @@
#include "chrome/renderer/external_host_bindings.h"
-#include "base/json_writer.h"
-#include "base/scoped_handle.h"
#include "base/values.h"
#include "chrome/common/render_messages.h"
-#include "chrome/common/stl_util-inl.h"
-ExternalHostBindings::ExternalHostBindings() : routing_id_(0), sender_(NULL) {
- BindMethod("postMessage", &ExternalHostBindings::postMessage);
+void ExternalHostBindings::BindMethods() {
+ BindMethod("ForwardMessageToExternalHost",
+ &ExternalHostBindings::ForwardMessageToExternalHost);
}
-ExternalHostBindings::~ExternalHostBindings() {
- STLDeleteContainerPointers(properties_.begin(), properties_.end());
-}
-
-void ExternalHostBindings::postMessage(const CppArgumentList& args,
- CppVariant* result) {
+void ExternalHostBindings::ForwardMessageToExternalHost(
+ const CppArgumentList& args, CppVariant* result) {
// We expect at least a string message identifier, and optionally take
// an object parameter. If we get anything else we bail.
if (args.size() < 2)
@@ -54,17 +48,9 @@ void ExternalHostBindings::postMessage(const CppArgumentList& args,
if (!args[0].isString() && !args[1].isString())
return;
- const std::string receiver = args[0].ToString();
- const std::string message = args[1].ToString();
-
- sender_->Send(
- new ViewHostMsg_ExternalHostMessage(routing_id_, receiver, message));
-}
+ const std::string& receiver = args[0].ToString();
+ const std::string& message = args[1].ToString();
-void ExternalHostBindings::SetProperty(const std::string& name,
- const std::string& value) {
- CppVariant* cpp_value = new CppVariant;
- cpp_value->Set(value);
- BindProperty(name, cpp_value);
- properties_.push_back(cpp_value);
+ sender()->Send(new ViewHostMsg_ForwardMessageToExternalHost(
+ routing_id(), receiver, message));
}