mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	- Expose command line parsing support with a new CefCommandLine class (issue #422).
- cefclient: Add the ability to specify CefSettings and CefBrowserSettings values on the command line. git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@378 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
		
							
								
								
									
										213
									
								
								libcef_dll/cpptoc/command_line_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										213
									
								
								libcef_dll/cpptoc/command_line_cpptoc.cc
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,213 @@
 | 
			
		||||
// Copyright (c) 2011 The Chromium Embedded Framework Authors. All rights
 | 
			
		||||
// reserved. Use of this source code is governed by a BSD-style license that
 | 
			
		||||
// can be found in the LICENSE file.
 | 
			
		||||
//
 | 
			
		||||
// ---------------------------------------------------------------------------
 | 
			
		||||
//
 | 
			
		||||
// A portion of this file was generated by the CEF translator tool.  When
 | 
			
		||||
// making changes by hand only do so within the body of existing function
 | 
			
		||||
// implementations. See the translator.README.txt file in the tools directory
 | 
			
		||||
// for more information.
 | 
			
		||||
//
 | 
			
		||||
 | 
			
		||||
#include "libcef_dll/cpptoc/command_line_cpptoc.h"
 | 
			
		||||
#include "libcef_dll/transfer_util.h"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// GLOBAL FUNCTIONS - Body may be edited by hand.
 | 
			
		||||
 | 
			
		||||
CEF_EXPORT cef_command_line_t* cef_command_line_create()
 | 
			
		||||
{
 | 
			
		||||
  CefRefPtr<CefCommandLine> impl = CefCommandLine::CreateCommandLine();
 | 
			
		||||
  if(impl.get())
 | 
			
		||||
    return CefCommandLineCppToC::Wrap(impl);
 | 
			
		||||
  return NULL;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// MEMBER FUNCTIONS - Body may be edited by hand.
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_init_from_argv(struct _cef_command_line_t* self,
 | 
			
		||||
    int argc, const char* const* argv)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->InitFromArgv(argc, argv);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_init_from_string(
 | 
			
		||||
    struct _cef_command_line_t* self, const cef_string_t* command_line)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->InitFromString(CefString(command_line));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cef_string_userfree_t CEF_CALLBACK command_line_get_command_line_string(
 | 
			
		||||
    struct _cef_command_line_t* self)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  CefString str = CefCommandLineCppToC::Get(self)->GetCommandLineString();
 | 
			
		||||
  return str.DetachToUserFree();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cef_string_userfree_t CEF_CALLBACK command_line_get_program(
 | 
			
		||||
    struct _cef_command_line_t* self)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  CefString str = CefCommandLineCppToC::Get(self)->GetProgram();
 | 
			
		||||
  return str.DetachToUserFree();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_set_program(struct _cef_command_line_t* self,
 | 
			
		||||
    const cef_string_t* program)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->SetProgram(CefString(program));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK command_line_has_switches(struct _cef_command_line_t* self)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  return CefCommandLineCppToC::Get(self)->HasSwitches();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK command_line_has_switch(struct _cef_command_line_t* self,
 | 
			
		||||
    const cef_string_t* name)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(name);
 | 
			
		||||
  if (!self || !name)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  return CefCommandLineCppToC::Get(self)->HasSwitch(CefString(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
cef_string_userfree_t CEF_CALLBACK command_line_get_switch_value(
 | 
			
		||||
    struct _cef_command_line_t* self, const cef_string_t* name)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(name);
 | 
			
		||||
  if (!self || !name)
 | 
			
		||||
    return NULL;
 | 
			
		||||
 | 
			
		||||
  CefString str = CefCommandLineCppToC::Get(self)->GetSwitchValue(
 | 
			
		||||
      CefString(name));
 | 
			
		||||
  return str.DetachToUserFree();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_get_switches(struct _cef_command_line_t* self,
 | 
			
		||||
    cef_string_map_t switches)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(switches);
 | 
			
		||||
  if (!self || !switches)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLine::SwitchMap map;
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->GetSwitches(map);
 | 
			
		||||
  transfer_string_map_contents(map, switches);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_append_switch(struct _cef_command_line_t* self,
 | 
			
		||||
    const cef_string_t* name)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(name);
 | 
			
		||||
  if (!self || !name)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->AppendSwitch(CefString(name));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_append_switch_with_value(
 | 
			
		||||
    struct _cef_command_line_t* self, const cef_string_t* name,
 | 
			
		||||
    const cef_string_t* value)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(name);
 | 
			
		||||
  DCHECK(value);
 | 
			
		||||
  if (!self || !name || !value)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->AppendSwitchWithValue(CefString(name),
 | 
			
		||||
      CefString(value));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
int CEF_CALLBACK command_line_has_arguments(struct _cef_command_line_t* self)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return 0;
 | 
			
		||||
 | 
			
		||||
  return CefCommandLineCppToC::Get(self)->HasArguments();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_get_arguments(struct _cef_command_line_t* self,
 | 
			
		||||
    cef_string_list_t arguments)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  if (!self)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLine::ArgumentList list;
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->GetArguments(list);
 | 
			
		||||
  transfer_string_list_contents(list, arguments);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void CEF_CALLBACK command_line_append_argument(struct _cef_command_line_t* self,
 | 
			
		||||
    const cef_string_t* argument)
 | 
			
		||||
{
 | 
			
		||||
  DCHECK(self);
 | 
			
		||||
  DCHECK(argument);
 | 
			
		||||
  if (!self || !argument)
 | 
			
		||||
    return;
 | 
			
		||||
 | 
			
		||||
  CefCommandLineCppToC::Get(self)->AppendArgument(CefString(argument));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
// CONSTRUCTOR - Do not edit by hand.
 | 
			
		||||
 | 
			
		||||
CefCommandLineCppToC::CefCommandLineCppToC(CefCommandLine* cls)
 | 
			
		||||
    : CefCppToC<CefCommandLineCppToC, CefCommandLine, cef_command_line_t>(cls)
 | 
			
		||||
{
 | 
			
		||||
  struct_.struct_.init_from_argv = command_line_init_from_argv;
 | 
			
		||||
  struct_.struct_.init_from_string = command_line_init_from_string;
 | 
			
		||||
  struct_.struct_.get_command_line_string =
 | 
			
		||||
      command_line_get_command_line_string;
 | 
			
		||||
  struct_.struct_.get_program = command_line_get_program;
 | 
			
		||||
  struct_.struct_.set_program = command_line_set_program;
 | 
			
		||||
  struct_.struct_.has_switches = command_line_has_switches;
 | 
			
		||||
  struct_.struct_.has_switch = command_line_has_switch;
 | 
			
		||||
  struct_.struct_.get_switch_value = command_line_get_switch_value;
 | 
			
		||||
  struct_.struct_.get_switches = command_line_get_switches;
 | 
			
		||||
  struct_.struct_.append_switch = command_line_append_switch;
 | 
			
		||||
  struct_.struct_.append_switch_with_value =
 | 
			
		||||
      command_line_append_switch_with_value;
 | 
			
		||||
  struct_.struct_.has_arguments = command_line_has_arguments;
 | 
			
		||||
  struct_.struct_.get_arguments = command_line_get_arguments;
 | 
			
		||||
  struct_.struct_.append_argument = command_line_append_argument;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#ifndef NDEBUG
 | 
			
		||||
template<> long CefCppToC<CefCommandLineCppToC, CefCommandLine,
 | 
			
		||||
    cef_command_line_t>::DebugObjCt = 0;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										34
									
								
								libcef_dll/cpptoc/command_line_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										34
									
								
								libcef_dll/cpptoc/command_line_cpptoc.h
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,34 @@
 | 
			
		||||
// Copyright (c) 2011 The Chromium Embedded Framework 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 file was generated by the CEF translator tool and should not edited
 | 
			
		||||
// by hand. See the translator.README.txt file in the tools directory for
 | 
			
		||||
// more information.
 | 
			
		||||
//
 | 
			
		||||
#ifndef _COMMANDLINE_CPPTOC_H
 | 
			
		||||
#define _COMMANDLINE_CPPTOC_H
 | 
			
		||||
 | 
			
		||||
#ifndef BUILDING_CEF_SHARED
 | 
			
		||||
#pragma message("Warning: "__FILE__" may be accessed DLL-side only")
 | 
			
		||||
#else // BUILDING_CEF_SHARED
 | 
			
		||||
 | 
			
		||||
#include "include/cef.h"
 | 
			
		||||
#include "include/cef_capi.h"
 | 
			
		||||
#include "libcef_dll/cpptoc/cpptoc.h"
 | 
			
		||||
 | 
			
		||||
// Wrap a C++ class with a C structure.
 | 
			
		||||
// This class may be instantiated and accessed DLL-side only.
 | 
			
		||||
class CefCommandLineCppToC
 | 
			
		||||
    : public CefCppToC<CefCommandLineCppToC, CefCommandLine, cef_command_line_t>
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
  CefCommandLineCppToC(CefCommandLine* cls);
 | 
			
		||||
  virtual ~CefCommandLineCppToC() {}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
#endif // BUILDING_CEF_SHARED
 | 
			
		||||
#endif // _COMMANDLINE_CPPTOC_H
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user