mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	- Add CefCommandLine::GetArgv method (issue #707).
git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@751 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
		| @@ -100,6 +100,13 @@ typedef struct _cef_command_line_t { | |||||||
|   /// |   /// | ||||||
|   void (CEF_CALLBACK *reset)(struct _cef_command_line_t* self); |   void (CEF_CALLBACK *reset)(struct _cef_command_line_t* self); | ||||||
|  |  | ||||||
|  |   /// | ||||||
|  |   // Retrieve the original command line string as a vector of strings. The argv | ||||||
|  |   // array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } | ||||||
|  |   /// | ||||||
|  |   void (CEF_CALLBACK *get_argv)(struct _cef_command_line_t* self, | ||||||
|  |       cef_string_list_t argv); | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   // Constructs and returns the represented command line string. Use this |   // Constructs and returns the represented command line string. Use this | ||||||
|   // function cautiously because quoting behavior is unclear. |   // function cautiously because quoting behavior is unclear. | ||||||
|   | |||||||
| @@ -113,6 +113,13 @@ class CefCommandLine : public virtual CefBase { | |||||||
|   /*--cef()--*/ |   /*--cef()--*/ | ||||||
|   virtual void Reset() =0; |   virtual void Reset() =0; | ||||||
|  |  | ||||||
|  |   /// | ||||||
|  |   // Retrieve the original command line string as a vector of strings. | ||||||
|  |   // The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* } | ||||||
|  |   /// | ||||||
|  |   /*--cef()--*/ | ||||||
|  |   virtual void GetArgv(std::vector<CefString>& argv) =0; | ||||||
|  |  | ||||||
|   /// |   /// | ||||||
|   // Constructs and returns the represented command line string. Use this method |   // Constructs and returns the represented command line string. Use this method | ||||||
|   // cautiously because quoting behavior is unclear. |   // cautiously because quoting behavior is unclear. | ||||||
|   | |||||||
| @@ -57,6 +57,14 @@ void CefCommandLineImpl::Reset() { | |||||||
|   const_cast<CommandLine::SwitchMap*>(&map)->clear(); |   const_cast<CommandLine::SwitchMap*>(&map)->clear(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void CefCommandLineImpl::GetArgv(std::vector<CefString>& argv) { | ||||||
|  |   CEF_VALUE_VERIFY_RETURN_VOID(false); | ||||||
|  |   const CommandLine::StringVector& cmd_argv = const_value().argv(); | ||||||
|  |   CommandLine::StringVector::const_iterator it = cmd_argv.begin(); | ||||||
|  |   for (; it != cmd_argv.end(); ++it) | ||||||
|  |     argv.push_back(*it); | ||||||
|  | } | ||||||
|  |  | ||||||
| CefString CefCommandLineImpl::GetCommandLineString() { | CefString CefCommandLineImpl::GetCommandLineString() { | ||||||
|   CEF_VALUE_VERIFY_RETURN(false, CefString()); |   CEF_VALUE_VERIFY_RETURN(false, CefString()); | ||||||
|   return const_value().GetCommandLineString(); |   return const_value().GetCommandLineString(); | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ class CefCommandLineImpl : public CefValueBase<CefCommandLine, CommandLine> { | |||||||
|   virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; |   virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; | ||||||
|   virtual void InitFromString(const CefString& command_line) OVERRIDE; |   virtual void InitFromString(const CefString& command_line) OVERRIDE; | ||||||
|   virtual void Reset() OVERRIDE; |   virtual void Reset() OVERRIDE; | ||||||
|  |   virtual void GetArgv(std::vector<CefString>& argv) OVERRIDE; | ||||||
|   virtual CefString GetCommandLineString() OVERRIDE; |   virtual CefString GetCommandLineString() OVERRIDE; | ||||||
|   virtual CefString GetProgram() OVERRIDE; |   virtual CefString GetProgram() OVERRIDE; | ||||||
|   virtual void SetProgram(const CefString& program) OVERRIDE; |   virtual void SetProgram(const CefString& program) OVERRIDE; | ||||||
|   | |||||||
| @@ -128,6 +128,31 @@ void CEF_CALLBACK command_line_reset(struct _cef_command_line_t* self) { | |||||||
|   CefCommandLineCppToC::Get(self)->Reset(); |   CefCommandLineCppToC::Get(self)->Reset(); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void CEF_CALLBACK command_line_get_argv(struct _cef_command_line_t* self, | ||||||
|  |     cef_string_list_t argv) { | ||||||
|  |   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||||
|  |  | ||||||
|  |   DCHECK(self); | ||||||
|  |   if (!self) | ||||||
|  |     return; | ||||||
|  |   // Verify param: argv; type: string_vec_byref | ||||||
|  |   DCHECK(argv); | ||||||
|  |   if (!argv) | ||||||
|  |     return; | ||||||
|  |  | ||||||
|  |   // Translate param: argv; type: string_vec_byref | ||||||
|  |   std::vector<CefString> argvList; | ||||||
|  |   transfer_string_list_contents(argv, argvList); | ||||||
|  |  | ||||||
|  |   // Execute | ||||||
|  |   CefCommandLineCppToC::Get(self)->GetArgv( | ||||||
|  |       argvList); | ||||||
|  |  | ||||||
|  |   // Restore param: argv; type: string_vec_byref | ||||||
|  |   cef_string_list_clear(argv); | ||||||
|  |   transfer_string_list_contents(argvList, argv); | ||||||
|  | } | ||||||
|  |  | ||||||
| cef_string_userfree_t CEF_CALLBACK command_line_get_command_line_string( | cef_string_userfree_t CEF_CALLBACK command_line_get_command_line_string( | ||||||
|     struct _cef_command_line_t* self) { |     struct _cef_command_line_t* self) { | ||||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING |   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||||
| @@ -361,6 +386,7 @@ CefCommandLineCppToC::CefCommandLineCppToC(CefCommandLine* cls) | |||||||
|   struct_.struct_.init_from_argv = command_line_init_from_argv; |   struct_.struct_.init_from_argv = command_line_init_from_argv; | ||||||
|   struct_.struct_.init_from_string = command_line_init_from_string; |   struct_.struct_.init_from_string = command_line_init_from_string; | ||||||
|   struct_.struct_.reset = command_line_reset; |   struct_.struct_.reset = command_line_reset; | ||||||
|  |   struct_.struct_.get_argv = command_line_get_argv; | ||||||
|   struct_.struct_.get_command_line_string = |   struct_.struct_.get_command_line_string = | ||||||
|       command_line_get_command_line_string; |       command_line_get_command_line_string; | ||||||
|   struct_.struct_.get_program = command_line_get_program; |   struct_.struct_.get_program = command_line_get_program; | ||||||
|   | |||||||
| @@ -136,6 +136,30 @@ void CefCommandLineCToCpp::Reset() { | |||||||
|   struct_->reset(struct_); |   struct_->reset(struct_); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void CefCommandLineCToCpp::GetArgv(std::vector<CefString>& argv) { | ||||||
|  |   if (CEF_MEMBER_MISSING(struct_, get_argv)) | ||||||
|  |     return; | ||||||
|  |  | ||||||
|  |   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||||
|  |  | ||||||
|  |   // Translate param: argv; type: string_vec_byref | ||||||
|  |   cef_string_list_t argvList = cef_string_list_alloc(); | ||||||
|  |   DCHECK(argvList); | ||||||
|  |   if (argvList) | ||||||
|  |     transfer_string_list_contents(argv, argvList); | ||||||
|  |  | ||||||
|  |   // Execute | ||||||
|  |   struct_->get_argv(struct_, | ||||||
|  |       argvList); | ||||||
|  |  | ||||||
|  |   // Restore param:argv; type: string_vec_byref | ||||||
|  |   if (argvList) { | ||||||
|  |     argv.clear(); | ||||||
|  |     transfer_string_list_contents(argvList, argv); | ||||||
|  |     cef_string_list_free(argvList); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| CefString CefCommandLineCToCpp::GetCommandLineString() { | CefString CefCommandLineCToCpp::GetCommandLineString() { | ||||||
|   if (CEF_MEMBER_MISSING(struct_, get_command_line_string)) |   if (CEF_MEMBER_MISSING(struct_, get_command_line_string)) | ||||||
|     return CefString(); |     return CefString(); | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ | |||||||
| #pragma message("Warning: "__FILE__" may be accessed wrapper-side only") | #pragma message("Warning: "__FILE__" may be accessed wrapper-side only") | ||||||
| #else  // USING_CEF_SHARED | #else  // USING_CEF_SHARED | ||||||
|  |  | ||||||
|  | #include <vector> | ||||||
| #include "include/cef_command_line.h" | #include "include/cef_command_line.h" | ||||||
| #include "include/capi/cef_command_line_capi.h" | #include "include/capi/cef_command_line_capi.h" | ||||||
| #include "libcef_dll/ctocpp/ctocpp.h" | #include "libcef_dll/ctocpp/ctocpp.h" | ||||||
| @@ -40,6 +41,7 @@ class CefCommandLineCToCpp | |||||||
|   virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; |   virtual void InitFromArgv(int argc, const char* const* argv) OVERRIDE; | ||||||
|   virtual void InitFromString(const CefString& command_line) OVERRIDE; |   virtual void InitFromString(const CefString& command_line) OVERRIDE; | ||||||
|   virtual void Reset() OVERRIDE; |   virtual void Reset() OVERRIDE; | ||||||
|  |   virtual void GetArgv(std::vector<CefString>& argv) OVERRIDE; | ||||||
|   virtual CefString GetCommandLineString() OVERRIDE; |   virtual CefString GetCommandLineString() OVERRIDE; | ||||||
|   virtual CefString GetProgram() OVERRIDE; |   virtual CefString GetProgram() OVERRIDE; | ||||||
|   virtual void SetProgram(const CefString& program) OVERRIDE; |   virtual void SetProgram(const CefString& program) OVERRIDE; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user