From f0b1f65341802ddb393fdc1c7b16ed2eb6971209 Mon Sep 17 00:00:00 2001 From: "jamiewalch@chromium.org" Date: Wed, 24 Jul 2013 10:01:20 +0000 Subject: Fix NPAPI and native messaging hosts to cope with NULL pairing registry. Since there are no Windows or Mac pairing registry delegates yet, the host plugin currently crashes when the web-app starts up on those platforms. Review URL: https://chromiumcodereview.appspot.com/19460020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@213381 0039d316-1c4b-4281-b951-d872f2087c98 --- remoting/host/plugin/host_script_object.cc | 33 +++++++++++++++++++--------- remoting/host/setup/native_messaging_host.cc | 31 ++++++++++++++++++-------- 2 files changed, 45 insertions(+), 19 deletions(-) (limited to 'remoting/host') diff --git a/remoting/host/plugin/host_script_object.cc b/remoting/host/plugin/host_script_object.cc index 8c03d8f..9b78eb3 100644 --- a/remoting/host/plugin/host_script_object.cc +++ b/remoting/host/plugin/host_script_object.cc @@ -1111,9 +1111,13 @@ bool HostNPScriptObject::ClearPairedClients(const NPVariant* args, } ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[0])); - pairing_registry_->ClearAllPairings( - base::Bind(&HostNPScriptObject::InvokeBooleanCallback, weak_ptr_, - callback_obj)); + if (pairing_registry_) { + pairing_registry_->ClearAllPairings( + base::Bind(&HostNPScriptObject::InvokeBooleanCallback, weak_ptr_, + callback_obj)); + } else { + InvokeBooleanCallback(callback_obj, false); + } return true; } @@ -1138,10 +1142,14 @@ bool HostNPScriptObject::DeletePairedClient(const NPVariant* args, std::string client_id = StringFromNPVariant(args[0]); ScopedRefNPObject callback_obj(ObjectFromNPVariant(args[1])); - pairing_registry_->DeletePairing( - client_id, - base::Bind(&HostNPScriptObject::InvokeBooleanCallback, - weak_ptr_, callback_obj)); + if (pairing_registry_) { + pairing_registry_->DeletePairing( + client_id, + base::Bind(&HostNPScriptObject::InvokeBooleanCallback, + weak_ptr_, callback_obj)); + } else { + InvokeBooleanCallback(callback_obj, false); + } return true; } @@ -1325,9 +1333,14 @@ bool HostNPScriptObject::GetPairedClients(const NPVariant* args, return false; } - pairing_registry_->GetAllPairings( - base::Bind(&HostNPScriptObject::InvokeGetPairedClientsCallback, - weak_ptr_, callback_obj)); + if (pairing_registry_) { + pairing_registry_->GetAllPairings( + base::Bind(&HostNPScriptObject::InvokeGetPairedClientsCallback, + weak_ptr_, callback_obj)); + } else { + scoped_ptr no_paired_clients(new base::ListValue); + InvokeGetPairedClientsCallback(callback_obj, no_paired_clients.Pass()); + } return true; } diff --git a/remoting/host/setup/native_messaging_host.cc b/remoting/host/setup/native_messaging_host.cc index 6218667..55d0020 100644 --- a/remoting/host/setup/native_messaging_host.cc +++ b/remoting/host/setup/native_messaging_host.cc @@ -150,9 +150,13 @@ bool NativeMessagingHost::ProcessHello( bool NativeMessagingHost::ProcessClearPairedClients( const base::DictionaryValue& message, scoped_ptr response) { - pairing_registry_->ClearAllPairings( - base::Bind(&NativeMessagingHost::SendBooleanResult, weak_ptr_, - base::Passed(&response))); + if (pairing_registry_) { + pairing_registry_->ClearAllPairings( + base::Bind(&NativeMessagingHost::SendBooleanResult, weak_ptr_, + base::Passed(&response))); + } else { + SendBooleanResult(response.Pass(), false); + } return true; } @@ -166,9 +170,13 @@ bool NativeMessagingHost::ProcessDeletePairedClient( return false; } - pairing_registry_->DeletePairing( - client_id, base::Bind(&NativeMessagingHost::SendBooleanResult, weak_ptr_, - base::Passed(&response))); + if (pairing_registry_) { + pairing_registry_->DeletePairing( + client_id, base::Bind(&NativeMessagingHost::SendBooleanResult, + weak_ptr_, base::Passed(&response))); + } else { + SendBooleanResult(response.Pass(), false); + } return true; } @@ -237,9 +245,14 @@ bool NativeMessagingHost::ProcessGetDaemonConfig( bool NativeMessagingHost::ProcessGetPairedClients( const base::DictionaryValue& message, scoped_ptr response) { - pairing_registry_->GetAllPairings( - base::Bind(&NativeMessagingHost::SendPairedClientsResponse, weak_ptr_, - base::Passed(&response))); + if (pairing_registry_) { + pairing_registry_->GetAllPairings( + base::Bind(&NativeMessagingHost::SendPairedClientsResponse, weak_ptr_, + base::Passed(&response))); + } else { + scoped_ptr no_paired_clients(new base::ListValue); + SendPairedClientsResponse(response.Pass(), no_paired_clients.Pass()); + } return true; } -- cgit v1.1