mirror of
				https://bitbucket.org/chromiumembedded/cef
				synced 2025-06-05 21:39:12 +02:00 
			
		
		
		
	Remove geolocation API support (issue #2380)
This commit is contained in:
		
							
								
								
									
										9
									
								
								BUILD.gn
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								BUILD.gn
									
									
									
									
									
								
							| @@ -373,7 +373,6 @@ static_library("libcef_static") { | ||||
|     "libcef/browser/file_dialog_manager.h", | ||||
|     "libcef/browser/frame_host_impl.cc", | ||||
|     "libcef/browser/frame_host_impl.h", | ||||
|     "libcef/browser/geolocation_impl.cc", | ||||
|     "libcef/browser/image_impl.cc", | ||||
|     "libcef/browser/image_impl.h", | ||||
|     "libcef/browser/javascript_dialog_runner.h", | ||||
| @@ -442,12 +441,6 @@ static_library("libcef_static") { | ||||
|     "libcef/browser/osr/web_contents_view_osr.cc", | ||||
|     "libcef/browser/osr/web_contents_view_osr.h", | ||||
|     "libcef/browser/path_util_impl.cc", | ||||
|     "libcef/browser/permissions/permission_context.cc", | ||||
|     "libcef/browser/permissions/permission_context.h", | ||||
|     "libcef/browser/permissions/permission_manager.cc", | ||||
|     "libcef/browser/permissions/permission_manager.h", | ||||
|     "libcef/browser/permissions/permission_util.cc", | ||||
|     "libcef/browser/permissions/permission_util.h", | ||||
|     "libcef/browser/plugins/plugin_service_filter.cc", | ||||
|     "libcef/browser/plugins/plugin_service_filter.h", | ||||
|     "libcef/browser/prefs/browser_prefs.cc", | ||||
| @@ -696,8 +689,6 @@ static_library("libcef_static") { | ||||
|     "//content/public/utility", | ||||
|     "//crypto", | ||||
|     "//device/base", | ||||
|     "//device/geolocation", | ||||
|     "//device/geolocation/public/interfaces", | ||||
|     "//extensions/browser", | ||||
|     "//extensions/browser/api:api_registration", | ||||
|     "//extensions/common/api", | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| # by hand. See the translator.README.txt file in the tools directory for | ||||
| # more information. | ||||
| # | ||||
| # $hash=5f69924ad7517dee8adf933a7c013616ebb94c36$ | ||||
| # $hash=bede6f61d0f5b45669b8e924144e4200c41f869b$ | ||||
| # | ||||
|  | ||||
| { | ||||
| @@ -38,8 +38,6 @@ | ||||
|       'include/cef_find_handler.h', | ||||
|       'include/cef_focus_handler.h', | ||||
|       'include/cef_frame.h', | ||||
|       'include/cef_geolocation.h', | ||||
|       'include/cef_geolocation_handler.h', | ||||
|       'include/cef_image.h', | ||||
|       'include/cef_jsdialog_handler.h', | ||||
|       'include/cef_keyboard_handler.h', | ||||
| @@ -131,8 +129,6 @@ | ||||
|       'include/capi/cef_find_handler_capi.h', | ||||
|       'include/capi/cef_focus_handler_capi.h', | ||||
|       'include/capi/cef_frame_capi.h', | ||||
|       'include/capi/cef_geolocation_capi.h', | ||||
|       'include/capi/cef_geolocation_handler_capi.h', | ||||
|       'include/capi/cef_image_capi.h', | ||||
|       'include/capi/cef_jsdialog_handler_capi.h', | ||||
|       'include/capi/cef_keyboard_handler_capi.h', | ||||
| @@ -286,14 +282,8 @@ | ||||
|       'libcef_dll/ctocpp/focus_handler_ctocpp.h', | ||||
|       'libcef_dll/cpptoc/frame_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/frame_cpptoc.h', | ||||
|       'libcef_dll/cpptoc/geolocation_callback_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/geolocation_callback_cpptoc.h', | ||||
|       'libcef_dll/ctocpp/geolocation_handler_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/geolocation_handler_ctocpp.h', | ||||
|       'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h', | ||||
|       'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h', | ||||
|       'libcef_dll/cpptoc/image_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/image_cpptoc.h', | ||||
|       'libcef_dll/cpptoc/jsdialog_callback_cpptoc.cc', | ||||
| @@ -572,14 +562,8 @@ | ||||
|       'libcef_dll/cpptoc/focus_handler_cpptoc.h', | ||||
|       'libcef_dll/ctocpp/frame_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/frame_ctocpp.h', | ||||
|       'libcef_dll/ctocpp/geolocation_callback_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/geolocation_callback_ctocpp.h', | ||||
|       'libcef_dll/cpptoc/geolocation_handler_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/geolocation_handler_cpptoc.h', | ||||
|       'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h', | ||||
|       'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.cc', | ||||
|       'libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h', | ||||
|       'libcef_dll/ctocpp/image_ctocpp.cc', | ||||
|       'libcef_dll/ctocpp/image_ctocpp.h', | ||||
|       'libcef_dll/ctocpp/jsdialog_callback_ctocpp.cc', | ||||
|   | ||||
| @@ -442,7 +442,6 @@ | ||||
|       'tests/ceftests/extensions/view_unittest.cc', | ||||
|       'tests/ceftests/file_util_unittest.cc', | ||||
|       'tests/ceftests/frame_unittest.cc', | ||||
|       'tests/ceftests/geolocation_unittest.cc', | ||||
|       'tests/ceftests/image_unittest.cc', | ||||
|       'tests/ceftests/image_util.cc', | ||||
|       'tests/ceftests/image_util.h', | ||||
|   | ||||
| @@ -33,7 +33,7 @@ | ||||
| // by hand. See the translator.README.txt file in the tools directory for | ||||
| // more information. | ||||
| // | ||||
| // $hash=2a93a2e7a17c81d39ad1b8c1c1aa93d5d90b1100$ | ||||
| // $hash=1dbb0adf7ac5fd42b5a79d271834781664a7fd47$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CAPI_CEF_CLIENT_CAPI_H_ | ||||
| @@ -48,7 +48,6 @@ | ||||
| #include "include/capi/cef_drag_handler_capi.h" | ||||
| #include "include/capi/cef_find_handler_capi.h" | ||||
| #include "include/capi/cef_focus_handler_capi.h" | ||||
| #include "include/capi/cef_geolocation_handler_capi.h" | ||||
| #include "include/capi/cef_jsdialog_handler_capi.h" | ||||
| #include "include/capi/cef_keyboard_handler_capi.h" | ||||
| #include "include/capi/cef_life_span_handler_capi.h" | ||||
| @@ -115,13 +114,6 @@ typedef struct _cef_client_t { | ||||
|   struct _cef_focus_handler_t*(CEF_CALLBACK* get_focus_handler)( | ||||
|       struct _cef_client_t* self); | ||||
|  | ||||
|   /// | ||||
|   // Return the handler for geolocation permissions requests. If no handler is | ||||
|   // provided geolocation access will be denied by default. | ||||
|   /// | ||||
|   struct _cef_geolocation_handler_t*(CEF_CALLBACK* get_geolocation_handler)( | ||||
|       struct _cef_client_t* self); | ||||
|  | ||||
|   /// | ||||
|   // Return the handler for JavaScript dialogs. If no handler is provided the | ||||
|   // default implementation will be used. | ||||
|   | ||||
| @@ -1,79 +0,0 @@ | ||||
| // Copyright (c) 2018 Marshall A. Greenblatt. All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //    * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //    * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //    * Neither the name of Google Inc. nor the name Chromium Embedded | ||||
| // Framework nor the names of its contributors may be used to endorse | ||||
| // or promote products derived from this software without specific prior | ||||
| // written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| // | ||||
| // --------------------------------------------------------------------------- | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // $hash=2af1552c0d2dada94c325be8249bfd889b22ca58$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ | ||||
| #define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ | ||||
| #pragma once | ||||
|  | ||||
| #include "include/capi/cef_base_capi.h" | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
| /// | ||||
| // Implement this structure to receive geolocation updates. The functions of | ||||
| // this structure will be called on the browser process UI thread. | ||||
| /// | ||||
| typedef struct _cef_get_geolocation_callback_t { | ||||
|   /// | ||||
|   // Base structure. | ||||
|   /// | ||||
|   cef_base_ref_counted_t base; | ||||
|  | ||||
|   /// | ||||
|   // Called with the 'best available' location information or, if the location | ||||
|   // update failed, with error information. | ||||
|   /// | ||||
|   void(CEF_CALLBACK* on_location_update)( | ||||
|       struct _cef_get_geolocation_callback_t* self, | ||||
|       const struct _cef_geoposition_t* position); | ||||
| } cef_get_geolocation_callback_t; | ||||
|  | ||||
| /// | ||||
| // Request a one-time geolocation update. This function bypasses any user | ||||
| // permission checks so should only be used by code that is allowed to access | ||||
| // location information. | ||||
| /// | ||||
| CEF_EXPORT int cef_get_geolocation(cef_get_geolocation_callback_t* callback); | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif  // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_CAPI_H_ | ||||
| @@ -1,106 +0,0 @@ | ||||
| // Copyright (c) 2018 Marshall A. Greenblatt. All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //    * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //    * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //    * Neither the name of Google Inc. nor the name Chromium Embedded | ||||
| // Framework nor the names of its contributors may be used to endorse | ||||
| // or promote products derived from this software without specific prior | ||||
| // written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| // | ||||
| // --------------------------------------------------------------------------- | ||||
| // | ||||
| // 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. | ||||
| // | ||||
| // $hash=33573a1b0f1caa917899c087b9febe83c2cfd41f$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ | ||||
| #define CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ | ||||
| #pragma once | ||||
|  | ||||
| #include "include/capi/cef_base_capi.h" | ||||
| #include "include/capi/cef_browser_capi.h" | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| extern "C" { | ||||
| #endif | ||||
|  | ||||
| /// | ||||
| // Callback structure used for asynchronous continuation of geolocation | ||||
| // permission requests. | ||||
| /// | ||||
| typedef struct _cef_geolocation_callback_t { | ||||
|   /// | ||||
|   // Base structure. | ||||
|   /// | ||||
|   cef_base_ref_counted_t base; | ||||
|  | ||||
|   /// | ||||
|   // Call to allow or deny geolocation access. | ||||
|   /// | ||||
|   void(CEF_CALLBACK* cont)(struct _cef_geolocation_callback_t* self, int allow); | ||||
| } cef_geolocation_callback_t; | ||||
|  | ||||
| /// | ||||
| // Implement this structure to handle events related to geolocation permission | ||||
| // requests. The functions of this structure will be called on the browser | ||||
| // process UI thread. | ||||
| /// | ||||
| typedef struct _cef_geolocation_handler_t { | ||||
|   /// | ||||
|   // Base structure. | ||||
|   /// | ||||
|   cef_base_ref_counted_t base; | ||||
|  | ||||
|   /// | ||||
|   // Called when a page requests permission to access geolocation information. | ||||
|   // |requesting_url| is the URL requesting permission and |request_id| is the | ||||
|   // unique ID for the permission request. Return true (1) and call | ||||
|   // cef_geolocation_callback_t::cont() either in this function or at a later | ||||
|   // time to continue or cancel the request. Return false (0) to cancel the | ||||
|   // request immediately. | ||||
|   /// | ||||
|   int(CEF_CALLBACK* on_request_geolocation_permission)( | ||||
|       struct _cef_geolocation_handler_t* self, | ||||
|       struct _cef_browser_t* browser, | ||||
|       const cef_string_t* requesting_url, | ||||
|       int request_id, | ||||
|       struct _cef_geolocation_callback_t* callback); | ||||
|  | ||||
|   /// | ||||
|   // Called when a geolocation access request is canceled. |request_id| is the | ||||
|   // unique ID for the permission request. | ||||
|   /// | ||||
|   void(CEF_CALLBACK* on_cancel_geolocation_permission)( | ||||
|       struct _cef_geolocation_handler_t* self, | ||||
|       struct _cef_browser_t* browser, | ||||
|       int request_id); | ||||
| } cef_geolocation_handler_t; | ||||
|  | ||||
| #ifdef __cplusplus | ||||
| } | ||||
| #endif | ||||
|  | ||||
| #endif  // CEF_INCLUDE_CAPI_CEF_GEOLOCATION_HANDLER_CAPI_H_ | ||||
| @@ -46,7 +46,6 @@ | ||||
| #include "include/cef_drag_handler.h" | ||||
| #include "include/cef_find_handler.h" | ||||
| #include "include/cef_focus_handler.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "include/cef_jsdialog_handler.h" | ||||
| #include "include/cef_keyboard_handler.h" | ||||
| #include "include/cef_life_span_handler.h" | ||||
| @@ -108,15 +107,6 @@ class CefClient : public virtual CefBaseRefCounted { | ||||
|   /*--cef()--*/ | ||||
|   virtual CefRefPtr<CefFocusHandler> GetFocusHandler() { return NULL; } | ||||
|  | ||||
|   /// | ||||
|   // Return the handler for geolocation permissions requests. If no handler is | ||||
|   // provided geolocation access will be denied by default. | ||||
|   /// | ||||
|   /*--cef()--*/ | ||||
|   virtual CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() { | ||||
|     return NULL; | ||||
|   } | ||||
|  | ||||
|   /// | ||||
|   // Return the handler for JavaScript dialogs. If no handler is provided the | ||||
|   // default implementation will be used. | ||||
|   | ||||
| @@ -1,66 +0,0 @@ | ||||
| // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //    * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //    * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //    * Neither the name of Google Inc. nor the name Chromium Embedded | ||||
| // Framework nor the names of its contributors may be used to endorse | ||||
| // or promote products derived from this software without specific prior | ||||
| // written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| // | ||||
| // --------------------------------------------------------------------------- | ||||
| // | ||||
| // The contents of this file must follow a specific format in order to | ||||
| // support the CEF translator tool. See the translator.README.txt file in the | ||||
| // tools directory for more information. | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CEF_GEOLOCATION_H_ | ||||
| #define CEF_INCLUDE_CEF_GEOLOCATION_H_ | ||||
| #pragma once | ||||
|  | ||||
| #include "include/cef_base.h" | ||||
|  | ||||
| /// | ||||
| // Implement this interface to receive geolocation updates. The methods of this | ||||
| // class will be called on the browser process UI thread. | ||||
| /// | ||||
| /*--cef(source=client)--*/ | ||||
| class CefGetGeolocationCallback : public virtual CefBaseRefCounted { | ||||
|  public: | ||||
|   /// | ||||
|   // Called with the 'best available' location information or, if the location | ||||
|   // update failed, with error information. | ||||
|   /// | ||||
|   /*--cef()--*/ | ||||
|   virtual void OnLocationUpdate(const CefGeoposition& position) = 0; | ||||
| }; | ||||
|  | ||||
| /// | ||||
| // Request a one-time geolocation update. This function bypasses any user | ||||
| // permission checks so should only be used by code that is allowed to access | ||||
| // location information. | ||||
| /// | ||||
| /*--cef()--*/ | ||||
| bool CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback> callback); | ||||
|  | ||||
| #endif  // CEF_INCLUDE_CEF_GEOLOCATION_H_ | ||||
| @@ -1,92 +0,0 @@ | ||||
| // Copyright (c) 2012 Marshall A. Greenblatt. All rights reserved. | ||||
| // | ||||
| // Redistribution and use in source and binary forms, with or without | ||||
| // modification, are permitted provided that the following conditions are | ||||
| // met: | ||||
| // | ||||
| //    * Redistributions of source code must retain the above copyright | ||||
| // notice, this list of conditions and the following disclaimer. | ||||
| //    * Redistributions in binary form must reproduce the above | ||||
| // copyright notice, this list of conditions and the following disclaimer | ||||
| // in the documentation and/or other materials provided with the | ||||
| // distribution. | ||||
| //    * Neither the name of Google Inc. nor the name Chromium Embedded | ||||
| // Framework nor the names of its contributors may be used to endorse | ||||
| // or promote products derived from this software without specific prior | ||||
| // written permission. | ||||
| // | ||||
| // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||||
| // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||||
| // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||||
| // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||||
| // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||||
| // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||||
| // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||||
| // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| // | ||||
| // --------------------------------------------------------------------------- | ||||
| // | ||||
| // The contents of this file must follow a specific format in order to | ||||
| // support the CEF translator tool. See the translator.README.txt file in the | ||||
| // tools directory for more information. | ||||
| // | ||||
|  | ||||
| #ifndef CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ | ||||
| #define CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ | ||||
| #pragma once | ||||
|  | ||||
| #include "include/cef_base.h" | ||||
| #include "include/cef_browser.h" | ||||
|  | ||||
| /// | ||||
| // Callback interface used for asynchronous continuation of geolocation | ||||
| // permission requests. | ||||
| /// | ||||
| /*--cef(source=library)--*/ | ||||
| class CefGeolocationCallback : public virtual CefBaseRefCounted { | ||||
|  public: | ||||
|   /// | ||||
|   // Call to allow or deny geolocation access. | ||||
|   /// | ||||
|   /*--cef(capi_name=cont)--*/ | ||||
|   virtual void Continue(bool allow) = 0; | ||||
| }; | ||||
|  | ||||
| /// | ||||
| // Implement this interface to handle events related to geolocation permission | ||||
| // requests. The methods of this class will be called on the browser process UI | ||||
| // thread. | ||||
| /// | ||||
| /*--cef(source=client)--*/ | ||||
| class CefGeolocationHandler : public virtual CefBaseRefCounted { | ||||
|  public: | ||||
|   /// | ||||
|   // Called when a page requests permission to access geolocation information. | ||||
|   // |requesting_url| is the URL requesting permission and |request_id| is the | ||||
|   // unique ID for the permission request. Return true and call | ||||
|   // CefGeolocationCallback::Continue() either in this method or at a later | ||||
|   // time to continue or cancel the request. Return false to cancel the request | ||||
|   // immediately. | ||||
|   /// | ||||
|   /*--cef()--*/ | ||||
|   virtual bool OnRequestGeolocationPermission( | ||||
|       CefRefPtr<CefBrowser> browser, | ||||
|       const CefString& requesting_url, | ||||
|       int request_id, | ||||
|       CefRefPtr<CefGeolocationCallback> callback) { | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   /// | ||||
|   // Called when a geolocation access request is canceled. |request_id| is the | ||||
|   // unique ID for the permission request. | ||||
|   /// | ||||
|   /*--cef()--*/ | ||||
|   virtual void OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser, | ||||
|                                              int request_id) {} | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_INCLUDE_CEF_GEOLOCATION_HANDLER_H_ | ||||
| @@ -2046,74 +2046,6 @@ typedef enum { | ||||
|   FILE_DIALOG_HIDEREADONLY_FLAG = 0x02000000, | ||||
| } cef_file_dialog_mode_t; | ||||
|  | ||||
| /// | ||||
| // Geoposition error codes. | ||||
| /// | ||||
| typedef enum { | ||||
|   GEOPOSITON_ERROR_NONE = 0, | ||||
|   GEOPOSITON_ERROR_PERMISSION_DENIED, | ||||
|   GEOPOSITON_ERROR_POSITION_UNAVAILABLE, | ||||
|   GEOPOSITON_ERROR_TIMEOUT, | ||||
| } cef_geoposition_error_code_t; | ||||
|  | ||||
| /// | ||||
| // Structure representing geoposition information. The properties of this | ||||
| // structure correspond to those of the JavaScript Position object although | ||||
| // their types may differ. | ||||
| /// | ||||
| typedef struct _cef_geoposition_t { | ||||
|   /// | ||||
|   // Latitude in decimal degrees north (WGS84 coordinate frame). | ||||
|   /// | ||||
|   double latitude; | ||||
|  | ||||
|   /// | ||||
|   // Longitude in decimal degrees west (WGS84 coordinate frame). | ||||
|   /// | ||||
|   double longitude; | ||||
|  | ||||
|   /// | ||||
|   // Altitude in meters (above WGS84 datum). | ||||
|   /// | ||||
|   double altitude; | ||||
|  | ||||
|   /// | ||||
|   // Accuracy of horizontal position in meters. | ||||
|   /// | ||||
|   double accuracy; | ||||
|  | ||||
|   /// | ||||
|   // Accuracy of altitude in meters. | ||||
|   /// | ||||
|   double altitude_accuracy; | ||||
|  | ||||
|   /// | ||||
|   // Heading in decimal degrees clockwise from true north. | ||||
|   /// | ||||
|   double heading; | ||||
|  | ||||
|   /// | ||||
|   // Horizontal component of device velocity in meters per second. | ||||
|   /// | ||||
|   double speed; | ||||
|  | ||||
|   /// | ||||
|   // Time of position measurement in milliseconds since Epoch in UTC time. This | ||||
|   // is taken from the host computer's system clock. | ||||
|   /// | ||||
|   cef_time_t timestamp; | ||||
|  | ||||
|   /// | ||||
|   // Error code, see enum above. | ||||
|   /// | ||||
|   cef_geoposition_error_code_t error_code; | ||||
|  | ||||
|   /// | ||||
|   // Human-readable error message. | ||||
|   /// | ||||
|   cef_string_t error_message; | ||||
| } cef_geoposition_t; | ||||
|  | ||||
| /// | ||||
| // Print job color mode values. | ||||
| /// | ||||
|   | ||||
| @@ -832,37 +832,6 @@ struct CefCookieTraits { | ||||
| /// | ||||
| typedef CefStructBase<CefCookieTraits> CefCookie; | ||||
|  | ||||
| struct CefGeopositionTraits { | ||||
|   typedef cef_geoposition_t struct_type; | ||||
|  | ||||
|   static inline void init(struct_type* s) {} | ||||
|  | ||||
|   static inline void clear(struct_type* s) { | ||||
|     cef_string_clear(&s->error_message); | ||||
|   } | ||||
|  | ||||
|   static inline void set(const struct_type* src, | ||||
|                          struct_type* target, | ||||
|                          bool copy) { | ||||
|     target->latitude = src->latitude; | ||||
|     target->longitude = src->longitude; | ||||
|     target->altitude = src->altitude; | ||||
|     target->accuracy = src->accuracy; | ||||
|     target->altitude_accuracy = src->altitude_accuracy; | ||||
|     target->heading = src->heading; | ||||
|     target->speed = src->speed; | ||||
|     target->timestamp = src->timestamp; | ||||
|     target->error_code = src->error_code; | ||||
|     cef_string_set(src->error_message.str, src->error_message.length, | ||||
|                    &target->error_message, copy); | ||||
|   } | ||||
| }; | ||||
|  | ||||
| /// | ||||
| // Class representing a geoposition. | ||||
| /// | ||||
| typedef CefStructBase<CefGeopositionTraits> CefGeoposition; | ||||
|  | ||||
| struct CefCursorInfoTraits { | ||||
|   typedef cef_cursor_info_t struct_type; | ||||
|  | ||||
|   | ||||
| @@ -12,7 +12,6 @@ | ||||
| #include "libcef/browser/context.h" | ||||
| #include "libcef/browser/download_manager_delegate.h" | ||||
| #include "libcef/browser/extensions/extension_system.h" | ||||
| #include "libcef/browser/permissions/permission_manager.h" | ||||
| #include "libcef/browser/prefs/browser_prefs.h" | ||||
| #include "libcef/browser/request_context_impl.h" | ||||
| #include "libcef/browser/ssl_host_state_delegate.h" | ||||
| @@ -420,9 +419,7 @@ CefBrowserContextImpl::GetSSLHostStateDelegate() { | ||||
| } | ||||
|  | ||||
| content::PermissionManager* CefBrowserContextImpl::GetPermissionManager() { | ||||
|   if (!permission_manager_.get()) | ||||
|     permission_manager_.reset(new CefPermissionManager(this)); | ||||
|   return permission_manager_.get(); | ||||
|   return nullptr; | ||||
| } | ||||
|  | ||||
| content::BackgroundFetchDelegate* | ||||
|   | ||||
| @@ -121,7 +121,6 @@ class CefBrowserContextImpl : public CefBrowserContext, | ||||
|  | ||||
|   std::unique_ptr<CefDownloadManagerDelegate> download_manager_delegate_; | ||||
|   scoped_refptr<CefURLRequestContextGetterImpl> url_request_getter_; | ||||
|   std::unique_ptr<content::PermissionManager> permission_manager_; | ||||
|   std::unique_ptr<CefSSLHostStateDelegate> ssl_host_state_delegate_; | ||||
|   scoped_refptr<HostContentSettingsMap> host_content_settings_map_; | ||||
|   std::unique_ptr<visitedlink::VisitedLinkMaster> visitedlink_master_; | ||||
|   | ||||
| @@ -1,107 +0,0 @@ | ||||
| // Copyright (c) 2012 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. | ||||
|  | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "libcef/browser/context.h" | ||||
| #include "libcef/browser/thread_util.h" | ||||
| #include "libcef/common/time_util.h" | ||||
|  | ||||
| #include "base/logging.h" | ||||
| #include "device/geolocation/geolocation_provider.h" | ||||
| #include "device/geolocation/public/interfaces/geoposition.mojom.h" | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| class CefLocationRequest | ||||
|     : public base::RefCountedThreadSafe<CefLocationRequest> { | ||||
|  public: | ||||
|   explicit CefLocationRequest(CefRefPtr<CefGetGeolocationCallback> callback) | ||||
|       : callback_(callback) { | ||||
|     CEF_REQUIRE_UIT(); | ||||
|     geo_callback_ = base::Bind(&CefLocationRequest::OnLocationUpdate, this); | ||||
|     device::GeolocationProvider* provider = | ||||
|         device::GeolocationProvider::GetInstance(); | ||||
|     subscription_ = provider->AddLocationUpdateCallback(geo_callback_, true); | ||||
|     provider->UserDidOptIntoLocationServices(); | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   friend class base::RefCountedThreadSafe<CefLocationRequest>; | ||||
|  | ||||
|   ~CefLocationRequest() {} | ||||
|  | ||||
|   void OnLocationUpdate(const device::mojom::Geoposition& position) { | ||||
|     CEF_REQUIRE_UIT(); | ||||
|     if (callback_.get()) { | ||||
|       CefGeoposition cef_position; | ||||
|       SetPosition(position, cef_position); | ||||
|       callback_->OnLocationUpdate(cef_position); | ||||
|       callback_ = NULL; | ||||
|     } | ||||
|     subscription_.reset(); | ||||
|     geo_callback_.Reset(); | ||||
|   } | ||||
|  | ||||
|   void SetPosition(const device::mojom::Geoposition& source, | ||||
|                    CefGeoposition& target) { | ||||
|     target.latitude = source.latitude; | ||||
|     target.longitude = source.longitude; | ||||
|     target.altitude = source.altitude; | ||||
|     target.accuracy = source.accuracy; | ||||
|     target.altitude_accuracy = source.altitude_accuracy; | ||||
|     target.heading = source.heading; | ||||
|     target.speed = source.speed; | ||||
|     cef_time_from_basetime(source.timestamp, target.timestamp); | ||||
|  | ||||
|     switch (source.error_code) { | ||||
|       case device::mojom::Geoposition::ErrorCode::NONE: | ||||
|         target.error_code = GEOPOSITON_ERROR_NONE; | ||||
|         break; | ||||
|       case device::mojom::Geoposition::ErrorCode::PERMISSION_DENIED: | ||||
|         target.error_code = GEOPOSITON_ERROR_PERMISSION_DENIED; | ||||
|         break; | ||||
|       case device::mojom::Geoposition::ErrorCode::POSITION_UNAVAILABLE: | ||||
|         target.error_code = GEOPOSITON_ERROR_POSITION_UNAVAILABLE; | ||||
|         break; | ||||
|       case device::mojom::Geoposition::ErrorCode::TIMEOUT: | ||||
|         target.error_code = GEOPOSITON_ERROR_TIMEOUT; | ||||
|         break; | ||||
|     } | ||||
|  | ||||
|     CefString(&target.error_message) = source.error_message; | ||||
|   } | ||||
|  | ||||
|   CefRefPtr<CefGetGeolocationCallback> callback_; | ||||
|   device::GeolocationProvider::LocationUpdateCallback geo_callback_; | ||||
|   std::unique_ptr<device::GeolocationProvider::Subscription> subscription_; | ||||
|  | ||||
|   DISALLOW_COPY_AND_ASSIGN(CefLocationRequest); | ||||
| }; | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| bool CefGetGeolocation(CefRefPtr<CefGetGeolocationCallback> callback) { | ||||
|   if (!CONTEXT_STATE_VALID()) { | ||||
|     NOTREACHED() << "context not valid"; | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   if (!callback.get()) { | ||||
|     NOTREACHED() << "invalid parameter"; | ||||
|     return false; | ||||
|   } | ||||
|  | ||||
|   if (CEF_CURRENTLY_ON_UIT()) { | ||||
|     if (device::GeolocationProvider::GetInstance()) { | ||||
|       // Will be released after the callback executes. | ||||
|       new CefLocationRequest(callback); | ||||
|       return true; | ||||
|     } | ||||
|     return false; | ||||
|   } else { | ||||
|     CEF_POST_TASK(CEF_UIT, | ||||
|                   base::Bind(base::IgnoreResult(CefGetGeolocation), callback)); | ||||
|     return true; | ||||
|   } | ||||
| } | ||||
| @@ -1,250 +0,0 @@ | ||||
| // Copyright 2015 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. | ||||
|  | ||||
| #include "libcef/browser/permissions/permission_context.h" | ||||
|  | ||||
| #include "include/cef_client.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "libcef/browser/browser_context.h" | ||||
| #include "libcef/browser/browser_host_impl.h" | ||||
| #include "libcef/browser/permissions/permission_util.h" | ||||
| #include "libcef/browser/thread_util.h" | ||||
|  | ||||
| #include "components/content_settings/core/browser/host_content_settings_map.h" | ||||
| #include "content/public/browser/permission_type.h" | ||||
| #include "content/public/browser/web_contents.h" | ||||
| #include "content/public/common/origin_util.h" | ||||
| #include "device/geolocation/geolocation_provider.h" | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // Whether the permission should be restricted to secure origins. | ||||
| bool IsRestrictedToSecureOrigins(content::PermissionType permission) { | ||||
|   return false; | ||||
| } | ||||
|  | ||||
| class CefGeolocationCallbackImpl : public CefGeolocationCallback { | ||||
|  public: | ||||
|   typedef CefPermissionContext::PermissionDecidedCallback CallbackType; | ||||
|  | ||||
|   explicit CefGeolocationCallbackImpl(const CallbackType& callback) | ||||
|       : callback_(callback) {} | ||||
|  | ||||
|   void Continue(bool allow) override { | ||||
|     if (CEF_CURRENTLY_ON_UIT()) { | ||||
|       if (!callback_.is_null()) { | ||||
|         if (allow) { | ||||
|           device::GeolocationProvider::GetInstance() | ||||
|               ->UserDidOptIntoLocationServices(); | ||||
|         } | ||||
|  | ||||
|         callback_.Run(allow ? CONTENT_SETTING_ALLOW : CONTENT_SETTING_BLOCK); | ||||
|         callback_.Reset(); | ||||
|       } | ||||
|     } else { | ||||
|       CEF_POST_TASK(CEF_UIT, base::Bind(&CefGeolocationCallbackImpl::Continue, | ||||
|                                         this, allow)); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   void Disconnect() { callback_.Reset(); } | ||||
|  | ||||
|  private: | ||||
|   CallbackType callback_; | ||||
|  | ||||
|   IMPLEMENT_REFCOUNTING(CefGeolocationCallbackImpl); | ||||
|   DISALLOW_COPY_AND_ASSIGN(CefGeolocationCallbackImpl); | ||||
| }; | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| CefPermissionContext::CefPermissionContext(CefBrowserContext* profile) | ||||
|     : profile_(profile), weak_ptr_factory_(this) {} | ||||
|  | ||||
| bool CefPermissionContext::SupportsPermission( | ||||
|     content::PermissionType permission) { | ||||
|   // Only Geolocation permissions are currently supported. | ||||
|   return permission == content::PermissionType::GEOLOCATION; | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::RequestPermission( | ||||
|     content::PermissionType permission, | ||||
|     content::WebContents* web_contents, | ||||
|     const PermissionRequestID& id, | ||||
|     const GURL& requesting_frame, | ||||
|     const BrowserPermissionCallback& callback) { | ||||
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||||
|  | ||||
|   DecidePermission(permission, web_contents, id, requesting_frame.GetOrigin(), | ||||
|                    web_contents->GetLastCommittedURL().GetOrigin(), callback); | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::CancelPermissionRequest( | ||||
|     content::PermissionType permission, | ||||
|     content::WebContents* web_contents, | ||||
|     const PermissionRequestID& id) { | ||||
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||||
|   DCHECK(permission == content::PermissionType::GEOLOCATION); | ||||
|  | ||||
|   CefRefPtr<CefBrowserHostImpl> browser = | ||||
|       CefBrowserHostImpl::GetBrowserForContents(web_contents); | ||||
|   if (browser.get()) { | ||||
|     CefRefPtr<CefClient> client = browser->GetClient(); | ||||
|     if (client.get()) { | ||||
|       CefRefPtr<CefGeolocationHandler> handler = | ||||
|           client->GetGeolocationHandler(); | ||||
|       if (handler.get()) | ||||
|         handler->OnCancelGeolocationPermission(browser.get(), id.request_id()); | ||||
|     } | ||||
|   } | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::ResetPermission(content::PermissionType permission, | ||||
|                                            const GURL& requesting_origin, | ||||
|                                            const GURL& embedding_origin) { | ||||
|   profile_->GetHostContentSettingsMap()->SetContentSettingCustomScope( | ||||
|       ContentSettingsPattern::FromURLNoWildcard(requesting_origin), | ||||
|       ContentSettingsPattern::FromURLNoWildcard(embedding_origin), | ||||
|       permission_util::PermissionTypeToContentSetting(permission), | ||||
|       std::string(), CONTENT_SETTING_DEFAULT); | ||||
| } | ||||
|  | ||||
| ContentSetting CefPermissionContext::GetPermissionStatus( | ||||
|     content::PermissionType permission, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin) const { | ||||
|   if (IsRestrictedToSecureOrigins(permission) && | ||||
|       !content::IsOriginSecure(requesting_origin)) { | ||||
|     return CONTENT_SETTING_BLOCK; | ||||
|   } | ||||
|  | ||||
|   return profile_->GetHostContentSettingsMap()->GetContentSetting( | ||||
|       requesting_origin, embedding_origin, | ||||
|       permission_util::PermissionTypeToContentSetting(permission), | ||||
|       std::string()); | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::DecidePermission( | ||||
|     content::PermissionType permission, | ||||
|     content::WebContents* web_contents, | ||||
|     const PermissionRequestID& id, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin, | ||||
|     const BrowserPermissionCallback& callback) { | ||||
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||||
|  | ||||
|   if (!requesting_origin.is_valid() || !embedding_origin.is_valid()) { | ||||
|     NotifyPermissionSet(permission, id, requesting_origin, embedding_origin, | ||||
|                         callback, false /* persist */, CONTENT_SETTING_BLOCK); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   if (IsRestrictedToSecureOrigins(permission) && | ||||
|       !content::IsOriginSecure(requesting_origin)) { | ||||
|     NotifyPermissionSet(permission, id, requesting_origin, embedding_origin, | ||||
|                         callback, false /* persist */, CONTENT_SETTING_BLOCK); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   ContentSetting content_setting = | ||||
|       profile_->GetHostContentSettingsMap()->GetContentSetting( | ||||
|           requesting_origin, embedding_origin, | ||||
|           permission_util::PermissionTypeToContentSetting(permission), | ||||
|           std::string()); | ||||
|  | ||||
|   if (content_setting == CONTENT_SETTING_ALLOW || | ||||
|       content_setting == CONTENT_SETTING_BLOCK) { | ||||
|     NotifyPermissionSet(permission, id, requesting_origin, embedding_origin, | ||||
|                         callback, false /* persist */, content_setting); | ||||
|     return; | ||||
|   } | ||||
|  | ||||
|   QueryPermission(permission, id, requesting_origin, embedding_origin, | ||||
|                   base::Bind(&CefPermissionContext::NotifyPermissionSet, | ||||
|                              weak_ptr_factory_.GetWeakPtr(), permission, id, | ||||
|                              requesting_origin, embedding_origin, callback, | ||||
|                              false /* persist */)); | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::QueryPermission( | ||||
|     content::PermissionType permission, | ||||
|     const PermissionRequestID& id, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin, | ||||
|     const PermissionDecidedCallback& callback) { | ||||
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||||
|   DCHECK(permission == content::PermissionType::GEOLOCATION); | ||||
|  | ||||
|   bool proceed = false; | ||||
|  | ||||
|   CefRefPtr<CefBrowserHostImpl> browser = | ||||
|       CefBrowserHostImpl::GetBrowserForFrame(id.render_process_id(), | ||||
|                                              id.render_frame_id()); | ||||
|   if (browser.get()) { | ||||
|     CefRefPtr<CefClient> client = browser->GetClient(); | ||||
|     if (client.get()) { | ||||
|       CefRefPtr<CefGeolocationHandler> handler = | ||||
|           client->GetGeolocationHandler(); | ||||
|       if (handler.get()) { | ||||
|         CefRefPtr<CefGeolocationCallbackImpl> callbackImpl( | ||||
|             new CefGeolocationCallbackImpl(callback)); | ||||
|  | ||||
|         // Notify the handler. | ||||
|         proceed = handler->OnRequestGeolocationPermission( | ||||
|             browser.get(), requesting_origin.spec(), id.request_id(), | ||||
|             callbackImpl.get()); | ||||
|         if (!proceed) | ||||
|           callbackImpl->Disconnect(); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   if (!proceed) { | ||||
|     // Disallow geolocation access by default. | ||||
|     callback.Run(CONTENT_SETTING_BLOCK); | ||||
|   } | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::NotifyPermissionSet( | ||||
|     content::PermissionType permission, | ||||
|     const PermissionRequestID& id, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin, | ||||
|     const BrowserPermissionCallback& callback, | ||||
|     bool persist, | ||||
|     ContentSetting content_setting) { | ||||
|   DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | ||||
|  | ||||
|   if (persist) { | ||||
|     UpdateContentSetting(permission, requesting_origin, embedding_origin, | ||||
|                          content_setting); | ||||
|   } | ||||
|  | ||||
|   if (content_setting == CONTENT_SETTING_DEFAULT) { | ||||
|     content_setting = | ||||
|         profile_->GetHostContentSettingsMap()->GetDefaultContentSetting( | ||||
|             permission_util::PermissionTypeToContentSetting(permission), | ||||
|             nullptr); | ||||
|   } | ||||
|  | ||||
|   DCHECK_NE(content_setting, CONTENT_SETTING_DEFAULT); | ||||
|   callback.Run(content_setting); | ||||
| } | ||||
|  | ||||
| void CefPermissionContext::UpdateContentSetting( | ||||
|     content::PermissionType permission, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin, | ||||
|     ContentSetting content_setting) { | ||||
|   DCHECK_EQ(requesting_origin, requesting_origin.GetOrigin()); | ||||
|   DCHECK_EQ(embedding_origin, embedding_origin.GetOrigin()); | ||||
|   DCHECK(content_setting == CONTENT_SETTING_ALLOW || | ||||
|          content_setting == CONTENT_SETTING_BLOCK); | ||||
|  | ||||
|   profile_->GetHostContentSettingsMap()->SetContentSettingCustomScope( | ||||
|       ContentSettingsPattern::FromURLNoWildcard(requesting_origin), | ||||
|       ContentSettingsPattern::FromURLNoWildcard(embedding_origin), | ||||
|       permission_util::PermissionTypeToContentSetting(permission), | ||||
|       std::string(), content_setting); | ||||
| } | ||||
| @@ -1,96 +0,0 @@ | ||||
| // Copyright 2015 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. | ||||
|  | ||||
| #ifndef CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_H_ | ||||
| #define CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_H_ | ||||
|  | ||||
| #include "base/callback_forward.h" | ||||
| #include "base/macros.h" | ||||
| #include "base/memory/weak_ptr.h" | ||||
| #include "chrome/browser/permissions/permission_request_id.h" | ||||
| #include "components/content_settings/core/common/content_settings.h" | ||||
|  | ||||
| class CefBrowserContext; | ||||
|  | ||||
| namespace content { | ||||
| enum class PermissionType; | ||||
| class WebContents; | ||||
| };  // namespace content | ||||
|  | ||||
| // Based on chrome/browser/permissions/permission_context_base.h | ||||
| class CefPermissionContext { | ||||
|  public: | ||||
|   explicit CefPermissionContext(CefBrowserContext* profile); | ||||
|  | ||||
|   using BrowserPermissionCallback = base::Callback<void(ContentSetting)>; | ||||
|   using PermissionDecidedCallback = base::Callback<void(ContentSetting)>; | ||||
|  | ||||
|   // Returns true if support exists for querying the embedder about the | ||||
|   // specified permission type. | ||||
|   bool SupportsPermission(content::PermissionType permission); | ||||
|  | ||||
|   // The renderer is requesting permission to push messages. | ||||
|   // When the answer to a permission request has been determined, |callback| | ||||
|   // should be called with the result. | ||||
|   void RequestPermission(content::PermissionType permission, | ||||
|                          content::WebContents* web_contents, | ||||
|                          const PermissionRequestID& id, | ||||
|                          const GURL& requesting_frame, | ||||
|                          const BrowserPermissionCallback& callback); | ||||
|  | ||||
|   // Withdraw an existing permission request, no op if the permission request | ||||
|   // was already cancelled by some other means. | ||||
|   void CancelPermissionRequest(content::PermissionType permission, | ||||
|                                content::WebContents* web_contents, | ||||
|                                const PermissionRequestID& id); | ||||
|  | ||||
|   // Resets the permission to its default value. | ||||
|   void ResetPermission(content::PermissionType permission, | ||||
|                        const GURL& requesting_origin, | ||||
|                        const GURL& embedding_origin); | ||||
|  | ||||
|   // Returns whether the permission has been granted, denied... | ||||
|   ContentSetting GetPermissionStatus(content::PermissionType permission, | ||||
|                                      const GURL& requesting_origin, | ||||
|                                      const GURL& embedding_origin) const; | ||||
|  | ||||
|  private: | ||||
|   // Decide whether the permission should be granted. | ||||
|   // Calls PermissionDecided if permission can be decided non-interactively, | ||||
|   // or NotifyPermissionSet if permission decided by presenting an infobar. | ||||
|   void DecidePermission(content::PermissionType permission, | ||||
|                         content::WebContents* web_contents, | ||||
|                         const PermissionRequestID& id, | ||||
|                         const GURL& requesting_origin, | ||||
|                         const GURL& embedding_origin, | ||||
|                         const BrowserPermissionCallback& callback); | ||||
|  | ||||
|   void QueryPermission(content::PermissionType permission, | ||||
|                        const PermissionRequestID& id, | ||||
|                        const GURL& requesting_origin, | ||||
|                        const GURL& embedding_origin, | ||||
|                        const PermissionDecidedCallback& callback); | ||||
|  | ||||
|   void NotifyPermissionSet(content::PermissionType permission, | ||||
|                            const PermissionRequestID& id, | ||||
|                            const GURL& requesting_origin, | ||||
|                            const GURL& embedding_origin, | ||||
|                            const BrowserPermissionCallback& callback, | ||||
|                            bool persist, | ||||
|                            ContentSetting content_setting); | ||||
|  | ||||
|   // Store the decided permission as a content setting. | ||||
|   void UpdateContentSetting(content::PermissionType permission, | ||||
|                             const GURL& requesting_origin, | ||||
|                             const GURL& embedding_origin, | ||||
|                             ContentSetting content_setting); | ||||
|  | ||||
|   CefBrowserContext* profile_; | ||||
|  | ||||
|   base::WeakPtrFactory<CefPermissionContext> weak_ptr_factory_; | ||||
|  | ||||
|   DISALLOW_COPY_AND_ASSIGN(CefPermissionContext); | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_CONTEXT_H_ | ||||
| @@ -1,356 +0,0 @@ | ||||
| // Copyright 2015 The Chromium Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style license that can be | ||||
| // found in the LICENSE file. | ||||
|  | ||||
| #include "libcef/browser/permissions/permission_manager.h" | ||||
|  | ||||
| #include "libcef/browser/browser_context.h" | ||||
| #include "libcef/browser/permissions/permission_util.h" | ||||
|  | ||||
| #include "base/callback.h" | ||||
| #include "components/content_settings/core/browser/host_content_settings_map.h" | ||||
| #include "content/public/browser/permission_type.h" | ||||
| #include "content/public/browser/render_frame_host.h" | ||||
| #include "content/public/browser/render_process_host.h" | ||||
| #include "content/public/browser/web_contents.h" | ||||
|  | ||||
| using blink::mojom::PermissionStatus; | ||||
| using content::PermissionType; | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // Helper method to convert ContentSetting to PermissionStatus. | ||||
| PermissionStatus ContentSettingToPermissionStatus(ContentSetting setting) { | ||||
|   switch (setting) { | ||||
|     case CONTENT_SETTING_ALLOW: | ||||
|     case CONTENT_SETTING_SESSION_ONLY: | ||||
|       return PermissionStatus::GRANTED; | ||||
|     case CONTENT_SETTING_BLOCK: | ||||
|       return PermissionStatus::DENIED; | ||||
|     case CONTENT_SETTING_ASK: | ||||
|       return PermissionStatus::ASK; | ||||
|     case CONTENT_SETTING_DETECT_IMPORTANT_CONTENT: | ||||
|     case CONTENT_SETTING_DEFAULT: | ||||
|     case CONTENT_SETTING_NUM_SETTINGS: | ||||
|       break; | ||||
|   } | ||||
|  | ||||
|   NOTREACHED(); | ||||
|   return PermissionStatus::DENIED; | ||||
| } | ||||
|  | ||||
| // Helper method to convert PermissionStatus to ContentSetting. | ||||
| ContentSetting PermissionStatusToContentSetting(PermissionStatus status) { | ||||
|   switch (status) { | ||||
|     case PermissionStatus::GRANTED: | ||||
|       return CONTENT_SETTING_ALLOW; | ||||
|     case PermissionStatus::DENIED: | ||||
|       return CONTENT_SETTING_BLOCK; | ||||
|     case PermissionStatus::ASK: | ||||
|       return CONTENT_SETTING_ASK; | ||||
|   } | ||||
|  | ||||
|   NOTREACHED(); | ||||
|   return CONTENT_SETTING_BLOCK; | ||||
| } | ||||
|  | ||||
| // Wrap a callback taking a PermissionStatus to pass it as a callback taking a | ||||
| // ContentSetting. | ||||
| void ContentSettingToPermissionStatusCallbackWrapper( | ||||
|     const base::Callback<void(PermissionStatus)>& callback, | ||||
|     ContentSetting setting) { | ||||
|   callback.Run(ContentSettingToPermissionStatus(setting)); | ||||
| } | ||||
|  | ||||
| // Returns whether the permission has a constant PermissionStatus value (i.e. | ||||
| // always approved or always denied). | ||||
| bool IsConstantPermission(PermissionType type) { | ||||
|   switch (type) { | ||||
|     case PermissionType::MIDI: | ||||
|       return true; | ||||
|     default: | ||||
|       return false; | ||||
|   } | ||||
| } | ||||
|  | ||||
| void PermissionRequestResponseCallbackWrapper( | ||||
|     const base::Callback<void(PermissionStatus)>& callback, | ||||
|     const std::vector<PermissionStatus>& vector) { | ||||
|   DCHECK_EQ(vector.size(), 1ul); | ||||
|   callback.Run(vector[0]); | ||||
| } | ||||
|  | ||||
| // Function used for handling permission types which do not change their | ||||
| // value i.e. they are always approved or always denied etc. | ||||
| // CONTENT_SETTING_DEFAULT is returned if the permission needs further handling. | ||||
| // This function should only be called when IsConstantPermission has returned | ||||
| // true for the PermissionType. | ||||
| ContentSetting GetContentSettingForConstantPermission(PermissionType type) { | ||||
|   DCHECK(IsConstantPermission(type)); | ||||
|   switch (type) { | ||||
|     case PermissionType::MIDI: | ||||
|       return CONTENT_SETTING_ALLOW; | ||||
|     default: | ||||
|       return CONTENT_SETTING_DEFAULT; | ||||
|   } | ||||
| } | ||||
|  | ||||
| PermissionStatus GetPermissionStatusForConstantPermission(PermissionType type) { | ||||
|   return ContentSettingToPermissionStatus( | ||||
|       GetContentSettingForConstantPermission(type)); | ||||
| } | ||||
|  | ||||
| }  // anonymous namespace | ||||
|  | ||||
| class CefPermissionManager::PendingRequest { | ||||
|  public: | ||||
|   PendingRequest( | ||||
|       content::RenderFrameHost* render_frame_host, | ||||
|       const std::vector<PermissionType> permissions, | ||||
|       const base::Callback<void(const std::vector<PermissionStatus>&)>& | ||||
|           callback) | ||||
|       : render_process_id_(render_frame_host->GetProcess()->GetID()), | ||||
|         render_frame_id_(render_frame_host->GetRoutingID()), | ||||
|         callback_(callback), | ||||
|         permissions_(permissions), | ||||
|         results_(permissions.size(), PermissionStatus::DENIED), | ||||
|         remaining_results_(permissions.size()) {} | ||||
|  | ||||
|   void SetPermissionStatus(int permission_id, PermissionStatus status) { | ||||
|     DCHECK(!IsComplete()); | ||||
|  | ||||
|     results_[permission_id] = status; | ||||
|     --remaining_results_; | ||||
|   } | ||||
|  | ||||
|   bool IsComplete() const { return remaining_results_ == 0; } | ||||
|  | ||||
|   int render_process_id() const { return render_process_id_; } | ||||
|   int render_frame_id() const { return render_frame_id_; } | ||||
|  | ||||
|   const base::Callback<void(const std::vector<PermissionStatus>&)> callback() | ||||
|       const { | ||||
|     return callback_; | ||||
|   } | ||||
|  | ||||
|   std::vector<PermissionType> permissions() const { return permissions_; } | ||||
|  | ||||
|   std::vector<PermissionStatus> results() const { return results_; } | ||||
|  | ||||
|  private: | ||||
|   int render_process_id_; | ||||
|   int render_frame_id_; | ||||
|   const base::Callback<void(const std::vector<PermissionStatus>&)> callback_; | ||||
|   std::vector<PermissionType> permissions_; | ||||
|   std::vector<PermissionStatus> results_; | ||||
|   size_t remaining_results_; | ||||
| }; | ||||
|  | ||||
| struct CefPermissionManager::Subscription { | ||||
|   PermissionType permission; | ||||
|   GURL requesting_origin; | ||||
|   GURL embedding_origin; | ||||
|   base::Callback<void(PermissionStatus)> callback; | ||||
|   ContentSetting current_value; | ||||
| }; | ||||
|  | ||||
| CefPermissionManager::CefPermissionManager(CefBrowserContext* profile) | ||||
|     : profile_(profile), context_(profile), weak_ptr_factory_(this) {} | ||||
|  | ||||
| CefPermissionManager::~CefPermissionManager() { | ||||
|   if (!subscriptions_.IsEmpty()) | ||||
|     profile_->GetHostContentSettingsMap()->RemoveObserver(this); | ||||
| } | ||||
|  | ||||
| int CefPermissionManager::RequestPermission( | ||||
|     PermissionType permission, | ||||
|     content::RenderFrameHost* render_frame_host, | ||||
|     const GURL& requesting_origin, | ||||
|     bool user_gesture, | ||||
|     const base::Callback<void(PermissionStatus)>& callback) { | ||||
|   return RequestPermissions( | ||||
|       std::vector<PermissionType>(1, permission), render_frame_host, | ||||
|       requesting_origin, user_gesture, | ||||
|       base::Bind(&PermissionRequestResponseCallbackWrapper, callback)); | ||||
| } | ||||
|  | ||||
| int CefPermissionManager::RequestPermissions( | ||||
|     const std::vector<PermissionType>& permissions, | ||||
|     content::RenderFrameHost* render_frame_host, | ||||
|     const GURL& requesting_origin, | ||||
|     bool user_gesture, | ||||
|     const base::Callback<void(const std::vector<PermissionStatus>&)>& | ||||
|         callback) { | ||||
|   if (permissions.empty()) { | ||||
|     callback.Run(std::vector<PermissionStatus>()); | ||||
|     return kNoPendingOperation; | ||||
|   } | ||||
|  | ||||
|   content::WebContents* web_contents = | ||||
|       content::WebContents::FromRenderFrameHost(render_frame_host); | ||||
|   GURL embedding_origin = web_contents->GetLastCommittedURL().GetOrigin(); | ||||
|  | ||||
|   std::unique_ptr<PendingRequest> pending_request = | ||||
|       base::MakeUnique<PendingRequest>(render_frame_host, permissions, | ||||
|                                        callback); | ||||
|   int request_id = pending_requests_.Add(std::move(pending_request)); | ||||
|  | ||||
|   const PermissionRequestID request(render_frame_host, request_id); | ||||
|  | ||||
|   for (size_t i = 0; i < permissions.size(); ++i) { | ||||
|     const PermissionType permission = permissions[i]; | ||||
|  | ||||
|     if (IsConstantPermission(permission) || | ||||
|         !context_.SupportsPermission(permission)) { | ||||
|       OnPermissionsRequestResponseStatus( | ||||
|           request_id, i, | ||||
|           GetPermissionStatus(permission, requesting_origin, embedding_origin)); | ||||
|       continue; | ||||
|     } | ||||
|  | ||||
|     context_.RequestPermission( | ||||
|         permission, web_contents, request, requesting_origin, | ||||
|         base::Bind( | ||||
|             &ContentSettingToPermissionStatusCallbackWrapper, | ||||
|             base::Bind( | ||||
|                 &CefPermissionManager::OnPermissionsRequestResponseStatus, | ||||
|                 weak_ptr_factory_.GetWeakPtr(), request_id, i))); | ||||
|   } | ||||
|  | ||||
|   // The request might have been resolved already. | ||||
|   if (!pending_requests_.Lookup(request_id)) | ||||
|     return kNoPendingOperation; | ||||
|  | ||||
|   return request_id; | ||||
| } | ||||
|  | ||||
| void CefPermissionManager::OnPermissionsRequestResponseStatus( | ||||
|     int request_id, | ||||
|     int permission_id, | ||||
|     PermissionStatus status) { | ||||
|   PendingRequest* pending_request = pending_requests_.Lookup(request_id); | ||||
|   pending_request->SetPermissionStatus(permission_id, status); | ||||
|  | ||||
|   if (!pending_request->IsComplete()) | ||||
|     return; | ||||
|  | ||||
|   pending_request->callback().Run(pending_request->results()); | ||||
|   pending_requests_.Remove(request_id); | ||||
| } | ||||
|  | ||||
| void CefPermissionManager::CancelPermissionRequest(int request_id) { | ||||
|   PendingRequest* pending_request = pending_requests_.Lookup(request_id); | ||||
|   if (!pending_request) | ||||
|     return; | ||||
|  | ||||
|   content::RenderFrameHost* render_frame_host = | ||||
|       content::RenderFrameHost::FromID(pending_request->render_process_id(), | ||||
|                                        pending_request->render_frame_id()); | ||||
|   DCHECK(render_frame_host); | ||||
|   content::WebContents* web_contents = | ||||
|       content::WebContents::FromRenderFrameHost(render_frame_host); | ||||
|   DCHECK(web_contents); | ||||
|  | ||||
|   const PermissionRequestID request(pending_request->render_process_id(), | ||||
|                                     pending_request->render_frame_id(), | ||||
|                                     request_id); | ||||
|   for (PermissionType permission : pending_request->permissions()) { | ||||
|     if (!context_.SupportsPermission(permission)) | ||||
|       continue; | ||||
|     context_.CancelPermissionRequest(permission, web_contents, request); | ||||
|   } | ||||
|   pending_requests_.Remove(request_id); | ||||
| } | ||||
|  | ||||
| void CefPermissionManager::ResetPermission(PermissionType permission, | ||||
|                                            const GURL& requesting_origin, | ||||
|                                            const GURL& embedding_origin) { | ||||
|   if (!context_.SupportsPermission(permission)) | ||||
|     return; | ||||
|   context_.ResetPermission(permission, requesting_origin, embedding_origin); | ||||
| } | ||||
|  | ||||
| PermissionStatus CefPermissionManager::GetPermissionStatus( | ||||
|     PermissionType permission, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin) { | ||||
|   if (IsConstantPermission(permission)) | ||||
|     return GetPermissionStatusForConstantPermission(permission); | ||||
|  | ||||
|   if (!context_.SupportsPermission(permission)) | ||||
|     return PermissionStatus::DENIED; | ||||
|  | ||||
|   return ContentSettingToPermissionStatus(context_.GetPermissionStatus( | ||||
|       permission, requesting_origin, embedding_origin)); | ||||
| } | ||||
|  | ||||
| int CefPermissionManager::SubscribePermissionStatusChange( | ||||
|     PermissionType permission, | ||||
|     const GURL& requesting_origin, | ||||
|     const GURL& embedding_origin, | ||||
|     const base::Callback<void(PermissionStatus)>& callback) { | ||||
|   if (subscriptions_.IsEmpty()) | ||||
|     profile_->GetHostContentSettingsMap()->AddObserver(this); | ||||
|  | ||||
|   std::unique_ptr<Subscription> subscription = base::MakeUnique<Subscription>(); | ||||
|   subscription->permission = permission; | ||||
|   subscription->requesting_origin = requesting_origin; | ||||
|   subscription->embedding_origin = embedding_origin; | ||||
|   subscription->callback = callback; | ||||
|  | ||||
|   subscription->current_value = PermissionStatusToContentSetting( | ||||
|       GetPermissionStatus(permission, subscription->requesting_origin, | ||||
|                           subscription->embedding_origin)); | ||||
|  | ||||
|   return subscriptions_.Add(std::move(subscription)); | ||||
| } | ||||
|  | ||||
| void CefPermissionManager::UnsubscribePermissionStatusChange( | ||||
|     int subscription_id) { | ||||
|   // Whether |subscription_id| is known will be checked by the Remove() call. | ||||
|   subscriptions_.Remove(subscription_id); | ||||
|  | ||||
|   if (subscriptions_.IsEmpty()) | ||||
|     profile_->GetHostContentSettingsMap()->RemoveObserver(this); | ||||
| } | ||||
|  | ||||
| void CefPermissionManager::OnContentSettingChanged( | ||||
|     const ContentSettingsPattern& primary_pattern, | ||||
|     const ContentSettingsPattern& secondary_pattern, | ||||
|     ContentSettingsType content_type, | ||||
|     std::string resource_identifier) { | ||||
|   std::list<base::Closure> callbacks; | ||||
|  | ||||
|   for (SubscriptionsMap::iterator iter(&subscriptions_); !iter.IsAtEnd(); | ||||
|        iter.Advance()) { | ||||
|     Subscription* subscription = iter.GetCurrentValue(); | ||||
|     if (permission_util::PermissionTypeToContentSetting( | ||||
|             subscription->permission) != content_type) { | ||||
|       continue; | ||||
|     } | ||||
|  | ||||
|     if (primary_pattern.IsValid() && | ||||
|         !primary_pattern.Matches(subscription->requesting_origin)) | ||||
|       continue; | ||||
|     if (secondary_pattern.IsValid() && | ||||
|         !secondary_pattern.Matches(subscription->embedding_origin)) | ||||
|       continue; | ||||
|  | ||||
|     ContentSetting new_value = | ||||
|         PermissionStatusToContentSetting(GetPermissionStatus( | ||||
|             subscription->permission, subscription->requesting_origin, | ||||
|             subscription->embedding_origin)); | ||||
|     if (subscription->current_value == new_value) | ||||
|       continue; | ||||
|  | ||||
|     subscription->current_value = new_value; | ||||
|  | ||||
|     // Add the callback to |callbacks| which will be run after the loop to | ||||
|     // prevent re-entrance issues. | ||||
|     callbacks.push_back(base::Bind( | ||||
|         subscription->callback, ContentSettingToPermissionStatus(new_value))); | ||||
|   } | ||||
|  | ||||
|   for (const auto& callback : callbacks) | ||||
|     callback.Run(); | ||||
| } | ||||
| @@ -1,100 +0,0 @@ | ||||
| // Copyright 2015 The Chromium Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style license that can be | ||||
| // found in the LICENSE file. | ||||
|  | ||||
| #ifndef CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | ||||
| #define CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | ||||
|  | ||||
| #include "libcef/browser/permissions/permission_context.h" | ||||
|  | ||||
| #include "base/callback_forward.h" | ||||
| #include "base/containers/id_map.h" | ||||
| #include "base/macros.h" | ||||
| #include "base/memory/weak_ptr.h" | ||||
| #include "components/content_settings/core/browser/content_settings_observer.h" | ||||
| #include "components/content_settings/core/common/content_settings.h" | ||||
| #include "components/keyed_service/core/keyed_service.h" | ||||
| #include "content/public/browser/permission_manager.h" | ||||
|  | ||||
| class CefBrowserContext; | ||||
|  | ||||
| namespace content { | ||||
| enum class PermissionType; | ||||
| class WebContents; | ||||
| };  // namespace content | ||||
|  | ||||
| // Implementation based on chrome/browser/permissions/permission_manager.h | ||||
| class CefPermissionManager : public KeyedService, | ||||
|                              public content::PermissionManager, | ||||
|                              public content_settings::Observer { | ||||
|  public: | ||||
|   explicit CefPermissionManager(CefBrowserContext* profile); | ||||
|   ~CefPermissionManager() override; | ||||
|  | ||||
|   // content::CefPermissionManager implementation. | ||||
|   int RequestPermission( | ||||
|       content::PermissionType permission, | ||||
|       content::RenderFrameHost* render_frame_host, | ||||
|       const GURL& requesting_origin, | ||||
|       bool user_gesture, | ||||
|       const base::Callback<void(blink::mojom::PermissionStatus)>& callback) | ||||
|       override; | ||||
|   int RequestPermissions( | ||||
|       const std::vector<content::PermissionType>& permissions, | ||||
|       content::RenderFrameHost* render_frame_host, | ||||
|       const GURL& requesting_origin, | ||||
|       bool user_gesture, | ||||
|       const base::Callback< | ||||
|           void(const std::vector<blink::mojom::PermissionStatus>&)>& callback) | ||||
|       override; | ||||
|   void CancelPermissionRequest(int request_id) override; | ||||
|   void ResetPermission(content::PermissionType permission, | ||||
|                        const GURL& requesting_origin, | ||||
|                        const GURL& embedding_origin) override; | ||||
|   blink::mojom::PermissionStatus GetPermissionStatus( | ||||
|       content::PermissionType permission, | ||||
|       const GURL& requesting_origin, | ||||
|       const GURL& embedding_origin) override; | ||||
|   int SubscribePermissionStatusChange( | ||||
|       content::PermissionType permission, | ||||
|       const GURL& requesting_origin, | ||||
|       const GURL& embedding_origin, | ||||
|       const base::Callback<void(blink::mojom::PermissionStatus)>& callback) | ||||
|       override; | ||||
|   void UnsubscribePermissionStatusChange(int subscription_id) override; | ||||
|  | ||||
|  private: | ||||
|   class PendingRequest; | ||||
|   using PendingRequestsMap = base::IDMap<std::unique_ptr<PendingRequest>>; | ||||
|  | ||||
|   struct Subscription; | ||||
|   using SubscriptionsMap = base::IDMap<std::unique_ptr<Subscription>>; | ||||
|  | ||||
|   // Called when a permission was decided for a given PendingRequest. The | ||||
|   // PendingRequest is identified by its |request_id| and the permission is | ||||
|   // identified by its |permission_id|. If the PendingRequest contains more than | ||||
|   // one permission, it will wait for the remaining permissions to be resolved. | ||||
|   // When all the permissions have been resolved, the PendingRequest's callback | ||||
|   // is run. | ||||
|   void OnPermissionsRequestResponseStatus( | ||||
|       int request_id, | ||||
|       int permission_id, | ||||
|       blink::mojom::PermissionStatus status); | ||||
|  | ||||
|   // content_settings::Observer implementation. | ||||
|   void OnContentSettingChanged(const ContentSettingsPattern& primary_pattern, | ||||
|                                const ContentSettingsPattern& secondary_pattern, | ||||
|                                ContentSettingsType content_type, | ||||
|                                std::string resource_identifier) override; | ||||
|  | ||||
|   CefBrowserContext* profile_; | ||||
|   PendingRequestsMap pending_requests_; | ||||
|   SubscriptionsMap subscriptions_; | ||||
|   CefPermissionContext context_; | ||||
|  | ||||
|   base::WeakPtrFactory<CefPermissionManager> weak_ptr_factory_; | ||||
|  | ||||
|   DISALLOW_COPY_AND_ASSIGN(CefPermissionManager); | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_MANAGER_H_ | ||||
| @@ -1,59 +0,0 @@ | ||||
| // Copyright 2015 The Chromium Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style license that can be | ||||
| // found in the LICENSE file. | ||||
|  | ||||
| #include "libcef/browser/permissions/permission_util.h" | ||||
|  | ||||
| #include "base/logging.h" | ||||
|  | ||||
| using content::PermissionType; | ||||
|  | ||||
| namespace permission_util { | ||||
|  | ||||
| // Copied from chrome/browser/permissions/permission_manager.cc. | ||||
| ContentSettingsType PermissionTypeToContentSetting(PermissionType permission) { | ||||
|   switch (permission) { | ||||
|     case PermissionType::MIDI: | ||||
|       return CONTENT_SETTINGS_TYPE_MIDI; | ||||
|     case PermissionType::MIDI_SYSEX: | ||||
|       return CONTENT_SETTINGS_TYPE_MIDI_SYSEX; | ||||
|     case PermissionType::NOTIFICATIONS: | ||||
|       return CONTENT_SETTINGS_TYPE_NOTIFICATIONS; | ||||
|     case PermissionType::GEOLOCATION: | ||||
|       return CONTENT_SETTINGS_TYPE_GEOLOCATION; | ||||
|     case PermissionType::PROTECTED_MEDIA_IDENTIFIER: | ||||
| #if defined(OS_ANDROID) || defined(OS_CHROMEOS) | ||||
|       return CONTENT_SETTINGS_TYPE_PROTECTED_MEDIA_IDENTIFIER; | ||||
| #else | ||||
|       NOTIMPLEMENTED(); | ||||
|       break; | ||||
| #endif | ||||
|     case PermissionType::DURABLE_STORAGE: | ||||
|       return CONTENT_SETTINGS_TYPE_DURABLE_STORAGE; | ||||
|     case PermissionType::AUDIO_CAPTURE: | ||||
|       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_MIC; | ||||
|     case PermissionType::VIDEO_CAPTURE: | ||||
|       return CONTENT_SETTINGS_TYPE_MEDIASTREAM_CAMERA; | ||||
|     case PermissionType::BACKGROUND_SYNC: | ||||
|       return CONTENT_SETTINGS_TYPE_BACKGROUND_SYNC; | ||||
|     case PermissionType::FLASH: | ||||
|       return CONTENT_SETTINGS_TYPE_PLUGINS; | ||||
|     case PermissionType::SENSORS: | ||||
|       return CONTENT_SETTINGS_TYPE_SENSORS; | ||||
|     case PermissionType::ACCESSIBILITY_EVENTS: | ||||
|       return CONTENT_SETTINGS_TYPE_ACCESSIBILITY_EVENTS; | ||||
|     case PermissionType::CLIPBOARD_READ: | ||||
|       return CONTENT_SETTINGS_TYPE_CLIPBOARD_READ; | ||||
|     case PermissionType::CLIPBOARD_WRITE: | ||||
|       return CONTENT_SETTINGS_TYPE_CLIPBOARD_WRITE; | ||||
|     case PermissionType::NUM: | ||||
|       // This will hit the NOTREACHED below. | ||||
|       break; | ||||
|   } | ||||
|  | ||||
|   NOTREACHED() << "Unknown content setting for permission " | ||||
|                << static_cast<int>(permission); | ||||
|   return CONTENT_SETTINGS_TYPE_DEFAULT; | ||||
| } | ||||
|  | ||||
| }  // namespace permission_util | ||||
| @@ -1,19 +0,0 @@ | ||||
| // Copyright 2015 The Chromium Authors. All rights reserved. | ||||
| // Use of this source code is governed by a BSD-style license that can be | ||||
| // found in the LICENSE file. | ||||
|  | ||||
| #ifndef CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | ||||
| #define CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | ||||
|  | ||||
| #include "components/content_settings/core/common/content_settings_types.h" | ||||
| #include "content/public/browser/permission_type.h" | ||||
|  | ||||
| namespace permission_util { | ||||
|  | ||||
| // Helper method to convert PermissionType to ContentSettingType. | ||||
| ContentSettingsType PermissionTypeToContentSetting( | ||||
|     content::PermissionType permission); | ||||
|  | ||||
| }  // namespace permission_util | ||||
|  | ||||
| #endif  // CEF_LIBCEF_BROWSER_PERMISSIONS_PERMISSION_UTIL_H_ | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=9e43ede1c873111f8ccd125a24a6201c4702f822$ | ||||
| // $hash=74f8efc606edb74535b418345d7a3b9ddcfd3bca$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/cpptoc/client_cpptoc.h" | ||||
| @@ -20,7 +20,6 @@ | ||||
| #include "libcef_dll/cpptoc/drag_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/find_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/focus_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" | ||||
| @@ -146,22 +145,6 @@ client_get_focus_handler(struct _cef_client_t* self) { | ||||
|   return CefFocusHandlerCppToC::Wrap(_retval); | ||||
| } | ||||
|  | ||||
| struct _cef_geolocation_handler_t* CEF_CALLBACK | ||||
| client_get_geolocation_handler(struct _cef_client_t* self) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return NULL; | ||||
|  | ||||
|   // Execute | ||||
|   CefRefPtr<CefGeolocationHandler> _retval = | ||||
|       CefClientCppToC::Get(self)->GetGeolocationHandler(); | ||||
|  | ||||
|   // Return type: refptr_same | ||||
|   return CefGeolocationHandlerCppToC::Wrap(_retval); | ||||
| } | ||||
|  | ||||
| struct _cef_jsdialog_handler_t* CEF_CALLBACK | ||||
| client_get_jsdialog_handler(struct _cef_client_t* self) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
| @@ -298,7 +281,6 @@ CefClientCppToC::CefClientCppToC() { | ||||
|   GetStruct()->get_drag_handler = client_get_drag_handler; | ||||
|   GetStruct()->get_find_handler = client_get_find_handler; | ||||
|   GetStruct()->get_focus_handler = client_get_focus_handler; | ||||
|   GetStruct()->get_geolocation_handler = client_get_geolocation_handler; | ||||
|   GetStruct()->get_jsdialog_handler = client_get_jsdialog_handler; | ||||
|   GetStruct()->get_keyboard_handler = client_get_keyboard_handler; | ||||
|   GetStruct()->get_life_span_handler = client_get_life_span_handler; | ||||
|   | ||||
| @@ -1,63 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=5bd0f16810c3c46a19a5f64133e02e4681675f04$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // MEMBER FUNCTIONS - Body may be edited by hand. | ||||
|  | ||||
| void CEF_CALLBACK | ||||
| geolocation_callback_cont(struct _cef_geolocation_callback_t* self, int allow) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return; | ||||
|  | ||||
|   // Execute | ||||
|   CefGeolocationCallbackCppToC::Get(self)->Continue(allow ? true : false); | ||||
| } | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGeolocationCallbackCppToC::CefGeolocationCallbackCppToC() { | ||||
|   GetStruct()->cont = geolocation_callback_cont; | ||||
| } | ||||
|  | ||||
| template <> | ||||
| CefRefPtr<CefGeolocationCallback> CefCppToCRefCounted< | ||||
|     CefGeolocationCallbackCppToC, | ||||
|     CefGeolocationCallback, | ||||
|     cef_geolocation_callback_t>::UnwrapDerived(CefWrapperType type, | ||||
|                                                cef_geolocation_callback_t* s) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCppToCRefCounted<CefGeolocationCallbackCppToC, | ||||
|                                          CefGeolocationCallback, | ||||
|                                          cef_geolocation_callback_t>::DebugObjCt | ||||
|     ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType CefCppToCRefCounted<CefGeolocationCallbackCppToC, | ||||
|                                    CefGeolocationCallback, | ||||
|                                    cef_geolocation_callback_t>::kWrapperType = | ||||
|     WT_GEOLOCATION_CALLBACK; | ||||
| @@ -1,37 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=98817821ce951491596ce01e7a13febc669ff1b9$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| #define CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(BUILDING_CEF_SHARED) | ||||
| #error This file can be included DLL-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_handler_capi.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "libcef_dll/cpptoc/cpptoc_ref_counted.h" | ||||
|  | ||||
| // Wrap a C++ class with a C structure. | ||||
| // This class may be instantiated and accessed DLL-side only. | ||||
| class CefGeolocationCallbackCppToC | ||||
|     : public CefCppToCRefCounted<CefGeolocationCallbackCppToC, | ||||
|                                  CefGeolocationCallback, | ||||
|                                  cef_geolocation_callback_t> { | ||||
|  public: | ||||
|   CefGeolocationCallbackCppToC(); | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| @@ -1,109 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=d4092763acd3a7bfd30586d0bdfd91915d2fab90$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" | ||||
| #include "libcef_dll/ctocpp/browser_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // MEMBER FUNCTIONS - Body may be edited by hand. | ||||
|  | ||||
| int CEF_CALLBACK geolocation_handler_on_request_geolocation_permission( | ||||
|     struct _cef_geolocation_handler_t* self, | ||||
|     cef_browser_t* browser, | ||||
|     const cef_string_t* requesting_url, | ||||
|     int request_id, | ||||
|     cef_geolocation_callback_t* callback) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return 0; | ||||
|   // Verify param: browser; type: refptr_diff | ||||
|   DCHECK(browser); | ||||
|   if (!browser) | ||||
|     return 0; | ||||
|   // Verify param: requesting_url; type: string_byref_const | ||||
|   DCHECK(requesting_url); | ||||
|   if (!requesting_url) | ||||
|     return 0; | ||||
|   // Verify param: callback; type: refptr_diff | ||||
|   DCHECK(callback); | ||||
|   if (!callback) | ||||
|     return 0; | ||||
|  | ||||
|   // Execute | ||||
|   bool _retval = | ||||
|       CefGeolocationHandlerCppToC::Get(self)->OnRequestGeolocationPermission( | ||||
|           CefBrowserCToCpp::Wrap(browser), CefString(requesting_url), | ||||
|           request_id, CefGeolocationCallbackCToCpp::Wrap(callback)); | ||||
|  | ||||
|   // Return type: bool | ||||
|   return _retval; | ||||
| } | ||||
|  | ||||
| void CEF_CALLBACK geolocation_handler_on_cancel_geolocation_permission( | ||||
|     struct _cef_geolocation_handler_t* self, | ||||
|     cef_browser_t* browser, | ||||
|     int request_id) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return; | ||||
|   // Verify param: browser; type: refptr_diff | ||||
|   DCHECK(browser); | ||||
|   if (!browser) | ||||
|     return; | ||||
|  | ||||
|   // Execute | ||||
|   CefGeolocationHandlerCppToC::Get(self)->OnCancelGeolocationPermission( | ||||
|       CefBrowserCToCpp::Wrap(browser), request_id); | ||||
| } | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGeolocationHandlerCppToC::CefGeolocationHandlerCppToC() { | ||||
|   GetStruct()->on_request_geolocation_permission = | ||||
|       geolocation_handler_on_request_geolocation_permission; | ||||
|   GetStruct()->on_cancel_geolocation_permission = | ||||
|       geolocation_handler_on_cancel_geolocation_permission; | ||||
| } | ||||
|  | ||||
| template <> | ||||
| CefRefPtr<CefGeolocationHandler> CefCppToCRefCounted< | ||||
|     CefGeolocationHandlerCppToC, | ||||
|     CefGeolocationHandler, | ||||
|     cef_geolocation_handler_t>::UnwrapDerived(CefWrapperType type, | ||||
|                                               cef_geolocation_handler_t* s) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCppToCRefCounted<CefGeolocationHandlerCppToC, | ||||
|                                          CefGeolocationHandler, | ||||
|                                          cef_geolocation_handler_t>::DebugObjCt | ||||
|     ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType CefCppToCRefCounted<CefGeolocationHandlerCppToC, | ||||
|                                    CefGeolocationHandler, | ||||
|                                    cef_geolocation_handler_t>::kWrapperType = | ||||
|     WT_GEOLOCATION_HANDLER; | ||||
| @@ -1,37 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=414d9dd69cf3d35b85ccdfcf302884033ed6e04c$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ | ||||
| #define CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(WRAPPING_CEF_SHARED) | ||||
| #error This file can be included wrapper-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_handler_capi.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "libcef_dll/cpptoc/cpptoc_ref_counted.h" | ||||
|  | ||||
| // Wrap a C++ class with a C structure. | ||||
| // This class may be instantiated and accessed wrapper-side only. | ||||
| class CefGeolocationHandlerCppToC | ||||
|     : public CefCppToCRefCounted<CefGeolocationHandlerCppToC, | ||||
|                                  CefGeolocationHandler, | ||||
|                                  cef_geolocation_handler_t> { | ||||
|  public: | ||||
|   CefGeolocationHandlerCppToC(); | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CPPTOC_GEOLOCATION_HANDLER_CPPTOC_H_ | ||||
| @@ -1,74 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=ba9c66f6c7806715268009762248e6f68e94fc8c$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h" | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // MEMBER FUNCTIONS - Body may be edited by hand. | ||||
|  | ||||
| void CEF_CALLBACK get_geolocation_callback_on_location_update( | ||||
|     struct _cef_get_geolocation_callback_t* self, | ||||
|     const struct _cef_geoposition_t* position) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   DCHECK(self); | ||||
|   if (!self) | ||||
|     return; | ||||
|   // Verify param: position; type: struct_byref_const | ||||
|   DCHECK(position); | ||||
|   if (!position) | ||||
|     return; | ||||
|  | ||||
|   // Translate param: position; type: struct_byref_const | ||||
|   CefGeoposition positionObj; | ||||
|   if (position) | ||||
|     positionObj.Set(*position, false); | ||||
|  | ||||
|   // Execute | ||||
|   CefGetGeolocationCallbackCppToC::Get(self)->OnLocationUpdate(positionObj); | ||||
| } | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGetGeolocationCallbackCppToC::CefGetGeolocationCallbackCppToC() { | ||||
|   GetStruct()->on_location_update = get_geolocation_callback_on_location_update; | ||||
| } | ||||
|  | ||||
| template <> | ||||
| CefRefPtr<CefGetGeolocationCallback> | ||||
| CefCppToCRefCounted<CefGetGeolocationCallbackCppToC, | ||||
|                     CefGetGeolocationCallback, | ||||
|                     cef_get_geolocation_callback_t>:: | ||||
|     UnwrapDerived(CefWrapperType type, cef_get_geolocation_callback_t* s) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCppToCRefCounted< | ||||
|     CefGetGeolocationCallbackCppToC, | ||||
|     CefGetGeolocationCallback, | ||||
|     cef_get_geolocation_callback_t>::DebugObjCt ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType | ||||
|     CefCppToCRefCounted<CefGetGeolocationCallbackCppToC, | ||||
|                         CefGetGeolocationCallback, | ||||
|                         cef_get_geolocation_callback_t>::kWrapperType = | ||||
|         WT_GET_GEOLOCATION_CALLBACK; | ||||
| @@ -1,37 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=5b84f64e6dc130807abd2cf121f4fe8a19ef0194$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| #define CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(WRAPPING_CEF_SHARED) | ||||
| #error This file can be included wrapper-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_capi.h" | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "libcef_dll/cpptoc/cpptoc_ref_counted.h" | ||||
|  | ||||
| // Wrap a C++ class with a C structure. | ||||
| // This class may be instantiated and accessed wrapper-side only. | ||||
| class CefGetGeolocationCallbackCppToC | ||||
|     : public CefCppToCRefCounted<CefGetGeolocationCallbackCppToC, | ||||
|                                  CefGetGeolocationCallback, | ||||
|                                  cef_get_geolocation_callback_t> { | ||||
|  public: | ||||
|   CefGetGeolocationCallbackCppToC(); | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CPPTOC_GET_GEOLOCATION_CALLBACK_CPPTOC_H_ | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=0fccd49cb20ab68370e1259052bda83c0cfd0a09$ | ||||
| // $hash=d02e30103863b1d5eb2a8339f8bd8e5d01812f28$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/ctocpp/client_ctocpp.h" | ||||
| @@ -22,7 +22,6 @@ | ||||
| #include "libcef_dll/ctocpp/drag_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/find_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/focus_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" | ||||
| @@ -131,21 +130,6 @@ CefRefPtr<CefFocusHandler> CefClientCToCpp::GetFocusHandler() { | ||||
|   return CefFocusHandlerCToCpp::Wrap(_retval); | ||||
| } | ||||
|  | ||||
| CefRefPtr<CefGeolocationHandler> CefClientCToCpp::GetGeolocationHandler() { | ||||
|   cef_client_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, get_geolocation_handler)) | ||||
|     return NULL; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Execute | ||||
|   cef_geolocation_handler_t* _retval = | ||||
|       _struct->get_geolocation_handler(_struct); | ||||
|  | ||||
|   // Return type: refptr_same | ||||
|   return CefGeolocationHandlerCToCpp::Wrap(_retval); | ||||
| } | ||||
|  | ||||
| CefRefPtr<CefJSDialogHandler> CefClientCToCpp::GetJSDialogHandler() { | ||||
|   cef_client_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, get_jsdialog_handler)) | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=d1d5aff0ab25713b263c91a5c2dba2c60c798d39$ | ||||
| // $hash=79395a86efe19099f77240902fb56533bc791f7a$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_CLIENT_CTOCPP_H_ | ||||
| @@ -39,7 +39,6 @@ class CefClientCToCpp | ||||
|   CefRefPtr<CefDragHandler> GetDragHandler() override; | ||||
|   CefRefPtr<CefFindHandler> GetFindHandler() override; | ||||
|   CefRefPtr<CefFocusHandler> GetFocusHandler() override; | ||||
|   CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() override; | ||||
|   CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() override; | ||||
|   CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() override; | ||||
|   CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override; | ||||
|   | ||||
| @@ -1,56 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=2bd27eaa0d2a977064dccedffdecbffd6c28d02b$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" | ||||
|  | ||||
| // VIRTUAL METHODS - Body may be edited by hand. | ||||
|  | ||||
| void CefGeolocationCallbackCToCpp::Continue(bool allow) { | ||||
|   cef_geolocation_callback_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, cont)) | ||||
|     return; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Execute | ||||
|   _struct->cont(_struct, allow); | ||||
| } | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGeolocationCallbackCToCpp::CefGeolocationCallbackCToCpp() {} | ||||
|  | ||||
| template <> | ||||
| cef_geolocation_callback_t* CefCToCppRefCounted< | ||||
|     CefGeolocationCallbackCToCpp, | ||||
|     CefGeolocationCallback, | ||||
|     cef_geolocation_callback_t>::UnwrapDerived(CefWrapperType type, | ||||
|                                                CefGeolocationCallback* c) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCToCppRefCounted<CefGeolocationCallbackCToCpp, | ||||
|                                          CefGeolocationCallback, | ||||
|                                          cef_geolocation_callback_t>::DebugObjCt | ||||
|     ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType CefCToCppRefCounted<CefGeolocationCallbackCToCpp, | ||||
|                                    CefGeolocationCallback, | ||||
|                                    cef_geolocation_callback_t>::kWrapperType = | ||||
|     WT_GEOLOCATION_CALLBACK; | ||||
| @@ -1,40 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=194c6a77f3f1a23a883940aff0b5ae4a0ab434fc$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| #define CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(WRAPPING_CEF_SHARED) | ||||
| #error This file can be included wrapper-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_handler_capi.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "libcef_dll/ctocpp/ctocpp_ref_counted.h" | ||||
|  | ||||
| // Wrap a C structure with a C++ class. | ||||
| // This class may be instantiated and accessed wrapper-side only. | ||||
| class CefGeolocationCallbackCToCpp | ||||
|     : public CefCToCppRefCounted<CefGeolocationCallbackCToCpp, | ||||
|                                  CefGeolocationCallback, | ||||
|                                  cef_geolocation_callback_t> { | ||||
|  public: | ||||
|   CefGeolocationCallbackCToCpp(); | ||||
|  | ||||
|   // CefGeolocationCallback methods. | ||||
|   void Continue(bool allow) OVERRIDE; | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| @@ -1,99 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=ee4a27e022edcd3e95b37fb24b72c0b115c9342c$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" | ||||
| #include "libcef_dll/cpptoc/browser_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" | ||||
|  | ||||
| // VIRTUAL METHODS - Body may be edited by hand. | ||||
|  | ||||
| bool CefGeolocationHandlerCToCpp::OnRequestGeolocationPermission( | ||||
|     CefRefPtr<CefBrowser> browser, | ||||
|     const CefString& requesting_url, | ||||
|     int request_id, | ||||
|     CefRefPtr<CefGeolocationCallback> callback) { | ||||
|   cef_geolocation_handler_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, on_request_geolocation_permission)) | ||||
|     return false; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Verify param: browser; type: refptr_diff | ||||
|   DCHECK(browser.get()); | ||||
|   if (!browser.get()) | ||||
|     return false; | ||||
|   // Verify param: requesting_url; type: string_byref_const | ||||
|   DCHECK(!requesting_url.empty()); | ||||
|   if (requesting_url.empty()) | ||||
|     return false; | ||||
|   // Verify param: callback; type: refptr_diff | ||||
|   DCHECK(callback.get()); | ||||
|   if (!callback.get()) | ||||
|     return false; | ||||
|  | ||||
|   // Execute | ||||
|   int _retval = _struct->on_request_geolocation_permission( | ||||
|       _struct, CefBrowserCppToC::Wrap(browser), requesting_url.GetStruct(), | ||||
|       request_id, CefGeolocationCallbackCppToC::Wrap(callback)); | ||||
|  | ||||
|   // Return type: bool | ||||
|   return _retval ? true : false; | ||||
| } | ||||
|  | ||||
| void CefGeolocationHandlerCToCpp::OnCancelGeolocationPermission( | ||||
|     CefRefPtr<CefBrowser> browser, | ||||
|     int request_id) { | ||||
|   cef_geolocation_handler_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, on_cancel_geolocation_permission)) | ||||
|     return; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Verify param: browser; type: refptr_diff | ||||
|   DCHECK(browser.get()); | ||||
|   if (!browser.get()) | ||||
|     return; | ||||
|  | ||||
|   // Execute | ||||
|   _struct->on_cancel_geolocation_permission( | ||||
|       _struct, CefBrowserCppToC::Wrap(browser), request_id); | ||||
| } | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGeolocationHandlerCToCpp::CefGeolocationHandlerCToCpp() {} | ||||
|  | ||||
| template <> | ||||
| cef_geolocation_handler_t* CefCToCppRefCounted< | ||||
|     CefGeolocationHandlerCToCpp, | ||||
|     CefGeolocationHandler, | ||||
|     cef_geolocation_handler_t>::UnwrapDerived(CefWrapperType type, | ||||
|                                               CefGeolocationHandler* c) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCToCppRefCounted<CefGeolocationHandlerCToCpp, | ||||
|                                          CefGeolocationHandler, | ||||
|                                          cef_geolocation_handler_t>::DebugObjCt | ||||
|     ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType CefCToCppRefCounted<CefGeolocationHandlerCToCpp, | ||||
|                                    CefGeolocationHandler, | ||||
|                                    cef_geolocation_handler_t>::kWrapperType = | ||||
|     WT_GEOLOCATION_HANDLER; | ||||
| @@ -1,46 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=b7ebc30b0b9adc5a052d3fd4f0d998467aec0773$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ | ||||
| #define CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(BUILDING_CEF_SHARED) | ||||
| #error This file can be included DLL-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_handler_capi.h" | ||||
| #include "include/cef_geolocation_handler.h" | ||||
| #include "libcef_dll/ctocpp/ctocpp_ref_counted.h" | ||||
|  | ||||
| // Wrap a C structure with a C++ class. | ||||
| // This class may be instantiated and accessed DLL-side only. | ||||
| class CefGeolocationHandlerCToCpp | ||||
|     : public CefCToCppRefCounted<CefGeolocationHandlerCToCpp, | ||||
|                                  CefGeolocationHandler, | ||||
|                                  cef_geolocation_handler_t> { | ||||
|  public: | ||||
|   CefGeolocationHandlerCToCpp(); | ||||
|  | ||||
|   // CefGeolocationHandler methods. | ||||
|   bool OnRequestGeolocationPermission( | ||||
|       CefRefPtr<CefBrowser> browser, | ||||
|       const CefString& requesting_url, | ||||
|       int request_id, | ||||
|       CefRefPtr<CefGeolocationCallback> callback) override; | ||||
|   void OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser, | ||||
|                                      int request_id) override; | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CTOCPP_GEOLOCATION_HANDLER_CTOCPP_H_ | ||||
| @@ -1,59 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=bb77620a4eb5dbac001660d97187a2c543a4de43$ | ||||
| // | ||||
|  | ||||
| #include "libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h" | ||||
|  | ||||
| // VIRTUAL METHODS - Body may be edited by hand. | ||||
|  | ||||
| void CefGetGeolocationCallbackCToCpp::OnLocationUpdate( | ||||
|     const CefGeoposition& position) { | ||||
|   cef_get_geolocation_callback_t* _struct = GetStruct(); | ||||
|   if (CEF_MEMBER_MISSING(_struct, on_location_update)) | ||||
|     return; | ||||
|  | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Execute | ||||
|   _struct->on_location_update(_struct, &position); | ||||
| } | ||||
|  | ||||
| // CONSTRUCTOR - Do not edit by hand. | ||||
|  | ||||
| CefGetGeolocationCallbackCToCpp::CefGetGeolocationCallbackCToCpp() {} | ||||
|  | ||||
| template <> | ||||
| cef_get_geolocation_callback_t* CefCToCppRefCounted< | ||||
|     CefGetGeolocationCallbackCToCpp, | ||||
|     CefGetGeolocationCallback, | ||||
|     cef_get_geolocation_callback_t>::UnwrapDerived(CefWrapperType type, | ||||
|                                                    CefGetGeolocationCallback* | ||||
|                                                        c) { | ||||
|   NOTREACHED() << "Unexpected class type: " << type; | ||||
|   return NULL; | ||||
| } | ||||
|  | ||||
| #if DCHECK_IS_ON() | ||||
| template <> | ||||
| base::AtomicRefCount CefCToCppRefCounted< | ||||
|     CefGetGeolocationCallbackCToCpp, | ||||
|     CefGetGeolocationCallback, | ||||
|     cef_get_geolocation_callback_t>::DebugObjCt ATOMIC_DECLARATION; | ||||
| #endif | ||||
|  | ||||
| template <> | ||||
| CefWrapperType | ||||
|     CefCToCppRefCounted<CefGetGeolocationCallbackCToCpp, | ||||
|                         CefGetGeolocationCallback, | ||||
|                         cef_get_geolocation_callback_t>::kWrapperType = | ||||
|         WT_GET_GEOLOCATION_CALLBACK; | ||||
| @@ -1,40 +0,0 @@ | ||||
| // Copyright (c) 2018 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. If making changes by | ||||
| // hand only do so within the body of existing method and function | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=1534f165425a785e198e3eb216b70948916499e1$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| #define CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| #pragma once | ||||
|  | ||||
| #if !defined(BUILDING_CEF_SHARED) | ||||
| #error This file can be included DLL-side only | ||||
| #endif | ||||
|  | ||||
| #include "include/capi/cef_geolocation_capi.h" | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "libcef_dll/ctocpp/ctocpp_ref_counted.h" | ||||
|  | ||||
| // Wrap a C structure with a C++ class. | ||||
| // This class may be instantiated and accessed DLL-side only. | ||||
| class CefGetGeolocationCallbackCToCpp | ||||
|     : public CefCToCppRefCounted<CefGetGeolocationCallbackCToCpp, | ||||
|                                  CefGetGeolocationCallback, | ||||
|                                  cef_get_geolocation_callback_t> { | ||||
|  public: | ||||
|   CefGetGeolocationCallbackCToCpp(); | ||||
|  | ||||
|   // CefGetGeolocationCallback methods. | ||||
|   void OnLocationUpdate(const CefGeoposition& position) override; | ||||
| }; | ||||
|  | ||||
| #endif  // CEF_LIBCEF_DLL_CTOCPP_GET_GEOLOCATION_CALLBACK_CTOCPP_H_ | ||||
| @@ -9,13 +9,12 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=308c8d67492d6cdc50740b85321ec6423f967a6e$ | ||||
| // $hash=8fb3e1af64274b34482ee34c75a6196654104360$ | ||||
| // | ||||
|  | ||||
| #include "include/capi/cef_app_capi.h" | ||||
| #include "include/capi/cef_crash_util_capi.h" | ||||
| #include "include/capi/cef_file_util_capi.h" | ||||
| #include "include/capi/cef_geolocation_capi.h" | ||||
| #include "include/capi/cef_origin_whitelist_capi.h" | ||||
| #include "include/capi/cef_parser_capi.h" | ||||
| #include "include/capi/cef_path_util_capi.h" | ||||
| @@ -30,7 +29,6 @@ | ||||
| #include "include/cef_app.h" | ||||
| #include "include/cef_crash_util.h" | ||||
| #include "include/cef_file_util.h" | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "include/cef_origin_whitelist.h" | ||||
| #include "include/cef_parser.h" | ||||
| #include "include/cef_path_util.h" | ||||
| @@ -59,7 +57,6 @@ | ||||
| #include "libcef_dll/cpptoc/extension_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/file_dialog_callback_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/frame_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/geolocation_callback_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/get_extension_resource_callback_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/image_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/jsdialog_callback_cpptoc.h" | ||||
| @@ -132,8 +129,6 @@ | ||||
| #include "libcef_dll/ctocpp/extension_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/find_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/focus_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/geolocation_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/get_geolocation_callback_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/jsdialog_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/keyboard_handler_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/life_span_handler_ctocpp.h" | ||||
| @@ -290,12 +285,8 @@ CEF_EXPORT void cef_shutdown() { | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFindHandlerCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFocusHandlerCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFrameCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefGeolocationCallbackCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefGeolocationHandlerCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero( | ||||
|       &CefGetExtensionResourceCallbackCppToC::DebugObjCt)); | ||||
|   DCHECK( | ||||
|       base::AtomicRefCountIsZero(&CefGetGeolocationCallbackCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefImageCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefJSDialogCallbackCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefJSDialogHandlerCToCpp::DebugObjCt)); | ||||
| @@ -610,23 +601,6 @@ CEF_EXPORT void cef_load_crlsets_file(const cef_string_t* path) { | ||||
|   CefLoadCRLSetsFile(CefString(path)); | ||||
| } | ||||
|  | ||||
| CEF_EXPORT int cef_get_geolocation( | ||||
|     struct _cef_get_geolocation_callback_t* callback) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Verify param: callback; type: refptr_diff | ||||
|   DCHECK(callback); | ||||
|   if (!callback) | ||||
|     return 0; | ||||
|  | ||||
|   // Execute | ||||
|   bool _retval = | ||||
|       CefGetGeolocation(CefGetGeolocationCallbackCToCpp::Wrap(callback)); | ||||
|  | ||||
|   // Return type: bool | ||||
|   return _retval; | ||||
| } | ||||
|  | ||||
| CEF_EXPORT int cef_add_cross_origin_whitelist_entry( | ||||
|     const cef_string_t* source_origin, | ||||
|     const cef_string_t* target_protocol, | ||||
|   | ||||
| @@ -9,13 +9,12 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=c73e15357ba9d9047c54452fc244fadcf98b4760$ | ||||
| // $hash=07d31c969dc527db8df550827d750aefa0abf1b8$ | ||||
| // | ||||
|  | ||||
| #include "include/capi/cef_app_capi.h" | ||||
| #include "include/capi/cef_crash_util_capi.h" | ||||
| #include "include/capi/cef_file_util_capi.h" | ||||
| #include "include/capi/cef_geolocation_capi.h" | ||||
| #include "include/capi/cef_origin_whitelist_capi.h" | ||||
| #include "include/capi/cef_parser_capi.h" | ||||
| #include "include/capi/cef_path_util_capi.h" | ||||
| @@ -30,7 +29,6 @@ | ||||
| #include "include/cef_app.h" | ||||
| #include "include/cef_crash_util.h" | ||||
| #include "include/cef_file_util.h" | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "include/cef_origin_whitelist.h" | ||||
| #include "include/cef_parser.h" | ||||
| #include "include/cef_path_util.h" | ||||
| @@ -60,8 +58,6 @@ | ||||
| #include "libcef_dll/cpptoc/extension_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/find_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/focus_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/geolocation_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/get_geolocation_callback_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/jsdialog_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/keyboard_handler_cpptoc.h" | ||||
| #include "libcef_dll/cpptoc/life_span_handler_cpptoc.h" | ||||
| @@ -120,7 +116,6 @@ | ||||
| #include "libcef_dll/ctocpp/extension_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/file_dialog_callback_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/frame_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/geolocation_callback_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/get_extension_resource_callback_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/image_ctocpp.h" | ||||
| #include "libcef_dll/ctocpp/jsdialog_callback_ctocpp.h" | ||||
| @@ -281,12 +276,8 @@ CEF_GLOBAL void CefShutdown() { | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFindHandlerCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFocusHandlerCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefFrameCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefGeolocationCallbackCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefGeolocationHandlerCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero( | ||||
|       &CefGetExtensionResourceCallbackCToCpp::DebugObjCt)); | ||||
|   DCHECK( | ||||
|       base::AtomicRefCountIsZero(&CefGetGeolocationCallbackCppToC::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefImageCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefJSDialogCallbackCToCpp::DebugObjCt)); | ||||
|   DCHECK(base::AtomicRefCountIsZero(&CefJSDialogHandlerCppToC::DebugObjCt)); | ||||
| @@ -579,23 +570,6 @@ CEF_GLOBAL void CefLoadCRLSetsFile(const CefString& path) { | ||||
|   cef_load_crlsets_file(path.GetStruct()); | ||||
| } | ||||
|  | ||||
| CEF_GLOBAL bool CefGetGeolocation( | ||||
|     CefRefPtr<CefGetGeolocationCallback> callback) { | ||||
|   // AUTO-GENERATED CONTENT - DELETE THIS COMMENT BEFORE MODIFYING | ||||
|  | ||||
|   // Verify param: callback; type: refptr_diff | ||||
|   DCHECK(callback.get()); | ||||
|   if (!callback.get()) | ||||
|     return false; | ||||
|  | ||||
|   // Execute | ||||
|   int _retval = | ||||
|       cef_get_geolocation(CefGetGeolocationCallbackCppToC::Wrap(callback)); | ||||
|  | ||||
|   // Return type: bool | ||||
|   return _retval ? true : false; | ||||
| } | ||||
|  | ||||
| CEF_GLOBAL bool CefAddCrossOriginWhitelistEntry( | ||||
|     const CefString& source_origin, | ||||
|     const CefString& target_protocol, | ||||
|   | ||||
| @@ -9,7 +9,7 @@ | ||||
| // implementations. See the translator.README.txt file in the tools directory | ||||
| // for more information. | ||||
| // | ||||
| // $hash=981e50d71f62734221727297117cf18f0ed9fd2e$ | ||||
| // $hash=3fe3af71072987e46db28d1a94b8b6a9ad7d9e2a$ | ||||
| // | ||||
|  | ||||
| #ifndef CEF_LIBCEF_DLL_WRAPPER_TYPES_H_ | ||||
| @@ -62,10 +62,7 @@ enum CefWrapperType { | ||||
|   WT_FIND_HANDLER, | ||||
|   WT_FOCUS_HANDLER, | ||||
|   WT_FRAME, | ||||
|   WT_GEOLOCATION_CALLBACK, | ||||
|   WT_GEOLOCATION_HANDLER, | ||||
|   WT_GET_EXTENSION_RESOURCE_CALLBACK, | ||||
|   WT_GET_GEOLOCATION_CALLBACK, | ||||
|   WT_IMAGE, | ||||
|   WT_JSDIALOG_CALLBACK, | ||||
|   WT_JSDIALOG_HANDLER, | ||||
|   | ||||
| @@ -497,18 +497,6 @@ void ClientHandler::OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) { | ||||
|   NotifyTakeFocus(next); | ||||
| } | ||||
|  | ||||
| bool ClientHandler::OnRequestGeolocationPermission( | ||||
|     CefRefPtr<CefBrowser> browser, | ||||
|     const CefString& requesting_url, | ||||
|     int request_id, | ||||
|     CefRefPtr<CefGeolocationCallback> callback) { | ||||
|   CEF_REQUIRE_UI_THREAD(); | ||||
|  | ||||
|   // Allow geolocation access from all websites. | ||||
|   callback->Continue(true); | ||||
|   return true; | ||||
| } | ||||
|  | ||||
| bool ClientHandler::OnPreKeyEvent(CefRefPtr<CefBrowser> browser, | ||||
|                                   const CefKeyEvent& event, | ||||
|                                   CefEventHandle os_event, | ||||
|   | ||||
| @@ -31,7 +31,6 @@ class ClientHandler : public CefClient, | ||||
|                       public CefDownloadHandler, | ||||
|                       public CefDragHandler, | ||||
|                       public CefFocusHandler, | ||||
|                       public CefGeolocationHandler, | ||||
|                       public CefKeyboardHandler, | ||||
|                       public CefLifeSpanHandler, | ||||
|                       public CefLoadHandler, | ||||
| @@ -105,9 +104,6 @@ class ClientHandler : public CefClient, | ||||
|   CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE { return this; } | ||||
|   CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE { return this; } | ||||
|   CefRefPtr<CefFocusHandler> GetFocusHandler() OVERRIDE { return this; } | ||||
|   CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE { | ||||
|     return this; | ||||
|   } | ||||
|   CefRefPtr<CefKeyboardHandler> GetKeyboardHandler() OVERRIDE { return this; } | ||||
|   CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() OVERRIDE { return this; } | ||||
|   CefRefPtr<CefLoadHandler> GetLoadHandler() OVERRIDE { return this; } | ||||
| @@ -174,13 +170,6 @@ class ClientHandler : public CefClient, | ||||
|   // CefFocusHandler methods | ||||
|   void OnTakeFocus(CefRefPtr<CefBrowser> browser, bool next) OVERRIDE; | ||||
|  | ||||
|   // CefGeolocationHandler methods | ||||
|   bool OnRequestGeolocationPermission( | ||||
|       CefRefPtr<CefBrowser> browser, | ||||
|       const CefString& requesting_url, | ||||
|       int request_id, | ||||
|       CefRefPtr<CefGeolocationCallback> callback) OVERRIDE; | ||||
|  | ||||
|   // CefKeyboardHandler methods | ||||
|   bool OnPreKeyEvent(CefRefPtr<CefBrowser> browser, | ||||
|                      const CefKeyEvent& event, | ||||
|   | ||||
| @@ -13,7 +13,6 @@ | ||||
| <li><a href="draggable">Draggable Regions</a></li> | ||||
| <li><a href="drm">DRM (Clearkey, Widevine)</a></li> | ||||
| <li><a href="http://www.adobe.com/software/flash/about/">Flash Plugin</a> - requires "enable-system-flash" flag on Win/Mac and "ppapi-flash-path", "ppapi-flash-version" flags on Linux</li> | ||||
| <li><a href="http://html5demos.com/geo">Geolocation</a></li> | ||||
| <li><a href="http://www.html5test.com">HTML5 Feature Test</a></li> | ||||
| <li><a href="http://html5-demos.appspot.com/static/filesystem/filer.js/demos/index.html">HTML5 Filesystem</a> - requires "cache-path" flag</li> | ||||
| <li><a href="http://www.youtube.com/watch?v=siOHh0uzcuY&html5=True">HTML5 Video</a></li> | ||||
|   | ||||
| @@ -1,230 +0,0 @@ | ||||
| // Copyright (c) 2012 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. | ||||
|  | ||||
| #include "include/base/cef_bind.h" | ||||
| #include "include/cef_geolocation.h" | ||||
| #include "include/cef_waitable_event.h" | ||||
| #include "include/wrapper/cef_closure_task.h" | ||||
| #include "tests/ceftests/test_handler.h" | ||||
| #include "tests/ceftests/test_util.h" | ||||
| #include "tests/gtest/include/gtest/gtest.h" | ||||
|  | ||||
| // Comment in this define if you have configured API keys that enable Google | ||||
| // Maps Geolocation API support. | ||||
| // See https://www.chromium.org/developers/how-tos/api-keys for details. | ||||
| // #define HAS_GEOLOCATION_API_KEYS 1 | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| // Geolocation access is now restricted to "secure" origins. | ||||
| const char* kTestOrigin = "https://tests/"; | ||||
| const char* kTestUrl = "https://tests/GeolocationTestHandler"; | ||||
| const char* kTestAllowUrl = "https://tests/GeolocationTestHandler.Allow"; | ||||
| const char* kTestDenyUrl = "https://tests/GeolocationTestHandler.Deny"; | ||||
| const char* kTestCancelUrl = "https://tests/GeolocationTestHandler.Cancel"; | ||||
|  | ||||
| enum TestMode { | ||||
|   TEST_ALLOW, | ||||
|   TEST_DENY, | ||||
|   TEST_CANCEL, | ||||
| }; | ||||
|  | ||||
| class GeolocationTestHandler : public TestHandler { | ||||
|  public: | ||||
|   GeolocationTestHandler(const TestMode& mode, bool async) | ||||
|       : mode_(mode), async_(async), request_id_(-1) {} | ||||
|  | ||||
|   void RunTest() override { | ||||
|     std::string html = | ||||
|         "<html><head><script>" | ||||
|         "navigator.geolocation.getCurrentPosition(" | ||||
|         // Success function | ||||
|         "function() {" | ||||
|         "window.location.href = '" + | ||||
|         std::string(kTestAllowUrl) + | ||||
|         "'; }," | ||||
|         // Error function | ||||
|         "function() {" | ||||
|         "window.location.href = '" + | ||||
|         std::string(kTestDenyUrl) + "';  });"; | ||||
|     if (mode_ == TEST_CANCEL) | ||||
|       html += "window.location.href = '" + std::string(kTestCancelUrl) + "';"; | ||||
|     html += "</script></head><body>TEST START</body></html>"; | ||||
|     AddResource(kTestUrl, html, "text/html"); | ||||
|  | ||||
|     std::string end_html = "<html><body>TEST END</body></html>"; | ||||
|     AddResource(kTestAllowUrl, end_html, "text/html"); | ||||
|     AddResource(kTestDenyUrl, end_html, "text/html"); | ||||
|     AddResource(kTestCancelUrl, end_html, "text/html"); | ||||
|  | ||||
|     // Create the browser | ||||
|     CreateBrowser(kTestUrl); | ||||
|  | ||||
|     // Time out the test after a reasonable period of time. | ||||
|     SetTestTimeout(); | ||||
|   } | ||||
|  | ||||
|   void OnLoadEnd(CefRefPtr<CefBrowser> browser, | ||||
|                  CefRefPtr<CefFrame> frame, | ||||
|                  int httpStatusCode) override { | ||||
|     std::string url = frame->GetURL(); | ||||
|     if (url != kTestUrl) { | ||||
|       if (url == kTestAllowUrl) | ||||
|         got_allow_.yes(); | ||||
|       else if (url == kTestDenyUrl) | ||||
|         got_deny_.yes(); | ||||
|       else if (url == kTestCancelUrl) | ||||
|         got_cancel_.yes(); | ||||
|  | ||||
|       DestroyTest(); | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   void ExecuteCallback(CefRefPtr<CefGeolocationCallback> callback) { | ||||
|     if (mode_ == TEST_ALLOW) | ||||
|       callback->Continue(true); | ||||
|     else if (mode_ == TEST_DENY) | ||||
|       callback->Continue(false); | ||||
|   } | ||||
|  | ||||
|   bool OnRequestGeolocationPermission( | ||||
|       CefRefPtr<CefBrowser> browser, | ||||
|       const CefString& requesting_url, | ||||
|       int request_id, | ||||
|       CefRefPtr<CefGeolocationCallback> callback) override { | ||||
|     got_requestgeolocationpermission_.yes(); | ||||
|  | ||||
|     EXPECT_TRUE(CefCurrentlyOn(TID_UI)); | ||||
|  | ||||
|     EXPECT_STREQ(kTestOrigin, requesting_url.ToString().c_str()); | ||||
|     request_id_ = request_id; | ||||
|  | ||||
|     if (!async_) { | ||||
|       ExecuteCallback(callback); | ||||
|     } else { | ||||
|       CefPostTask(TID_UI, base::Bind(&GeolocationTestHandler::ExecuteCallback, | ||||
|                                      this, callback)); | ||||
|     } | ||||
|  | ||||
|     return true; | ||||
|   } | ||||
|  | ||||
|   void OnCancelGeolocationPermission(CefRefPtr<CefBrowser> browser, | ||||
|                                      int request_id) override { | ||||
|     got_cancelgeolocationpermission_.yes(); | ||||
|  | ||||
|     EXPECT_TRUE(CefCurrentlyOn(TID_UI)); | ||||
|  | ||||
|     EXPECT_EQ(request_id, request_id_); | ||||
|   } | ||||
|  | ||||
|   void DestroyTest() override { | ||||
|     EXPECT_TRUE(got_requestgeolocationpermission_); | ||||
|     if (mode_ == TEST_CANCEL) | ||||
|       EXPECT_TRUE(got_cancelgeolocationpermission_); | ||||
|     else | ||||
|       EXPECT_FALSE(got_cancelgeolocationpermission_); | ||||
|  | ||||
|     TestHandler::DestroyTest(); | ||||
|   } | ||||
|  | ||||
|   TestMode mode_; | ||||
|   bool async_; | ||||
|  | ||||
|   int request_id_; | ||||
|  | ||||
|   TrackCallback got_requestgeolocationpermission_; | ||||
|   TrackCallback got_cancelgeolocationpermission_; | ||||
|   TrackCallback got_allow_; | ||||
|   TrackCallback got_cancel_; | ||||
|   TrackCallback got_deny_; | ||||
|  | ||||
|   IMPLEMENT_REFCOUNTING(GeolocationTestHandler); | ||||
| }; | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| TEST(GeolocationTest, HandlerAllow) { | ||||
|   CefRefPtr<GeolocationTestHandler> handler = | ||||
|       new GeolocationTestHandler(TEST_ALLOW, false); | ||||
|   handler->ExecuteTest(); | ||||
| #if defined(HAS_GEOLOCATION_API_KEYS) | ||||
|   EXPECT_TRUE(handler->got_allow_); | ||||
| #else | ||||
|   EXPECT_FALSE(handler->got_allow_); | ||||
| #endif | ||||
|   ReleaseAndWaitForDestructor(handler); | ||||
| } | ||||
|  | ||||
| TEST(GeolocationTest, HandlerAllowAsync) { | ||||
|   CefRefPtr<GeolocationTestHandler> handler = | ||||
|       new GeolocationTestHandler(TEST_ALLOW, true); | ||||
|   handler->ExecuteTest(); | ||||
| #if defined(HAS_GEOLOCATION_API_KEYS) | ||||
|   EXPECT_TRUE(handler->got_allow_); | ||||
| #else | ||||
|   EXPECT_FALSE(handler->got_allow_); | ||||
| #endif | ||||
|   ReleaseAndWaitForDestructor(handler); | ||||
| } | ||||
|  | ||||
| TEST(GeolocationTest, HandlerDeny) { | ||||
|   CefRefPtr<GeolocationTestHandler> handler = | ||||
|       new GeolocationTestHandler(TEST_DENY, false); | ||||
|   handler->ExecuteTest(); | ||||
|   EXPECT_TRUE(handler->got_deny_); | ||||
|   ReleaseAndWaitForDestructor(handler); | ||||
| } | ||||
|  | ||||
| TEST(GeolocationTest, HandlerDenyAsync) { | ||||
|   CefRefPtr<GeolocationTestHandler> handler = | ||||
|       new GeolocationTestHandler(TEST_DENY, true); | ||||
|   handler->ExecuteTest(); | ||||
|   EXPECT_TRUE(handler->got_deny_); | ||||
|   ReleaseAndWaitForDestructor(handler); | ||||
| } | ||||
|  | ||||
| TEST(GeolocationTest, HandlerCancel) { | ||||
|   CefRefPtr<GeolocationTestHandler> handler = | ||||
|       new GeolocationTestHandler(TEST_CANCEL, false); | ||||
|   handler->ExecuteTest(); | ||||
|   EXPECT_TRUE(handler->got_cancel_); | ||||
|   ReleaseAndWaitForDestructor(handler); | ||||
| } | ||||
|  | ||||
| namespace { | ||||
|  | ||||
| class TestGetGeolocationCallback : public CefGetGeolocationCallback { | ||||
|  public: | ||||
|   explicit TestGetGeolocationCallback(CefRefPtr<CefWaitableEvent> event) | ||||
|       : event_(event) {} | ||||
|  | ||||
|   void OnLocationUpdate(const CefGeoposition& position) override { | ||||
|     EXPECT_TRUE(CefCurrentlyOn(TID_UI)); | ||||
| #if defined(HAS_GEOLOCATION_API_KEYS) | ||||
|     EXPECT_EQ(GEOPOSITON_ERROR_NONE, position.error_code); | ||||
| #else | ||||
|     EXPECT_EQ(GEOPOSITON_ERROR_POSITION_UNAVAILABLE, position.error_code); | ||||
| #endif | ||||
|     EXPECT_NE(0.0, position.latitude); | ||||
|     EXPECT_NE(0.0, position.longitude); | ||||
|     EXPECT_NE(0.0, position.accuracy); | ||||
|     EXPECT_NE(0, position.timestamp.year); | ||||
|     event_->Signal(); | ||||
|   } | ||||
|  | ||||
|  private: | ||||
|   CefRefPtr<CefWaitableEvent> event_; | ||||
|  | ||||
|   IMPLEMENT_REFCOUNTING(TestGetGeolocationCallback); | ||||
| }; | ||||
|  | ||||
| }  // namespace | ||||
|  | ||||
| TEST(GeolocationTest, GetGeolocation) { | ||||
|   CefRefPtr<CefWaitableEvent> event = | ||||
|       CefWaitableEvent::CreateWaitableEvent(true, false); | ||||
|   CefGetGeolocation(new TestGetGeolocationCallback(event)); | ||||
|   event->Wait(); | ||||
| } | ||||
| @@ -59,7 +59,6 @@ class TestHandler : public CefClient, | ||||
|                     public CefDisplayHandler, | ||||
|                     public CefDownloadHandler, | ||||
|                     public CefDragHandler, | ||||
|                     public CefGeolocationHandler, | ||||
|                     public CefJSDialogHandler, | ||||
|                     public CefLifeSpanHandler, | ||||
|                     public CefLoadHandler, | ||||
| @@ -156,9 +155,6 @@ class TestHandler : public CefClient, | ||||
|   CefRefPtr<CefDisplayHandler> GetDisplayHandler() override { return this; } | ||||
|   CefRefPtr<CefDownloadHandler> GetDownloadHandler() override { return this; } | ||||
|   CefRefPtr<CefDragHandler> GetDragHandler() override { return this; } | ||||
|   CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() override { | ||||
|     return this; | ||||
|   } | ||||
|   CefRefPtr<CefJSDialogHandler> GetJSDialogHandler() override { return this; } | ||||
|   CefRefPtr<CefLifeSpanHandler> GetLifeSpanHandler() override { return this; } | ||||
|   CefRefPtr<CefLoadHandler> GetLoadHandler() override { return this; } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user