@@ -41,7 +41,7 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
4141 CefRefPtr<CefProcessMessage> message) OVERRIDE {
4242 std::string message_name = message->GetName ();
4343 CefRefPtr<CefListValue> argList = message->GetArgumentList ();
44- int32 callbackId;
44+ int32 callbackId = - 1 ;
4545 int32 error = NO_ERROR;
4646 CefRefPtr<CefProcessMessage> response =
4747 CefProcessMessage::Create (" invokeCallback" );
@@ -53,12 +53,13 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
5353 // argument0 - the id of this message. This id is passed back to the
5454 // render process in order to execute callbacks
5555 // argument1 - argumentN - the arguments for the function
56+ //
57+ // Note: Functions without callback can be specified, but they *cannot*
58+ // take any arguments.
5659
57- if (argList->GetSize () < 1 ) {
58- fprintf (stderr, " No callback id specified for function %s\n " , message_name.c_str ());
59- return false ;
60- }
61- callbackId = argList->GetInt (0 );
60+ // If we have any arguments, the first is the callbackId
61+ if (argList->GetSize () > 0 )
62+ callbackId = argList->GetInt (0 );
6263
6364 if (message_name == " ShowOpenDialog" ) {
6465 // Parameters:
@@ -212,17 +213,24 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
212213
213214 // No additional response args for this function
214215 }
216+ } else if (message_name == " ShowDeveloperTools" ) {
217+ // Parameters - none
218+
219+ handler->ShowDevTools (browser);
220+
215221 } else {
216222 fprintf (stderr, " Native function not implemented yet: %s\n " , message_name.c_str ());
217223 return false ;
218224 }
219225
220- // Set common response args (callbackId and error)
221- responseArgs->SetInt (0 , callbackId);
222- responseArgs->SetInt (1 , error);
223-
224- // Send response
225- browser->SendProcessMessage (PID_RENDERER, response);
226+ if (callbackId != -1 ) {
227+ // Set common response args (callbackId and error)
228+ responseArgs->SetInt (0 , callbackId);
229+ responseArgs->SetInt (1 , error);
230+
231+ // Send response
232+ browser->SendProcessMessage (PID_RENDERER, response);
233+ }
226234
227235 return true ;
228236 }
0 commit comments