OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "chrome/renderer/extensions/miscellaneous_bindings.h" | 5 #include "chrome/renderer/extensions/miscellaneous_bindings.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 return v8::Undefined(); | 95 return v8::Undefined(); |
96 | 96 |
97 if (args.Length() >= 2 && args[0]->IsInt32() && args[1]->IsString()) { | 97 if (args.Length() >= 2 && args[0]->IsInt32() && args[1]->IsString()) { |
98 int port_id = args[0]->Int32Value(); | 98 int port_id = args[0]->Int32Value(); |
99 if (!HasPortData(port_id)) { | 99 if (!HasPortData(port_id)) { |
100 return v8::ThrowException(v8::Exception::Error( | 100 return v8::ThrowException(v8::Exception::Error( |
101 v8::String::New(kPortClosedError))); | 101 v8::String::New(kPortClosedError))); |
102 } | 102 } |
103 std::string message = *v8::String::Utf8Value(args[1]->ToString()); | 103 std::string message = *v8::String::Utf8Value(args[1]->ToString()); |
104 renderview->Send(new ExtensionHostMsg_PostMessage( | 104 renderview->Send(new ExtensionHostMsg_PostMessage( |
105 renderview->GetRoutingId(), port_id, message)); | 105 renderview->GetRoutingID(), port_id, message)); |
106 } | 106 } |
107 return v8::Undefined(); | 107 return v8::Undefined(); |
108 } | 108 } |
109 | 109 |
110 // Forcefully disconnects a port. | 110 // Forcefully disconnects a port. |
111 static v8::Handle<v8::Value> CloseChannel(const v8::Arguments& args) { | 111 static v8::Handle<v8::Value> CloseChannel(const v8::Arguments& args) { |
112 if (args.Length() >= 2 && args[0]->IsInt32() && args[1]->IsBoolean()) { | 112 if (args.Length() >= 2 && args[0]->IsInt32() && args[1]->IsBoolean()) { |
113 int port_id = args[0]->Int32Value(); | 113 int port_id = args[0]->Int32Value(); |
114 if (!HasPortData(port_id)) { | 114 if (!HasPortData(port_id)) { |
115 return v8::Undefined(); | 115 return v8::Undefined(); |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 arguments.push_back(v8::String::New(message.c_str(), message.size())); | 192 arguments.push_back(v8::String::New(message.c_str(), message.size())); |
193 arguments.push_back(port_id_handle); | 193 arguments.push_back(port_id_handle); |
194 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage", | 194 CHECK((*it)->CallChromeHiddenMethod("Port.dispatchOnMessage", |
195 arguments.size(), | 195 arguments.size(), |
196 &arguments[0], | 196 &arguments[0], |
197 NULL)); | 197 NULL)); |
198 } | 198 } |
199 } | 199 } |
200 | 200 |
201 } // namespace extension | 201 } // namespace extension |
OLD | NEW |