@@ -577,12 +577,18 @@ cdef public int CommandLineSwitches_GetInt(const char* key) except * with gil:
577577# is called. See Issue #73 in the CEF Python Issue Tracker.
578578
579579def Initialize (applicationSettings = None , commandLineSwitches = None , **kwargs ):
580+ # applicationSettings and commandLineSwitches argument
581+ # names are kept for backward compatibility.
582+ application_settings = applicationSettings
583+ command_line_switches = commandLineSwitches
580584
581585 # Alternative names for existing parameters
582586 if " settings" in kwargs:
583- applicationSettings = kwargs[" settings" ]
587+ assert not applicationSettings, " Bad arguments"
588+ application_settings = kwargs[" settings" ]
584589 if " switches" in kwargs:
585- commandLineSwitches = kwargs[" switches" ]
590+ assert not command_line_switches, " Bad arguments"
591+ command_line_switches = kwargs[" switches" ]
586592
587593 IF UNAME_SYSNAME == " Linux" :
588594 # Fix Issue #231 - Discovery of the "icudtl.dat" file fails on Linux.
@@ -595,16 +601,17 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
595601 or Debug(" ERROR: CefOverridePath failed" )
596602 # END IF UNAME_SYSNAME == "Linux":
597603
598- if not applicationSettings:
599- applicationSettings = {}
604+ if not application_settings:
605+ application_settings = {}
606+
600607 # Debug settings need to be set before Debug() is called
601608 # and before the CefPythonApp class is instantiated.
602609 global g_debug
603610 global g_debugFile
604- if " debug" in applicationSettings :
605- g_debug = bool (applicationSettings [" debug" ])
606- if " log_file" in applicationSettings :
607- g_debugFile = applicationSettings [" log_file" ]
611+ if " debug" in application_settings :
612+ g_debug = bool (application_settings [" debug" ])
613+ if " log_file" in application_settings :
614+ g_debugFile = application_settings [" log_file" ]
608615
609616 Debug(" Initialize() called" )
610617
@@ -617,65 +624,79 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
617624 # -------------------------------------------------------------------------
618625 # CEF Python only options - default values
619626
620- if " debug" not in applicationSettings :
621- applicationSettings [" debug" ] = False
622- if " log_severity" not in applicationSettings :
627+ if " debug" not in application_settings :
628+ application_settings [" debug" ] = False
629+ if " log_severity" not in application_settings :
623630 # By default show only errors. Don't show on Linux X server non-fatal
624631 # errors like "WARNING:x11_util.cc(1409)] X error received".
625- applicationSettings [" log_severity" ] = LOGSEVERITY_ERROR
626- if " string_encoding" not in applicationSettings :
627- applicationSettings [" string_encoding" ] = " utf-8"
628- if " unique_request_context_per_browser" not in applicationSettings :
629- applicationSettings [" unique_request_context_per_browser" ] = False
630- if " downloads_enabled" not in applicationSettings :
631- applicationSettings [" downloads_enabled" ] = True
632- if " remote_debugging_port" not in applicationSettings :
633- applicationSettings [" remote_debugging_port" ] = 0
634- if " auto_zooming" not in applicationSettings :
632+ application_settings [" log_severity" ] = LOGSEVERITY_ERROR
633+ if " string_encoding" not in application_settings :
634+ application_settings [" string_encoding" ] = " utf-8"
635+ if " unique_request_context_per_browser" not in application_settings :
636+ application_settings [" unique_request_context_per_browser" ] = False
637+ if " downloads_enabled" not in application_settings :
638+ application_settings [" downloads_enabled" ] = True
639+ if " remote_debugging_port" not in application_settings :
640+ application_settings [" remote_debugging_port" ] = 0
641+ if " auto_zooming" not in application_settings :
635642 IF UNAME_SYSNAME == " Windows" :
636643 if DpiAware.IsProcessDpiAware():
637- applicationSettings [" auto_zooming" ] = " system_dpi"
644+ application_settings [" auto_zooming" ] = " system_dpi"
638645
639646 # Paths
640647 cdef str module_dir = GetModuleDirectory()
641- if " locales_dir_path" not in applicationSettings:
648+ if platform.system() == " Darwin" :
649+ if " framework_dir_path" not in application_settings:
650+ application_settings[" framework_dir_path" ] = os.path.join(
651+ module_dir, " Chromium Embedded Framework.framework" )
652+ # Bug in CEF: CefSettings.framework_dir_path doesn't work.
653+ # Can be worked around by setting command line switch.
654+ if not command_line_switches:
655+ command_line_switches = {}
656+ if " framework-dir-path" not in command_line_switches:
657+ command_line_switches[" framework-dir-path" ] = \
658+ application_settings[" framework_dir_path" ]
659+ if " locales_dir_path" not in application_settings:
642660 if platform.system() != " Darwin" :
643- applicationSettings [" locales_dir_path" ] = os.path.join(
661+ application_settings [" locales_dir_path" ] = os.path.join(
644662 module_dir, " locales" )
645- if " resources_dir_path" not in applicationSettings :
646- applicationSettings [" resources_dir_path" ] = module_dir
663+ if " resources_dir_path" not in application_settings :
664+ application_settings [" resources_dir_path" ] = module_dir
647665 if platform.system() == " Darwin" :
648- pass # TODO: Check if this needs to be set in v56+
649- if " browser_subprocess_path" not in applicationSettings:
650- applicationSettings[" browser_subprocess_path" ] = os.path.join(
666+ # "framework_dir_path" will always be set, see code above.
667+ application_settings[" resources_dir_path" ] = os.path.join(
668+ application_settings[" framework_dir_path" ],
669+ " Resources" )
670+ if " browser_subprocess_path" not in application_settings:
671+ application_settings[" browser_subprocess_path" ] = os.path.join(
651672 module_dir, " subprocess" )
652673
653674 # Mouse context menu
654- if " context_menu" not in applicationSettings :
655- applicationSettings [" context_menu" ] = {}
675+ if " context_menu" not in application_settings :
676+ application_settings [" context_menu" ] = {}
656677 menuItems = [" enabled" , " navigation" , " print" , " view_source" ,
657678 " external_browser" , " devtools" ]
658679 for item in menuItems:
659- if item not in applicationSettings [" context_menu" ]:
660- applicationSettings [" context_menu" ][item] = True
680+ if item not in application_settings [" context_menu" ]:
681+ application_settings [" context_menu" ][item] = True
661682
662683 # Remote debugging port. If value is 0 we will generate a random
663684 # port. To disable remote debugging set value to -1.
664- if applicationSettings [" remote_debugging_port" ] == 0 :
685+ if application_settings [" remote_debugging_port" ] == 0 :
665686 # Generate a random port.
666- applicationSettings [" remote_debugging_port" ] = \
687+ application_settings [" remote_debugging_port" ] = \
667688 random.randint(49152 , 65535 )
668- elif applicationSettings [" remote_debugging_port" ] == - 1 :
689+ elif application_settings [" remote_debugging_port" ] == - 1 :
669690 # Disable remote debugging
670- applicationSettings [" remote_debugging_port" ] = 0
691+ application_settings [" remote_debugging_port" ] = 0
671692
672693 # -------------------------------------------------------------------------
673694
674695 # CEF options - default values.
675- if not " multi_threaded_message_loop" in applicationSettings :
676- applicationSettings [" multi_threaded_message_loop" ] = False
677- if not " single_process" in applicationSettings :
678- applicationSettings [" single_process" ] = False
696+ if not " multi_threaded_message_loop" in application_settings :
697+ application_settings [" multi_threaded_message_loop" ] = False
698+ if not " single_process" in application_settings :
699+ application_settings [" single_process" ] = False
679700
680701 cdef CefRefPtr[CefApp] cefApp = < CefRefPtr[CefApp]?> new CefPythonApp()
681702
@@ -698,21 +719,21 @@ def Initialize(applicationSettings=None, commandLineSwitches=None, **kwargs):
698719 # Make a copy as applicationSettings is a reference only
699720 # that might get destroyed later.
700721 global g_applicationSettings
701- for key in applicationSettings :
702- g_applicationSettings[key] = copy.deepcopy(applicationSettings [key])
722+ for key in application_settings :
723+ g_applicationSettings[key] = copy.deepcopy(application_settings [key])
703724
704725 cdef CefSettings cefApplicationSettings
705726 # No sandboxing for the subprocesses
706727 cefApplicationSettings.no_sandbox = 1
707- SetApplicationSettings(applicationSettings , & cefApplicationSettings)
728+ SetApplicationSettings(application_settings , & cefApplicationSettings)
708729
709- if commandLineSwitches :
730+ if command_line_switches :
710731 # Make a copy as commandLineSwitches is a reference only
711732 # that might get destroyed later.
712733 global g_commandLineSwitches
713- for key in commandLineSwitches :
734+ for key in command_line_switches :
714735 g_commandLineSwitches[key] = copy.deepcopy(
715- commandLineSwitches [key])
736+ command_line_switches [key])
716737
717738 # External message pump
718739 if GetAppSetting(" external_message_pump" )\
0 commit comments