diff options
author | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 02:48:12 +0000 |
---|---|---|
committer | wez@chromium.org <wez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-31 02:48:12 +0000 |
commit | 672646361b0ca337ec23a78e6bcc6df35a0ffc5f (patch) | |
tree | 1f40780e3c6852904affd97eac0b2f1c10033b17 /remoting | |
parent | ebba55ee23c936416f227af02160d17b364b8134 (diff) | |
download | chromium_src-672646361b0ca337ec23a78e6bcc6df35a0ffc5f.zip chromium_src-672646361b0ca337ec23a78e6bcc6df35a0ffc5f.tar.gz chromium_src-672646361b0ca337ec23a78e6bcc6df35a0ffc5f.tar.bz2 |
Remove legacy scriptable-object interface from client plugin.
BUG=130335
TEST=Manual verification of Chromoting client functionality, and PyAuto tests.
Review URL: https://chromiumcodereview.appspot.com/10454078
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139720 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting')
-rw-r--r-- | remoting/client/plugin/chromoting_instance.cc | 44 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_instance.h | 19 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_scriptable_object.cc | 471 | ||||
-rw-r--r-- | remoting/client/plugin/chromoting_scriptable_object.h | 216 | ||||
-rw-r--r-- | remoting/remoting.gyp | 2 |
5 files changed, 8 insertions, 744 deletions
diff --git a/remoting/client/plugin/chromoting_instance.cc b/remoting/client/plugin/chromoting_instance.cc index fec261e..dbb36027 100644 --- a/remoting/client/plugin/chromoting_instance.cc +++ b/remoting/client/plugin/chromoting_instance.cc @@ -31,7 +31,6 @@ #include "remoting/client/client_config.h" #include "remoting/client/chromoting_client.h" #include "remoting/client/frame_consumer_proxy.h" -#include "remoting/client/plugin/chromoting_scriptable_object.h" #include "remoting/client/plugin/pepper_input_handler.h" #include "remoting/client/plugin/pepper_port_allocator.h" #include "remoting/client/plugin/pepper_view.h" @@ -134,7 +133,7 @@ bool ChromotingInstance::ParseAuthMethods(const std::string& auth_methods_str, } ChromotingInstance::ChromotingInstance(PP_Instance pp_instance) - : pp::InstancePrivate(pp_instance), + : pp::Instance(pp_instance), initialized_(false), plugin_message_loop_( new PluginMessageLoopProxy(&plugin_thread_delegate_)), @@ -352,26 +351,11 @@ bool ChromotingInstance::HandleInputEvent(const pp::InputEvent& event) { return input_handler_->HandleInputEvent(event); } -pp::Var ChromotingInstance::GetInstanceObject() { - if (instance_object_.is_undefined()) { - ChromotingScriptableObject* object = - new ChromotingScriptableObject(this, plugin_message_loop_); - object->Init(); - - // The pp::Var takes ownership of object here. - instance_object_ = pp::VarPrivate(this, object); - } - - return instance_object_; -} - void ChromotingInstance::SetDesktopSize(int width, int height) { scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); data->SetInteger("width", width); data->SetInteger("height", height); PostChromotingMessage("onDesktopSize", data.Pass()); - - GetScriptableObject()->SetDesktopSize(width, height); } void ChromotingInstance::SetConnectionState( @@ -381,8 +365,6 @@ void ChromotingInstance::SetConnectionState( data->SetString("state", ConnectionStateToString(state)); data->SetString("error", ConnectionErrorToString(error)); PostChromotingMessage("onConnectionStatus", data.Pass()); - - GetScriptableObject()->SetConnectionStatus(state, error); } void ChromotingInstance::OnFirstFrameReceived() { @@ -390,17 +372,6 @@ void ChromotingInstance::OnFirstFrameReceived() { PostChromotingMessage("onFirstFrameReceived", data.Pass()); } -ChromotingScriptableObject* ChromotingInstance::GetScriptableObject() { - pp::VarPrivate object = GetInstanceObject(); - if (!object.is_undefined()) { - pp::deprecated::ScriptableObject* so = object.AsScriptableObject(); - DCHECK(so != NULL); - return static_cast<ChromotingScriptableObject*>(so); - } - LOG(ERROR) << "Unable to get ScriptableObject for Chromoting plugin."; - return NULL; -} - void ChromotingInstance::Connect(const ClientConfig& config) { DCHECK(plugin_message_loop_->BelongsToCurrentThread()); @@ -560,8 +531,6 @@ void ChromotingInstance::SendOutgoingIq(const std::string& iq) { scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); data->SetString("iq", iq); PostChromotingMessage("sendOutgoingIq", data.Pass()); - - GetScriptableObject()->SendIq(iq); } void ChromotingInstance::SendPerfStats() { @@ -682,14 +651,9 @@ void ChromotingInstance::ProcessLogToUI(const std::string& message) { // new tasks while we're in the middle of servicing a LOG call. This can // happen if the call to LogDebugInfo tries to LOG anything. g_logging_to_plugin = true; - ChromotingScriptableObject* scriptable_object = GetScriptableObject(); - if (scriptable_object) { - scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); - data->SetString("message", message); - PostChromotingMessage("logDebugMessage", data.Pass()); - - scriptable_object->LogDebugInfo(message); - } + scoped_ptr<base::DictionaryValue> data(new base::DictionaryValue()); + data->SetString("message", message); + PostChromotingMessage("logDebugMessage", data.Pass()); g_logging_to_plugin = false; } diff --git a/remoting/client/plugin/chromoting_instance.h b/remoting/client/plugin/chromoting_instance.h index a489bde..1bbaf7d 100644 --- a/remoting/client/plugin/chromoting_instance.h +++ b/remoting/client/plugin/chromoting_instance.h @@ -24,7 +24,7 @@ #undef PostMessage #endif -#include "ppapi/cpp/private/instance_private.h" +#include "ppapi/cpp/instance.h" #include "remoting/base/scoped_thread_proxy.h" #include "remoting/client/client_context.h" #include "remoting/client/key_event_mapper.h" @@ -52,7 +52,6 @@ class MouseInputFilter; } // namespace protocol class ChromotingClient; -class ChromotingScriptableObject; class ChromotingStats; class ClientContext; class FrameConsumerProxy; @@ -65,7 +64,7 @@ struct ClientConfig; class ChromotingInstance : public protocol::ClipboardStub, - public pp::InstancePrivate, + public pp::Instance, public base::SupportsWeakPtr<ChromotingInstance> { public: // These state values are duplicated in the JS code. Remember to @@ -105,7 +104,7 @@ class ChromotingInstance : // Backward-compatibility version used by for the ScriptableObject // interface. Should be updated whenever we remove support for // an older version of the API. - static const int kApiMinScriptableVersion = 2; + static const int kApiMinScriptableVersion = 5; // Helper method to parse authentication_methods parameter. static bool ParseAuthMethods(const std::string& auth_methods, @@ -122,9 +121,6 @@ class ChromotingInstance : virtual void HandleMessage(const pp::Var& message) OVERRIDE; virtual bool HandleInputEvent(const pp::InputEvent& event) OVERRIDE; - // pp::InstancePrivate interface. - virtual pp::Var GetInstanceObject() OVERRIDE; - // ClipboardStub implementation. virtual void InjectClipboardEvent(const protocol::ClipboardEvent& event) OVERRIDE; @@ -134,11 +130,8 @@ class ChromotingInstance : void SetConnectionState(ConnectionState state, ConnectionError error); void OnFirstFrameReceived(); - // Convenience wrapper to get the ChromotingScriptableObject. - ChromotingScriptableObject* GetScriptableObject(); - // Message handlers for messages that come from JavaScript. Called - // from HandleMessage() and ChromotingScriptableObject. + // from HandleMessage(). void Connect(const ClientConfig& config); void Disconnect(); void OnIncomingIq(const std::string& iq); @@ -221,10 +214,6 @@ class ChromotingInstance : // connection. scoped_refptr<PepperXmppProxy> xmpp_proxy_; - // JavaScript interface to control this instance. - // This wraps a ChromotingScriptableObject in a pp::Var. - pp::Var instance_object_; - scoped_ptr<ScopedThreadProxy> thread_proxy_; DISALLOW_COPY_AND_ASSIGN(ChromotingInstance); diff --git a/remoting/client/plugin/chromoting_scriptable_object.cc b/remoting/client/plugin/chromoting_scriptable_object.cc deleted file mode 100644 index 7e2de5e..0000000 --- a/remoting/client/plugin/chromoting_scriptable_object.cc +++ /dev/null @@ -1,471 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "remoting/client/plugin/chromoting_scriptable_object.h" - -#include "base/bind.h" -#include "base/callback.h" -#include "base/logging.h" -#include "base/message_loop_proxy.h" -#include "base/string_split.h" -#include "ppapi/cpp/private/var_private.h" -#include "remoting/base/auth_token_util.h" -#include "remoting/client/client_config.h" -#include "remoting/client/chromoting_stats.h" -#include "remoting/client/plugin/chromoting_instance.h" -#include "remoting/client/plugin/pepper_xmpp_proxy.h" - -using pp::Var; -using pp::VarPrivate; - -namespace remoting { - -namespace { - -const char kApiVersionAttribute[] = "apiVersion"; -const char kApiMinVersionAttribute[] = "apiMinVersion"; -const char kConnectionInfoUpdate[] = "connectionInfoUpdate"; -const char kDebugInfo[] = "debugInfo"; -const char kDesktopHeight[] = "desktopHeight"; -const char kDesktopWidth[] = "desktopWidth"; -const char kDesktopSizeUpdate[] = "desktopSizeUpdate"; -const char kSendIq[] = "sendIq"; -const char kStatusAttribute[] = "status"; -const char kErrorAttribute[] = "error"; -const char kVideoBandwidthAttribute[] = "videoBandwidth"; -const char kVideoFrameRateAttribute[] = "videoFrameRate"; -const char kVideoCaptureLatencyAttribute[] = "videoCaptureLatency"; -const char kVideoEncodeLatencyAttribute[] = "videoEncodeLatency"; -const char kVideoDecodeLatencyAttribute[] = "videoDecodeLatency"; -const char kVideoRenderLatencyAttribute[] = "videoRenderLatency"; -const char kRoundTripLatencyAttribute[] = "roundTripLatency"; - -} // namespace - -ChromotingScriptableObject::ChromotingScriptableObject( - ChromotingInstance* instance, base::MessageLoopProxy* plugin_message_loop) - : instance_(instance), - plugin_message_loop_(plugin_message_loop) { -} - -ChromotingScriptableObject::~ChromotingScriptableObject() { -} - -void ChromotingScriptableObject::Init() { - // Property addition order should match the interface description at the - // top of chromoting_scriptable_object.h. - - AddAttribute(kApiVersionAttribute, Var(ChromotingInstance::kApiVersion)); - - AddAttribute(kApiMinVersionAttribute, - Var(ChromotingInstance::kApiMinScriptableVersion)); - - // Connection status. - AddAttribute(kStatusAttribute, Var(0)); // STATUS_UNKNOWN - - // Connection status values. - // TODO(jamiewalch): Remove STATUS_UNKNOWN once all web-apps that might try - // to access it have been upgraded. - AddAttribute("STATUS_UNKNOWN", Var(0)); - AddAttribute("STATUS_CONNECTING", Var(ChromotingInstance::STATE_CONNECTING)); - AddAttribute("STATUS_INITIALIZING", - Var(ChromotingInstance::STATE_INITIALIZING)); - AddAttribute("STATUS_CONNECTED", Var(ChromotingInstance::STATE_CONNECTED)); - AddAttribute("STATUS_CLOSED", Var(ChromotingInstance::STATE_CLOSED)); - AddAttribute("STATUS_FAILED", Var(ChromotingInstance::STATE_FAILED)); - - // Connection error. - AddAttribute(kErrorAttribute, Var(ChromotingInstance::ERROR_NONE)); - - // Connection error values. - AddAttribute("ERROR_NONE", Var(ChromotingInstance::ERROR_NONE)); - AddAttribute("ERROR_HOST_IS_OFFLINE", - Var(ChromotingInstance::ERROR_HOST_IS_OFFLINE)); - AddAttribute("ERROR_SESSION_REJECTED", - Var(ChromotingInstance::ERROR_SESSION_REJECTED)); - AddAttribute("ERROR_INCOMPATIBLE_PROTOCOL", - Var(ChromotingInstance::ERROR_INCOMPATIBLE_PROTOCOL)); - AddAttribute("ERROR_FAILURE_NONE", - Var(ChromotingInstance::ERROR_NETWORK_FAILURE)); - - // Debug info to display. - AddAttribute(kConnectionInfoUpdate, Var()); - AddAttribute(kDebugInfo, Var()); - AddAttribute(kDesktopSizeUpdate, Var()); - AddAttribute(kSendIq, Var()); - AddAttribute(kDesktopWidth, Var(0)); - AddAttribute(kDesktopHeight, Var(0)); - - // Statistics. - AddAttribute(kVideoBandwidthAttribute, Var()); - AddAttribute(kVideoFrameRateAttribute, Var()); - AddAttribute(kVideoCaptureLatencyAttribute, Var()); - AddAttribute(kVideoEncodeLatencyAttribute, Var()); - AddAttribute(kVideoDecodeLatencyAttribute, Var()); - AddAttribute(kVideoRenderLatencyAttribute, Var()); - AddAttribute(kRoundTripLatencyAttribute, Var()); - - AddMethod("connect", &ChromotingScriptableObject::DoConnect); - AddMethod("disconnect", &ChromotingScriptableObject::DoDisconnect); - AddMethod("onIq", &ChromotingScriptableObject::DoOnIq); - AddMethod("releaseAllKeys", &ChromotingScriptableObject::DoReleaseAllKeys); - - // Older versions of the web app expect a setScaleToFit method. - AddMethod("setScaleToFit", &ChromotingScriptableObject::DoNothing); -} - -bool ChromotingScriptableObject::HasProperty(const Var& name, Var* exception) { - // TODO(ajwong): Check if all these name.is_string() sentinels are required. - if (!name.is_string()) { - *exception = Var("HasProperty expects a string for the name."); - return false; - } - - PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); - if (iter == property_names_.end()) { - return false; - } - - // TODO(ajwong): Investigate why ARM build breaks if you do: - // properties_[iter->second].method == NULL; - // Somehow the ARM compiler is thinking that the above is using NULL as an - // arithmetic expression. - return properties_[iter->second].method == 0; -} - -bool ChromotingScriptableObject::HasMethod(const Var& name, Var* exception) { - // TODO(ajwong): Check if all these name.is_string() sentinels are required. - if (!name.is_string()) { - *exception = Var("HasMethod expects a string for the name."); - return false; - } - - PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); - if (iter == property_names_.end()) { - return false; - } - - // See comment from HasProperty about why to use 0 instead of NULL here. - return properties_[iter->second].method != 0; -} - -Var ChromotingScriptableObject::GetProperty(const Var& name, Var* exception) { - // TODO(ajwong): Check if all these name.is_string() sentinels are required. - if (!name.is_string()) { - *exception = Var("GetProperty expects a string for the name."); - return Var(); - } - - PropertyNameMap::const_iterator iter = property_names_.find(name.AsString()); - - // No property found. - if (iter == property_names_.end()) { - return ScriptableObject::GetProperty(name, exception); - } - - // If this is a statistics attribute then return the value from - // ChromotingStats structure. - ChromotingStats* stats = instance_->GetStats(); - if (name.AsString() == kVideoBandwidthAttribute) - return stats ? stats->video_bandwidth()->Rate() : Var(); - if (name.AsString() == kVideoFrameRateAttribute) - return stats ? stats->video_frame_rate()->Rate() : Var(); - if (name.AsString() == kVideoCaptureLatencyAttribute) - return stats ? stats->video_capture_ms()->Average() : Var(); - if (name.AsString() == kVideoEncodeLatencyAttribute) - return stats ? stats->video_encode_ms()->Average() : Var(); - if (name.AsString() == kVideoDecodeLatencyAttribute) - return stats ? stats->video_decode_ms()->Average() : Var(); - if (name.AsString() == kVideoRenderLatencyAttribute) - return stats ? stats->video_paint_ms()->Average() : Var(); - if (name.AsString() == kRoundTripLatencyAttribute) - return stats ? stats->round_trip_ms()->Average() : Var(); - - // TODO(ajwong): This incorrectly return a null object if a function - // property is requested. - return properties_[iter->second].attribute; -} - -void ChromotingScriptableObject::GetAllPropertyNames( - std::vector<Var>* properties, - Var* exception) { - for (size_t i = 0; i < properties_.size(); i++) { - properties->push_back(Var(properties_[i].name)); - } -} - -void ChromotingScriptableObject::SetProperty(const Var& name, - const Var& value, - Var* exception) { - // TODO(ajwong): Check if all these name.is_string() sentinels are required. - if (!name.is_string()) { - *exception = Var("SetProperty expects a string for the name."); - return; - } - - // Not all properties are mutable. - std::string property_name = name.AsString(); - if (property_name != kConnectionInfoUpdate && - property_name != kDebugInfo && - property_name != kDesktopSizeUpdate && - property_name != kSendIq && - property_name != kDesktopWidth && - property_name != kDesktopHeight) { - *exception = - Var("Cannot set property " + property_name + " on this object."); - return; - } - - // Since we're whitelisting the property that are settable above, we can - // assume that the property exists in the map. - properties_[property_names_[property_name]].attribute = value; -} - -Var ChromotingScriptableObject::Call(const Var& method_name, - const std::vector<Var>& args, - Var* exception) { - PropertyNameMap::const_iterator iter = - property_names_.find(method_name.AsString()); - if (iter == property_names_.end()) { - return pp::deprecated::ScriptableObject::Call(method_name, args, exception); - } - - return (this->*(properties_[iter->second].method))(args, exception); -} - -void ChromotingScriptableObject::SetConnectionStatus( - ChromotingInstance::ConnectionState state, - ChromotingInstance::ConnectionError error) { - VLOG(1) << "Connection status is updated: " << state; - - bool signal = false; - - int status_index = property_names_[kStatusAttribute]; - if (properties_[status_index].attribute.AsInt() != state) { - properties_[status_index].attribute = Var(state); - signal = true; - } - - int error_index = property_names_[kErrorAttribute]; - if (properties_[error_index].attribute.AsInt() != error) { - properties_[error_index].attribute = Var(error); - signal = true; - } - - if (signal) { - plugin_message_loop_->PostTask( - FROM_HERE, base::Bind( - &ChromotingScriptableObject::DoSignalConnectionInfoChange, - AsWeakPtr(), state, error)); - } -} - -void ChromotingScriptableObject::LogDebugInfo(const std::string& info) { - Var exception; - VarPrivate cb = GetProperty(Var(kDebugInfo), &exception); - - if (!cb.is_undefined()) { - // Var() means call the object directly as a function rather than calling - // a method in the object. - cb.Call(Var(), Var(info), &exception); - - if (!exception.is_undefined()) { - LOG(WARNING) << "Exception when invoking debugInfo JS callback: " - << exception.DebugString(); - } - } -} - -void ChromotingScriptableObject::SetDesktopSize(int width, int height) { - int width_index = property_names_[kDesktopWidth]; - int height_index = property_names_[kDesktopHeight]; - - if (properties_[width_index].attribute.AsInt() != width || - properties_[height_index].attribute.AsInt() != height) { - properties_[width_index].attribute = Var(width); - properties_[height_index].attribute = Var(height); - plugin_message_loop_->PostTask( - FROM_HERE, base::Bind( - &ChromotingScriptableObject::DoSignalDesktopSizeChange, - AsWeakPtr())); - } - - VLOG(1) << "Update desktop size to: " << width << " x " << height; -} - -void ChromotingScriptableObject::SendIq(const std::string& message_xml) { - plugin_message_loop_->PostTask( - FROM_HERE, base::Bind( - &ChromotingScriptableObject::DoSendIq, AsWeakPtr(), message_xml)); -} - -void ChromotingScriptableObject::AddAttribute(const std::string& name, - const Var& attribute) { - property_names_[name] = properties_.size(); - properties_.push_back(PropertyDescriptor(name, attribute)); -} - -void ChromotingScriptableObject::AddMethod(const std::string& name, - MethodHandler handler) { - property_names_[name] = properties_.size(); - properties_.push_back(PropertyDescriptor(name, handler)); -} - -void ChromotingScriptableObject::DoSignalConnectionInfoChange(int state, - int error) { - Var exception; - VarPrivate cb = GetProperty(Var(kConnectionInfoUpdate), &exception); - - if (!cb.is_undefined()) { - // |this| must not be touched after Call() returns. - cb.Call(Var(), Var(state), Var(error), &exception); - - if (!exception.is_undefined()) - LOG(ERROR) << "Exception when invoking connectionInfoUpdate JS callback."; - } -} - -void ChromotingScriptableObject::DoSignalDesktopSizeChange() { - Var exception; - VarPrivate cb = GetProperty(Var(kDesktopSizeUpdate), &exception); - - if (!cb.is_undefined()) { - // |this| must not be touched after Call() returns. - cb.Call(Var(), &exception); - - if (!exception.is_undefined()) { - LOG(ERROR) << "Exception when invoking JS callback" - << exception.DebugString(); - } - } -} - -void ChromotingScriptableObject::DoSendIq(const std::string& message_xml) { - Var exception; - VarPrivate cb = GetProperty(Var(kSendIq), &exception); - - if (!cb.is_undefined()) { - // |this| must not be touched after Call() returns. - cb.Call(Var(), Var(message_xml), &exception); - - if (!exception.is_undefined()) - LOG(ERROR) << "Exception when invoking sendiq JS callback."; - } -} - -Var ChromotingScriptableObject::DoConnect(const std::vector<Var>& args, - Var* exception) { - // Parameter order is: - // host_jid - // host_public_key - // client_jid - // shared_secret - // authentication_methods - // authentication_tag - ClientConfig config; - - unsigned int arg = 0; - if (!args[arg].is_string()) { - *exception = Var("The host_jid must be a string."); - return Var(); - } - config.host_jid = args[arg++].AsString(); - - if (!args[arg].is_string()) { - *exception = Var("The host_public_key must be a string."); - return Var(); - } - config.host_public_key = args[arg++].AsString(); - - if (!args[arg].is_string()) { - *exception = Var("The client_jid must be a string."); - return Var(); - } - config.local_jid = args[arg++].AsString(); - - if (!args[arg].is_string()) { - *exception = Var("The shared_secret must be a string."); - return Var(); - } - config.shared_secret = args[arg++].AsString(); - - // Older versions of the webapp do not supply the following two - // parameters. - - // By default use V1 authentication. - config.use_v1_authenticator = true; - if (args.size() > arg) { - if (!args[arg].is_string()) { - *exception = Var("The authentication_methods must be a string."); - return Var(); - } - - if (!ChromotingInstance::ParseAuthMethods( - args[arg++].AsString(), &config)) { - *exception = Var("No valid authentication methods specified."); - return Var(); - } - } - - if (args.size() > arg) { - if (!args[arg].is_string()) { - *exception = Var("The authentication_tag must be a string."); - return Var(); - } - config.authentication_tag = args[arg++].AsString(); - } - - if (args.size() != arg) { - *exception = Var("Too many agruments passed to connect()."); - return Var(); - } - - VLOG(1) << "Connecting to host. " - << "client_jid: " << config.local_jid - << ", host_jid: " << config.host_jid; - instance_->Connect(config); - - return Var(); -} - -Var ChromotingScriptableObject::DoDisconnect(const std::vector<Var>& args, - Var* exception) { - VLOG(1) << "Disconnecting from host."; - instance_->Disconnect(); - return Var(); -} - -Var ChromotingScriptableObject::DoNothing(const std::vector<Var>& args, - Var* exception) { - return Var(); -} - -Var ChromotingScriptableObject::DoOnIq(const std::vector<Var>& args, - Var* exception) { - if (args.size() != 1) { - *exception = Var("Usage: onIq(response_xml)"); - return Var(); - } - - if (!args[0].is_string()) { - *exception = Var("response_xml must be a string."); - return Var(); - } - - instance_->OnIncomingIq(args[0].AsString()); - - return Var(); -} - -Var ChromotingScriptableObject::DoReleaseAllKeys( - const std::vector<pp::Var>& args, pp::Var* exception) { - if (args.size() != 0) { - *exception = Var("Usage: DoReleaseAllKeys()"); - return Var(); - } - instance_->ReleaseAllKeys(); - return Var(); -} - -} // namespace remoting diff --git a/remoting/client/plugin/chromoting_scriptable_object.h b/remoting/client/plugin/chromoting_scriptable_object.h deleted file mode 100644 index acb8d63..0000000 --- a/remoting/client/plugin/chromoting_scriptable_object.h +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright (c) 2012 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// This implements the JavaScript class entrypoint for the plugin instance. -// The Javascript API is defined as follows. -// -// interface ChromotingScriptableObject { -// -// // Chromoting session API version (for this plugin). -// // This is compared with the javascript API version to verify that they are -// // compatible. -// readonly attribute unsigned short apiVersion; -// -// // The oldest API version that we support. -// // This will differ from |apiVersion| if we decide to maintain backward -// // compatibility with older API versions. -// readonly attribute unsigned short apiMinVersion; -// -// // Connection status. -// readonly attribute unsigned short status; -// -// // Constants for connection status. -// const unsigned short STATUS_UNKNOWN; -// const unsigned short STATUS_CONNECTING; -// const unsigned short STATUS_INITIALIZING; -// const unsigned short STATUS_CONNECTED; -// const unsigned short STATUS_CLOSED; -// const unsigned short STATUS_FAILED; -// -// // Constants for connection errors. -// const unsigned short ERROR_NONE; -// const unsigned short ERROR_HOST_IS_OFFLINE; -// const unsigned short ERROR_SESSION_REJECTED; -// const unsigned short ERROR_INCOMPATIBLE_PROTOCOL; -// const unsigned short ERROR_NETWORK_FAILURE; -// -// // JS callback function so we can signal the JS UI when the connection -// // status has been updated. -// attribute Function connectionInfoUpdate; -// -// // JS callback function to call when there is new debug info to display -// // in the client UI. -// attribute Function debugInfo; -// -// attribute Function desktopSizeUpdate; -// -// // JS callback function to send an XMPP IQ stanza for performing the -// // signaling in a jingle connection. The callback function should be -// // of type void(string request_xml). -// attribute Function sendIq; -// -// // Dimension of the desktop area. -// readonly attribute int desktopWidth; -// readonly attribute int desktopHeight; -// -// // Statistics. -// // Video bandwidth, in bytes per second. -// readonly attribute float videoBandwidth; -// // Video frames received per second. -// readonly attribute float videoFrameRate; -// // Latency for capturing, in milliseconds. -// readonly attribute int videoCaptureLatency; -// // Latency for video decoding, in milliseconds. -// readonly attribute int videoDecodeLatency; -// // Latency for video encoding, in milliseconds. -// readonly attribute int videoEncodeLatency; -// // Latency for video rendering, in milliseconds. -// readonly attribute int videoRenderLatency; -// // Latency of input events, based on delay between sending an input event -// // and receiving the first video packet after the event was processed. -// readonly attribute int roundTripLatency; -// -// // Methods for establishing a Chromoting connection. -// // -// // sendIq must be set and responses to calls on sendIq must -// // be piped back into onIq(). -// // -// // Note that auth_token_with_service should be specified as -// // "auth_service:auth_token". For example, "oauth2:5/aBd123". -// void connect(string host_jid, string auth_token_with_service, -// optional string access_code); -// -// // Terminating a Chromoting connection. -// void disconnect(); -// -// // Method for setting scale-to-fit. -// void setScaleToFit(bool scale_to_fit); -// -// // Method for receiving an XMPP IQ stanza in response to a previous -// // sendIq() invocation. Other packets will be silently dropped. -// void onIq(string response_xml); -// -// // Method for releasing all keys to ensure a consistent host state. -// void releaseAllKeys(); -// } - -#ifndef REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ -#define REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ - -#include <map> -#include <string> -#include <vector> - -#include "base/memory/weak_ptr.h" -#include "ppapi/cpp/dev/scriptable_object_deprecated.h" -#include "ppapi/cpp/var.h" -#include "remoting/client/plugin/chromoting_instance.h" - -namespace base { -class MessageLoopProxy; -}; // namespace base - -namespace remoting { - -// TODO(sergeyu): Remove this class when migration to messaging -// interface is finished (crbug.com/86353). -class ChromotingScriptableObject - : public pp::deprecated::ScriptableObject, - public base::SupportsWeakPtr<ChromotingScriptableObject> { - public: - ChromotingScriptableObject( - ChromotingInstance* instance, - base::MessageLoopProxy* plugin_message_loop); - virtual ~ChromotingScriptableObject(); - - virtual void Init(); - - // Override the ScriptableObject functions. - virtual bool HasProperty(const pp::Var& name, pp::Var* exception) OVERRIDE; - virtual bool HasMethod(const pp::Var& name, pp::Var* exception) OVERRIDE; - virtual pp::Var GetProperty(const pp::Var& name, pp::Var* exception) OVERRIDE; - virtual void GetAllPropertyNames(std::vector<pp::Var>* properties, - pp::Var* exception) OVERRIDE; - virtual void SetProperty(const pp::Var& name, - const pp::Var& value, - pp::Var* exception) OVERRIDE; - virtual pp::Var Call(const pp::Var& method_name, - const std::vector<pp::Var>& args, - pp::Var* exception) OVERRIDE; - - void SetConnectionStatus(ChromotingInstance::ConnectionState state, - ChromotingInstance::ConnectionError error); - void LogDebugInfo(const std::string& info); - void SetDesktopSize(int width, int height); - - // Sends an IQ stanza, serialized as an xml string, into Javascript for - // handling. - void SendIq(const std::string& request_xml); - - private: - typedef std::map<std::string, int> PropertyNameMap; - typedef pp::Var (ChromotingScriptableObject::*MethodHandler)( - const std::vector<pp::Var>& args, pp::Var* exception); - struct PropertyDescriptor { - PropertyDescriptor(const std::string& n, const pp::Var& a) - : type(NONE), name(n), attribute(a), method(NULL) { - } - - PropertyDescriptor(const std::string& n, MethodHandler m) - : type(NONE), name(n), method(m) { - } - - enum Type { - NONE, - ATTRIBUTE, - METHOD, - } type; - - std::string name; - pp::Var attribute; - MethodHandler method; - }; - - // Routines to add new attribute, method properties. - void AddAttribute(const std::string& name, const pp::Var& attribute); - void AddMethod(const std::string& name, MethodHandler handler); - - void SignalConnectionInfoChange(int state, int error); - void SignalDesktopSizeChange(); - - // Calls to these methods are posted to the plugin thread so that we - // call JavaScript with clean stack. This is necessary because - // JavaScript event handlers may destroy the plugin. - void DoSignalConnectionInfoChange(int state, int error); - void DoSignalDesktopSizeChange(); - void DoSendIq(const std::string& message_xml); - - pp::Var DoConnect(const std::vector<pp::Var>& args, pp::Var* exception); - pp::Var DoDisconnect(const std::vector<pp::Var>& args, pp::Var* exception); - - // This method is used for legacy script APIs such as setScaleToFit. - pp::Var DoNothing(const std::vector<pp::Var>& args, pp::Var* exception); - - // This method is called by Javascript to provide responses to sendIq() - // requests. - pp::Var DoOnIq(const std::vector<pp::Var>& args, pp::Var* exception); - - // This method is called by Javascript when the plugin loses input focus to - // release all pressed keys. - pp::Var DoReleaseAllKeys(const std::vector<pp::Var>& args, - pp::Var* exception); - - PropertyNameMap property_names_; - std::vector<PropertyDescriptor> properties_; - - ChromotingInstance* instance_; - - scoped_refptr<base::MessageLoopProxy> plugin_message_loop_; - - DISALLOW_COPY_AND_ASSIGN(ChromotingScriptableObject); -}; - -} // namespace remoting - -#endif // REMOTING_CLIENT_PLUGIN_CHROMOTING_SCRIPTABLE_OBJECT_H_ diff --git a/remoting/remoting.gyp b/remoting/remoting.gyp index 2d4648b..eebfb79 100644 --- a/remoting/remoting.gyp +++ b/remoting/remoting.gyp @@ -787,8 +787,6 @@ 'sources': [ 'client/plugin/chromoting_instance.cc', 'client/plugin/chromoting_instance.h', - 'client/plugin/chromoting_scriptable_object.cc', - 'client/plugin/chromoting_scriptable_object.h', 'client/plugin/mac_key_event_processor.cc', 'client/plugin/mac_key_event_processor.h', 'client/plugin/pepper_entrypoints.cc', |