OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/renderer/external_host_bindings.h" | 5 #include "chrome/renderer/external_host_bindings.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/common/render_messages.h" | 8 #include "chrome/common/render_messages.h" |
9 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" | 9 #include "third_party/WebKit/WebKit/chromium/public/WebBindings.h" |
10 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" | 10 #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" |
11 | 11 |
12 using WebKit::WebBindings; | 12 using WebKit::WebBindings; |
13 | 13 |
14 ExternalHostBindings::ExternalHostBindings() : frame_(NULL) { | 14 ExternalHostBindings::ExternalHostBindings() : frame_(NULL) { |
15 BindMethod("postMessage", &ExternalHostBindings::postMessage); | 15 BindMethod("postMessage", &ExternalHostBindings::postMessage); |
16 BindProperty("onmessage", &on_message_handler_); | 16 BindProperty("onmessage", &on_message_handler_); |
17 } | 17 } |
18 | 18 |
| 19 ExternalHostBindings::~ExternalHostBindings() { |
| 20 } |
| 21 |
19 void ExternalHostBindings::postMessage( | 22 void ExternalHostBindings::postMessage( |
20 const CppArgumentList& args, CppVariant* result) { | 23 const CppArgumentList& args, CppVariant* result) { |
21 DCHECK(result); | 24 DCHECK(result); |
22 | 25 |
23 // We need at least one argument (message) and at most 2 arguments. | 26 // We need at least one argument (message) and at most 2 arguments. |
24 // Also, the first argument must be a string | 27 // Also, the first argument must be a string |
25 if (args.size() < 1 || args.size() > 2 || !args[0].isString()) { | 28 if (args.size() < 1 || args.size() > 2 || !args[0].isString()) { |
26 result->Set(false); | 29 result->Set(false); |
27 return; | 30 return; |
28 } | 31 } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 DCHECK(success == false); | 175 DCHECK(success == false); |
173 } else { | 176 } else { |
174 DCHECK(success != false); | 177 DCHECK(success != false); |
175 // Pass the ownership to the caller (don't call ReleaseVariantValue). | 178 // Pass the ownership to the caller (don't call ReleaseVariantValue). |
176 *message_event = result.value.objectValue; | 179 *message_event = result.value.objectValue; |
177 } | 180 } |
178 } | 181 } |
179 | 182 |
180 return success; | 183 return success; |
181 } | 184 } |
OLD | NEW |