From 16b9df32ceacbec31650338366a83980ecaa1a19 Mon Sep 17 00:00:00 2001 From: zourongchun Date: Thu, 14 Sep 2023 16:28:56 +0800 Subject: [PATCH 1/2] Revert "add patch to 09041120" This reverts commit 4110916f1e64d87c902059914864fc6676973079. --- base/files/file_path.cc | 3 +- base/trace_event/common/trace_event_common.h | 337 +++++------------- base/trace_event/trace_event_ohos.cc | 54 ++- base/trace_event/trace_event_ohos.h | 13 +- base/tracing/protos/chrome_track_event.proto | 2 + cc/metrics/compositor_frame_reporter.cc | 2 +- cc/metrics/event_metrics.cc | 2 +- cc/metrics/event_metrics.h | 2 +- .../async_layer_tree_frame_sink.cc | 12 - .../core/browser/browser_autofill_manager.cc | 3 +- .../content_settings_default_provider.cc | 19 +- .../embedder_support/user_agent_utils.cc | 2 +- components/os_crypt/BUILD.gn | 9 +- components/os_crypt/ohos_crypto.cc | 163 --------- components/os_crypt/ohos_crypto.h | 28 -- components/os_crypt/ohos_keystore.cc | 98 ----- components/os_crypt/ohos_keystore.h | 36 -- components/os_crypt/os_crypt_linux.cc | 38 -- .../password_manager/core/browser/BUILD.gn | 9 - .../core/browser/form_fetcher_impl.cc | 5 +- .../core/browser/form_parsing/form_parser.cc | 33 -- .../browser/oh_sync_credentials_filter.cc | 54 --- .../core/browser/oh_sync_credentials_filter.h | 48 --- .../core/browser/password_autofill_manager.cc | 11 - .../core/browser/password_form_manager.cc | 4 - .../core/browser/password_store.cc | 12 - .../core/browser/password_store.h | 5 - .../core/browser/password_store_backend.h | 5 - ...sword_store_backend_migration_decorator.cc | 8 - ...ssword_store_backend_migration_decorator.h | 5 - .../password_store_built_in_backend.cc | 10 - .../browser/password_store_built_in_backend.h | 6 - .../browser/password_store_proxy_backend.cc | 7 - .../browser/password_store_proxy_backend.h | 5 - .../core/browser/test_password_store.cc | 8 - .../core/browser/test_password_store.h | 6 - .../core/common/password_manager_features.cc | 8 +- components/policy/core/common/BUILD.gn | 6 - .../policy/core/common/policy_loader_ohos.cc | 113 ------ .../policy/core/common/policy_loader_ohos.h | 35 -- .../browser/print_to_pdf/pdf_print_manager.cc | 4 - .../browser/print_to_pdf/pdf_print_manager.h | 3 - components/printing/common/print.mojom | 3 - .../renderer/print_render_frame_helper.cc | 42 +-- .../renderer/print_render_frame_helper.h | 13 - .../viz/client/frame_eviction_manager.cc | 2 +- .../display_embedder/compositor_gpu_thread.cc | 25 -- .../frame_sinks/compositor_frame_sink_impl.cc | 25 -- .../frame_sinks/compositor_frame_sink_impl.h | 10 - .../compositor_frame_sink_support.cc | 5 +- .../external_begin_frame_source_ohos.cc | 34 +- .../external_begin_frame_source_ohos.h | 10 +- .../root_compositor_frame_sink_impl.h | 4 +- .../main/viz_compositor_thread_runner_impl.cc | 26 -- .../browser/devtools/devtools_http_handler.cc | 8 +- content/browser/gpu/gpu_process_host.cc | 18 - .../media/session/media_session_impl.cc | 3 - .../media/session/media_session_impl.h | 5 +- .../renderer_host/input/fling_controller.cc | 2 +- .../render_widget_host_latency_tracker.cc | 2 +- .../input/stylus_text_selector.cc | 2 +- .../touchscreen_tap_suppression_controller.cc | 2 +- .../render_frame_host_delegate.h | 4 +- .../renderer_host/render_frame_host_impl.cc | 4 +- .../renderer_host/render_frame_host_impl.h | 4 +- .../renderer_host/render_process_host_impl.cc | 14 - content/browser/storage_partition_impl.cc | 25 ++ content/browser/storage_partition_impl.h | 9 + .../browser/web_contents/web_contents_impl.cc | 60 +--- .../browser/web_contents/web_contents_impl.h | 39 +- content/common/frame.mojom | 2 + .../public/browser/content_browser_client.cc | 6 - content/public/browser/render_frame_host.h | 4 +- content/public/browser/storage_partition.h | 3 + content/public/browser/web_contents.h | 22 +- .../public/browser/web_contents_delegate.cc | 2 +- .../public/browser/web_contents_delegate.h | 18 +- .../browser/web_contents_view_delegate.cc | 4 +- .../browser/web_contents_view_delegate.h | 4 +- content/renderer/render_frame_impl.cc | 4 +- content/renderer/render_frame_impl.h | 2 +- content/renderer/render_remote_proxy.cc | 3 +- content/test/test_render_frame.cc | 2 +- crypto/encryptor.cc | 208 +---------- crypto/encryptor.h | 13 - media/audio/audio_thread_impl.cc | 19 - .../audio/ohos/ohos_audio_capturer_source.cc | 11 +- media/audio/ohos/ohos_audio_capturer_source.h | 1 - media/audio/ohos/ohos_audio_manager.cc | 78 +--- media/audio/ohos/ohos_audio_manager.h | 17 +- media/audio/ohos/ohos_audio_output_stream.cc | 112 +++--- media/audio/ohos/ohos_audio_output_stream.h | 6 +- mojo/public/cpp/bindings/lib/message.cc | 2 +- net/cert/cert_verify_proc_ohos.cc | 38 +- .../proxy_config_service_ohos.cc | 20 +- net/socket/unix_domain_client_socket_posix.cc | 9 +- ohos_nweb/BUILD.gn | 1 - ohos_nweb/include/nweb.h | 15 - ohos_nweb/include/nweb_cookie_manager.h | 2 +- ohos_nweb/include/nweb_handler.h | 6 +- .../capi/nweb_app_client_extension_callback.h | 11 - .../capi/nweb_storage_extension_callback.h | 30 -- .../nweb_cookie_manager_delegate.cc | 76 ++-- .../nweb_cookie_manager_delegate.h | 2 +- ohos_nweb/src/cef_delegate/nweb_delegate.cc | 216 +++-------- ohos_nweb/src/cef_delegate/nweb_delegate.h | 12 - .../src/cef_delegate/nweb_drag_data_impl.cc | 82 ++--- .../src/cef_delegate/nweb_drag_data_impl.h | 3 - .../src/cef_delegate/nweb_event_handler.cc | 10 +- .../src/cef_delegate/nweb_handler_delegate.cc | 81 +---- .../src/cef_delegate/nweb_handler_delegate.h | 17 +- .../src/cef_delegate/nweb_render_handler.cc | 10 - .../src/cef_delegate/nweb_render_handler.h | 1 - .../cef_delegate/nweb_web_storage_delegate.cc | 160 --------- .../cef_delegate/nweb_web_storage_delegate.h | 20 -- .../nweb_cookie_manager_delegate_interface.h | 2 +- ohos_nweb/src/nweb_cookie_manager_impl.cc | 4 +- ohos_nweb/src/nweb_cookie_manager_impl.h | 2 +- ohos_nweb/src/nweb_delegate_interface.h | 10 - ohos_nweb/src/nweb_impl.cc | 203 +++++------ ohos_nweb/src/nweb_impl.h | 21 +- ohos_nweb/src/nweb_inputmethod_handler.cc | 68 ++-- ohos_nweb/src/nweb_inputmethod_handler.h | 2 - ohos_nweb/src/nweb_output_handler.cc | 15 - ohos_nweb/src/nweb_output_handler.h | 1 - .../src/nweb_web_storage_delegate_interface.h | 20 -- ohos_nweb/src/nweb_web_storage_impl.cc | 52 --- ohos_nweb/src/nweb_web_storage_impl.h | 16 - .../ohos/location_provider_ohos.cc | 7 - services/network/cookie_manager.cc | 28 -- services/network/cookie_manager.h | 14 - services/network/network_context.cc | 12 - services/network/network_context.h | 13 +- .../network/public/mojom/cookie_manager.mojom | 17 - .../compositing/compositor_frame_sink.mojom | 5 - ui/events/blink/blink_event_util.cc | 4 +- ui/events/devices/device_data_manager.cc | 186 ++++------ ui/events/devices/device_data_manager.h | 1 - ui/events/event.cc | 2 +- ui/events/event_utils.cc | 2 +- .../filtered_gesture_provider.cc | 2 +- .../filtered_gesture_provider.h | 2 +- .../gesture_configuration.cc | 2 +- .../gesture_detection/gesture_configuration.h | 4 +- .../gesture_configuration_android.cc | 2 +- .../gesture_detection/gesture_detector.cc | 32 +- .../gesture_detection/gesture_detector.h | 8 +- .../gesture_detection/gesture_listeners.cc | 2 +- .../gesture_detection/gesture_listeners.h | 6 +- .../gesture_detection/gesture_provider.cc | 12 +- .../gesture_detection/gesture_provider.h | 2 +- .../gesture_provider_config_helper.cc | 2 +- .../gesture_provider_unittest.cc | 18 +- .../gesture_touch_uma_histogram.cc | 4 +- .../gesture_touch_uma_histogram.h | 2 + ui/events/gesture_detection/motion_event.cc | 2 +- ui/events/gesture_detection/motion_event.h | 2 +- .../gesture_detection/motion_event_generic.cc | 8 +- .../gesture_detection/motion_event_generic.h | 6 +- .../touch_disposition_gesture_filter.cc | 2 +- ui/events/types/event_type.h | 2 +- ui/views/animation/ink_drop_event_handler.cc | 2 +- ui/views/controls/scrollbar/scroll_bar.cc | 2 +- 163 files changed, 766 insertions(+), 3065 deletions(-) delete mode 100644 components/os_crypt/ohos_crypto.cc delete mode 100644 components/os_crypt/ohos_crypto.h delete mode 100644 components/os_crypt/ohos_keystore.cc delete mode 100644 components/os_crypt/ohos_keystore.h delete mode 100644 components/password_manager/core/browser/oh_sync_credentials_filter.cc delete mode 100644 components/password_manager/core/browser/oh_sync_credentials_filter.h delete mode 100644 components/policy/core/common/policy_loader_ohos.cc delete mode 100644 components/policy/core/common/policy_loader_ohos.h delete mode 100644 ohos_nweb/src/capi/nweb_storage_extension_callback.h diff --git a/base/files/file_path.cc b/base/files/file_path.cc index 909b4e1bce..abfbf333a2 100644 --- a/base/files/file_path.cc +++ b/base/files/file_path.cc @@ -1407,8 +1407,7 @@ bool FilePath::IsContentUri() const { bool FilePath::IsDataShareUri() const { return StartsWith(path_, "datashare://", base::CompareCase::INSENSITIVE_ASCII) || StartsWith(path_, "dataability://", base::CompareCase::INSENSITIVE_ASCII) || - StartsWith(path_, "file://media/", base::CompareCase::INSENSITIVE_ASCII) || - StartsWith(path_, "file://docs/", base::CompareCase::INSENSITIVE_ASCII);; + StartsWith(path_, "file://media/", base::CompareCase::INSENSITIVE_ASCII); } #endif } // namespace base diff --git a/base/trace_event/common/trace_event_common.h b/base/trace_event/common/trace_event_common.h index 920fbb93d9..7476df00b6 100644 --- a/base/trace_event/common/trace_event_common.h +++ b/base/trace_event/common/trace_event_common.h @@ -383,14 +383,17 @@ template std::string GetStringFromArgs(const char* name, const char* arg1_name, ARG1_TYPE&& arg1_val) { - std::string str(name); - base::trace_event::TraceArguments args(arg1_name, - std::forward(arg1_val)); - str += " | "; - str += arg1_name; - str += "="; - args.values()[0].AppendAsString(args.types()[0], &str); - return str; + if (IsBytraceEnable()) { + std::string str(name); + base::trace_event::TraceArguments args(arg1_name, + std::forward(arg1_val)); + str += " | "; + str += arg1_name; + str += "="; + args.values()[0].AppendAsString(args.types()[0], &str); + return str; + } + return ""; } template @@ -399,50 +402,35 @@ std::string GetStringFromArgs(const char* name, ARG1_TYPE&& arg1_val, const char* arg2_name, ARG2_TYPE&& arg2_val) { - std::string str(name); - base::trace_event::TraceArguments args( - arg1_name, std::forward(arg1_val), arg2_name, - std::forward(arg2_val)); - str += " | "; - str += arg1_name; - str += "="; - args.values()[0].AppendAsString(args.types()[0], &str); - str += " | "; - str += arg2_name; - str += "="; - args.values()[1].AppendAsString(args.types()[1], &str); - return str; + if (IsBytraceEnable()) { + std::string str(name); + base::trace_event::TraceArguments args( + arg1_name, std::forward(arg1_val), arg2_name, + std::forward(arg2_val)); + str += " | "; + str += arg1_name; + str += "="; + args.values()[0].AppendAsString(args.types()[0], &str); + str += " | "; + str += arg2_name; + str += "="; + args.values()[1].AppendAsString(args.types()[1], &str); + return str; + } + return ""; } #endif #if defined(OS_OHOS) #define TRACE_EVENT0(category_group, name) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(name); \ - } \ - } while(0) - + (void)(category_group); \ + BYTRACE_SCOPED(name); #define TRACE_EVENT1(category_group, name, arg1_name, arg1_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while(0) - -#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val, \ - arg2_name, arg2_val)); \ - } \ - } while(0) + TRACE_EVENT0(category_group, GetStringFromArgs(name, arg1_name, arg1_val)); +#define TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, \ + arg2_val) \ + TRACE_EVENT0(category_group, GetStringFromArgs(name, arg1_name, arg1_val, \ + arg2_name, arg2_val)); #else #define TRACE_EVENT0(category_group, name) \ INTERNAL_TRACE_EVENT_ADD_SCOPED(category_group, name) @@ -456,37 +444,20 @@ std::string GetStringFromArgs(const char* name, #if defined(OS_OHOS) #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_flags) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(bind_id); \ - (void)(flow_flags); \ - BYTRACE_SCOPED_TRACE_EVENT(name); \ - } \ - } while(0) + (void)(category_group); \ + (void)(bind_id); \ + (void)(flow_flags); \ + BYTRACE_SCOPED(name); #define TRACE_EVENT_WITH_FLOW1(category_group, name, bind_id, flow_flags, \ arg1_name, arg1_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(bind_id); \ - (void)(flow_flags); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while(0) + TRACE_EVENT_WITH_FLOW0(category_group, \ + GetStringFromArgs(name, arg1_name, arg1_val), \ + bind_id, flow_flags); #define TRACE_EVENT_WITH_FLOW2(category_group, name, bind_id, flow_flags, \ arg1_name, arg1_val, arg2_name, arg2_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(bind_id); \ - (void)(flow_flags); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val, arg2_name, arg2_val)); \ - } \ - } while(0) + TRACE_EVENT_WITH_FLOW0(category_group, \ + GetStringFromArgs(name, arg1_name, arg1_val, arg2_name, arg2_val), \ + bind_id, flow_flags); #else #define TRACE_EVENT_WITH_FLOW0(category_group, name, bind_id, flow_flags) \ INTERNAL_TRACE_EVENT_ADD_SCOPED_WITH_FLOW(category_group, name, bind_id, \ @@ -557,27 +528,15 @@ std::string GetStringFromArgs(const char* name, // literals). They may not include " chars. #if defined(OS_OHOS) #define TRACE_EVENT_BEGIN0(category_group, name) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - StartBytrace(name); \ - } \ - } while (0) + (void)(category_group); \ + StartBytrace(name) #define TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - StartBytrace(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while (0) + TRACE_EVENT_BEGIN0(category_group, \ + GetStringFromArgs(name, arg1_name, arg1_val)) #define TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - StartBytrace(GetStringFromArgs(name, arg1_name, arg1_val, arg2_name, arg2_val)); \ - } \ - } while (0) + TRACE_EVENT_BEGIN0(category_group, GetStringFromArgs(name, arg1_name, \ + arg1_val, arg2_name, arg2_val)) #else #define TRACE_EVENT_BEGIN0(category_group, name) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, \ @@ -594,30 +553,16 @@ std::string GetStringFromArgs(const char* name, #if defined(OS_OHOS) #define TRACE_EVENT_BEGIN_WITH_FLAGS0(category_group, name, flags) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(flags); \ - StartBytrace(name); \ - } \ - } while (0) + (void)(flags); \ + TRACE_EVENT_BEGIN0(category_group, name) #define TRACE_EVENT_BEGIN_WITH_FLAGS1(category_group, name, flags, arg1_name, \ arg1_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(flags); \ - StartBytrace(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while (0) + (void)(flags); \ + TRACE_EVENT_BEGIN1(category_group, name, arg1_name, arg1_name) #define TRACE_EVENT_COPY_BEGIN2(category_group, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - StartBytrace(GetStringFromArgs(name, arg1_name, arg1_val, arg2_name, arg2_val)); \ - } \ - } while (0) + TRACE_EVENT_BEGIN2(category_group, name, arg1_name, arg1_name, \ + arg2_name, arg2_val) #else #define TRACE_EVENT_BEGIN_WITH_FLAGS0(category_group, name, flags) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_BEGIN, category_group, name, flags) @@ -670,36 +615,20 @@ std::string GetStringFromArgs(const char* name, // literals). They may not include " chars. #if defined(OS_OHOS) #define TRACE_EVENT_END0(category_group, name) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(category_group); \ + (void)(name); \ + FinishBytrace() #define TRACE_EVENT_END1(category_group, name, arg1_name, arg1_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - (void)(arg1_name); \ - (void)(arg1_val); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(arg1_name); \ + (void)(arg1_val); \ + TRACE_EVENT_END0(category_group, name) #define TRACE_EVENT_END2(category_group, name, arg1_name, arg1_val, arg2_name, \ arg2_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - (void)(arg1_name); \ - (void)(arg1_val); \ - (void)(arg2_name); \ - (void)(arg2_val); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(arg1_name); \ + (void)(arg1_val); \ + (void)(arg2_name); \ + (void)(arg2_val); \ + TRACE_EVENT_END0(category_group, name) #else #define TRACE_EVENT_END0(category_group, name) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, \ @@ -716,39 +645,21 @@ std::string GetStringFromArgs(const char* name, #if defined(OS_OHOS) #define TRACE_EVENT_END_WITH_FLAGS0(category_group, name, flags) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - (void)(flags); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(flags); \ + TRACE_EVENT_END0(category_group, name) #define TRACE_EVENT_END_WITH_FLAGS1(category_group, name, flags, arg1_name, \ arg1_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - (void)(arg1_name); \ - (void)(arg1_val); \ - (void)(flags); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(flags); \ + (void)(arg1_name); \ + (void)(arg1_val); \ + TRACE_EVENT_END0(category_group, name) #define TRACE_EVENT_COPY_END2(category_group, name, arg1_name, arg1_val, \ arg2_name, arg2_val) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(name); \ - (void)(arg1_name); \ - (void)(arg1_val); \ - (void)(arg2_name); \ - (void)(arg2_val); \ - FinishBytrace(); \ - } \ - } while (0) + (void)(arg1_name); \ + (void)(arg1_val); \ + (void)(arg2_name); \ + (void)(arg2_val); \ + TRACE_EVENT_END0(category_group, name) #else #define TRACE_EVENT_END_WITH_FLAGS0(category_group, name, flags) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_END, category_group, name, flags) @@ -769,36 +680,17 @@ std::string GetStringFromArgs(const char* name, // doesn't run all tests with tracing enabled. #if defined(OS_OHOS) #define TRACE_EVENT_MARK_WITH_TIMESTAMP0(category_group, name, timestamp) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(timestamp); \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(name); \ - } \ - } while (0) + (void)(timestamp); \ + TRACE_EVENT0(category_group, name); #define TRACE_EVENT_MARK_WITH_TIMESTAMP1(category_group, name, timestamp, \ arg1_name, arg1_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(timestamp); \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while (0) + (void)(timestamp); \ + TRACE_EVENT1(category_group, name, arg1_name, arg1_val); #define TRACE_EVENT_MARK_WITH_TIMESTAMP2( \ category_group, name, timestamp, arg1_name, arg1_val, arg2_name, arg2_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(timestamp); \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val, \ - arg2_name, arg2_val)); \ - } \ - } while (0) + (void)(timestamp); \ + TRACE_EVENT2(category_group, name, arg1_name, arg1_val, arg2_name, arg2_val); #else #define TRACE_EVENT_MARK_WITH_TIMESTAMP0(category_group, name, timestamp) \ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \ @@ -820,32 +712,14 @@ std::string GetStringFromArgs(const char* name, #if defined(OS_OHOS) #define TRACE_EVENT_COPY_MARK(category_group, name) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(name); \ - } \ - } while (0) + TRACE_EVENT0(category_group, name); #define TRACE_EVENT_COPY_MARK1(category_group, name, arg1_name, arg1_val) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - BYTRACE_SCOPED_TRACE_EVENT(GetStringFromArgs(name, arg1_name, arg1_val)); \ - } \ - } while (0) + TRACE_EVENT1(category_group, name, arg1_name, arg1_val); #define TRACE_EVENT_COPY_MARK_WITH_TIMESTAMP(category_group, name, timestamp) \ - BYTRACE_SCOPED_INIT(); \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(timestamp); \ - BYTRACE_SCOPED_TRACE_EVENT(name); \ - } \ - } while (0) + (void)(timestamp); \ + TRACE_EVENT_COPY_MARK(category_group, name); #else #define TRACE_EVENT_COPY_MARK(category_group, name) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_MARK, category_group, name, \ @@ -899,27 +773,15 @@ std::string GetStringFromArgs(const char* name, // literals). They may not include " chars. #if defined(OS_OHOS) #define TRACE_COUNTER1(category_group, name, value) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - CountBytrace(name, value); \ - } \ - } while (0) + (void)(category_group); \ + CountBytrace(name, value); #define TRACE_COUNTER_WITH_FLAG1(category_group, name, flag, value) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(flag); \ - CountBytrace(name, value); \ - } \ - } while (0) + (void)(category_group); \ + (void)(flag); \ + CountBytrace(name, value); #define TRACE_COPY_COUNTER1(category_group, name, value) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group);\ - CountBytrace(name, static_cast(value)); \ - } \ - } while (0) + (void)(category_group); \ + CountBytrace(name, static_cast(value)); #else #define TRACE_COUNTER1(category_group, name, value) \ INTERNAL_TRACE_EVENT_ADD(TRACE_EVENT_PHASE_COUNTER, category_group, name, \ @@ -958,13 +820,8 @@ std::string GetStringFromArgs(const char* name, // enabled, as the commit queue doesn't run all tests with tracing enabled. #if defined(OS_OHOS) #define TRACE_COUNTER_WITH_TIMESTAMP1(category_group, name, timestamp, value) \ - do { \ - if (IsBytraceEnable()) { \ - (void)(category_group); \ - (void)(timestamp); \ - CountBytrace(name, value); \ - } \ - } while (0) + (void)(timestamp); \ + TRACE_COUNTER1(category_group, name, value); #else #define TRACE_COUNTER_WITH_TIMESTAMP1(category_group, name, timestamp, value) \ INTERNAL_TRACE_EVENT_ADD_WITH_TIMESTAMP( \ diff --git a/base/trace_event/trace_event_ohos.cc b/base/trace_event/trace_event_ohos.cc index ee686badf9..effe550573 100755 --- a/base/trace_event/trace_event_ohos.cc +++ b/base/trace_event/trace_event_ohos.cc @@ -15,27 +15,17 @@ #include "base/trace_event/trace_event_ohos.h" -#include -#include - #include "base/logging.h" #include "ohos_adapter_helper.h" using OHOS::NWeb::OhosAdapterHelper; bool IsBytraceEnable() { - static bool traceStatus = false; - static time_t lastTime = 0; - time_t nowTime; - nowTime = time(0); - if (nowTime == lastTime) { - return traceStatus; - } - lastTime = nowTime; - traceStatus = OhosAdapterHelper::GetInstance() - .GetHiTraceAdapterInstance() - .IsHiTraceEnable(); - return traceStatus; +#if defined(ENABLE_OHOS_BYTRACE) + return true; +#else + return false; +#endif } BytraceArg GetArg(double i) { @@ -71,44 +61,48 @@ std::string GetStringWithArgs(const std::string& name) { } void StartBytrace(const std::string& value) { +#if defined(ENABLE_OHOS_BYTRACE) OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartTrace( value); +#endif } void FinishBytrace() { +#if defined(ENABLE_OHOS_BYTRACE) OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishTrace(); +#endif } void StartAsyncBytrace(const std::string& value, int32_t taskId) { - OhosAdapterHelper::GetInstance() - .GetHiTraceAdapterInstance() - .StartAsyncTrace(value, taskId); +#if defined(ENABLE_OHOS_BYTRACE) + OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartAsyncTrace( + value, taskId); +#endif } void FinishAsyncBytrace(const std::string& value, int32_t taskId) { - OhosAdapterHelper::GetInstance() - .GetHiTraceAdapterInstance() - .FinishAsyncTrace(value, taskId); +#if defined(ENABLE_OHOS_BYTRACE) + OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishAsyncTrace( + value, taskId); +#endif } void CountBytrace(const std::string& name, int64_t count) { +#if defined(ENABLE_OHOS_BYTRACE) OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().CountTrace( name, count); +#endif } ScopedBytrace::ScopedBytrace(const std::string& proc) : proc_(proc) { +#if defined(ENABLE_OHOS_BYTRACE) OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartTrace( proc_); +#endif } -void ScopedBytrace::SendTraceEvent(const std::string& data) { - OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().StartTrace(data); -} - -ScopedBytrace::ScopedBytrace() {} - ScopedBytrace::~ScopedBytrace() { - if (IsBytraceEnable()) { - OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishTrace(); - } +#if defined(ENABLE_OHOS_BYTRACE) + OhosAdapterHelper::GetInstance().GetHiTraceAdapterInstance().FinishTrace(); +#endif } diff --git a/base/trace_event/trace_event_ohos.h b/base/trace_event/trace_event_ohos.h index ff554b6bf1..b46f5b85a5 100755 --- a/base/trace_event/trace_event_ohos.h +++ b/base/trace_event/trace_event_ohos.h @@ -76,21 +76,18 @@ void CountBytrace(const std::string& name, int64_t count); class ScopedBytrace { public: ScopedBytrace(const std::string& proc); - ScopedBytrace(); ~ScopedBytrace(); - static void SendTraceEvent(const std::string& data); + private: std::string proc_; }; - + #define OHOS_BY_TRACE_CONNENCT(a, b) a##b #define OHOS_BY_TRACE_NAME2(a, b) OHOS_BY_TRACE_CONNENCT(a, b) #define OHOS_BY_TRACE_NAME(a) OHOS_BY_TRACE_NAME2(a, __LINE__) -#define BYTRACE_SCOPED_INIT() \ - ScopedBytrace OHOS_BY_TRACE_NAME(bytrace) - -#define BYTRACE_SCOPED_TRACE_EVENT(name) \ - ScopedBytrace::SendTraceEvent(name) +#define BYTRACE_SCOPED(name, ...) \ + ScopedBytrace OHOS_BY_TRACE_NAME(bytrace)( \ + GetStringWithArgs(name, ##__VA_ARGS__)) #endif // BASE_TRACE_EVENT_TRACE_EVENT_OHOS_H_ diff --git a/base/tracing/protos/chrome_track_event.proto b/base/tracing/protos/chrome_track_event.proto index 74b21128f5..f11f71ba9c 100644 --- a/base/tracing/protos/chrome_track_event.proto +++ b/base/tracing/protos/chrome_track_event.proto @@ -644,7 +644,9 @@ message EventLatency { GESTURE_PINCH_END = 24; GESTURE_PINCH_UPDATE = 25; INERTIAL_GESTURE_SCROLL_UPDATE = 26; + // #ifdef OHOS_ENABLE_DRAG_DROP GESTURE_DRAG_LONG_PRESS =27; + // #endif } optional EventType event_type = 1; diff --git a/cc/metrics/compositor_frame_reporter.cc b/cc/metrics/compositor_frame_reporter.cc index 4847fccd6f..a9bde28c42 100644 --- a/cc/metrics/compositor_frame_reporter.cc +++ b/cc/metrics/compositor_frame_reporter.cc @@ -367,7 +367,7 @@ perfetto::protos::pbzero::EventLatency::EventType ToProtoEnum( CASE(kGestureScrollEnd, GESTURE_SCROLL_END); CASE(kGestureDoubleTap, GESTURE_DOUBLE_TAP); CASE(kGestureLongPress, GESTURE_LONG_PRESS); - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP CASE(kGestureDragLongPress, GESTURE_DRAG_LONG_PRESS); #endif CASE(kGestureLongTap, GESTURE_LONG_TAP); diff --git a/cc/metrics/event_metrics.cc b/cc/metrics/event_metrics.cc index 3fd8143cc1..7ebb950ed6 100644 --- a/cc/metrics/event_metrics.cc +++ b/cc/metrics/event_metrics.cc @@ -43,7 +43,7 @@ constexpr struct { EVENT_TYPE(GestureScrollEnd, ui::ET_GESTURE_SCROLL_END, false), EVENT_TYPE(GestureDoubleTap, ui::ET_GESTURE_DOUBLE_TAP), EVENT_TYPE(GestureLongPress, ui::ET_GESTURE_LONG_PRESS), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP EVENT_TYPE(GestureDragLongPress, ui::ET_GESTURE_DRAG_LONG_PRESS), #endif EVENT_TYPE(GestureLongTap, ui::ET_GESTURE_LONG_TAP), diff --git a/cc/metrics/event_metrics.h b/cc/metrics/event_metrics.h index d01d5f18de..fbe5379846 100644 --- a/cc/metrics/event_metrics.h +++ b/cc/metrics/event_metrics.h @@ -46,7 +46,7 @@ class CC_EXPORT EventMetrics { kGestureScrollEnd, kGestureDoubleTap, kGestureLongPress, -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP kGestureDragLongPress, #endif kGestureLongTap, diff --git a/cc/mojo_embedder/async_layer_tree_frame_sink.cc b/cc/mojo_embedder/async_layer_tree_frame_sink.cc index 186da64787..522c1a6f1b 100644 --- a/cc/mojo_embedder/async_layer_tree_frame_sink.cc +++ b/cc/mojo_embedder/async_layer_tree_frame_sink.cc @@ -23,10 +23,6 @@ #include "components/viz/common/hit_test/hit_test_region_list.h" #include "components/viz/common/quads/compositor_frame.h" -#if BUILDFLAG(IS_OHOS) -#include "base/process/process_handle.h" -#endif - namespace cc { namespace mojo_embedder { @@ -112,14 +108,6 @@ bool AsyncLayerTreeFrameSink::BindToClient(LayerTreeFrameSinkClient* client) { compositor_frame_sink_ptr_->SetThreadIds(thread_ids); #endif -#if BUILDFLAG(IS_OHOS) - std::vector thread_ids; - thread_ids.push_back(base::PlatformThread::CurrentId()); - bool is_created = true; - compositor_frame_sink_ptr_->ReportKeyThreadIds( - thread_ids, base::GetCurrentProcId(), is_created); -#endif - return true; } diff --git a/components/autofill/core/browser/browser_autofill_manager.cc b/components/autofill/core/browser/browser_autofill_manager.cc index 407ec558f3..3e857cee93 100644 --- a/components/autofill/core/browser/browser_autofill_manager.cc +++ b/components/autofill/core/browser/browser_autofill_manager.cc @@ -1287,10 +1287,9 @@ void BrowserAutofillManager::DidShowSuggestions(bool has_autofill_suggestions, } void BrowserAutofillManager::OnHidePopup() { -#if !BUILDFLAG(IS_OHOS) if (!IsAutofillEnabled()) return; -#endif + single_field_form_fill_router_->CancelPendingQueries(this); client()->HideAutofillPopup(PopupHidingReason::kRendererEvent); } diff --git a/components/content_settings/core/browser/content_settings_default_provider.cc b/components/content_settings/core/browser/content_settings_default_provider.cc index 3935fe80b1..24a7b9d833 100644 --- a/components/content_settings/core/browser/content_settings_default_provider.cc +++ b/components/content_settings/core/browser/content_settings_default_provider.cc @@ -28,6 +28,10 @@ #include "components/prefs/pref_service.h" #include "components/prefs/scoped_user_pref_update.h" #include "url/gurl.h" +#if BUILDFLAG(IS_OHOS) +#include "base/command_line.h" +#include "content/public/common/content_switches.h" +#endif namespace content_settings { @@ -269,8 +273,21 @@ bool DefaultProvider::SetWebsiteSetting( // The default settings may not be directly modified for OTR sessions. // Instead, they are synced to the main profile's setting. - if (is_off_the_record_) + if (is_off_the_record_) { +#if BUILDFLAG(IS_OHOS) + if (base::CommandLine::ForCurrentProcess()->HasSwitch( + switches::kForBrowser)) { + if (content_type != ContentSettingsType::COOKIES && + content_type != ContentSettingsType::JAVASCRIPT) { + return true; + } + } else { + return true; + } +#else return true; +#endif + } { base::AutoReset auto_reset(&updating_preferences_, true); diff --git a/components/embedder_support/user_agent_utils.cc b/components/embedder_support/user_agent_utils.cc index e43707cd40..fe8ad4d2e1 100644 --- a/components/embedder_support/user_agent_utils.cc +++ b/components/embedder_support/user_agent_utils.cc @@ -437,7 +437,7 @@ std::string GetFullUserAgent( case OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_TABLET: product += " Tablet"; break; - case OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_2IN1: + case OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_PC: case OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_UNKNOWN: default: // product += ""; diff --git a/components/os_crypt/BUILD.gn b/components/os_crypt/BUILD.gn index 8e1e820c5f..165b1d11fe 100644 --- a/components/os_crypt/BUILD.gn +++ b/components/os_crypt/BUILD.gn @@ -37,14 +37,7 @@ component("os_crypt") { "os_crypt_switches.cc", "os_crypt_switches.h", ] - if (is_ohos) { - sources += [ - "ohos_crypto.cc", - "ohos_crypto.h", - "ohos_keystore.cc", - "ohos_keystore.h", - ] - } + deps = [ "//base", "//build:branding_buildflags", diff --git a/components/os_crypt/ohos_crypto.cc b/components/os_crypt/ohos_crypto.cc deleted file mode 100644 index 34c24f781f..0000000000 --- a/components/os_crypt/ohos_crypto.cc +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2023. All rights reserved. - */ - -#include "ohos_crypto.h" - -#include -#include -#include -#include -#include -#include "base/logging.h" -#include "base/lazy_instance.h" -#include "crypto/sha2.h" -#include "ohos_keystore.h" - -namespace crypto { - -namespace ohos { - -namespace { - -class KeyCache { - public: - KeyCache() = default; - ~KeyCache() = default; - // No copy construct and assignment allowed - KeyCache(const KeyCache&) = delete; - KeyCache& operator=(const KeyCache&) = delete; - - // Return true if the key is found, otherwise false - bool get_key(const std::string& key_name, std::string* key_value); - - // Add a key to the map - void add_key(const std::string& key_name, const std::string& key_value); - - private: - struct key_map_entry_t { - std::string value_; - uint64_t time_; - }; - - typedef std::map key_map_t; - - key_map_t key_map_; - uint64_t key_time_{0}; - std::mutex lock; -}; - -// Maximum key map size -const size_t MAX_KEY_MAP_SIZE = 256; - -static base::LazyInstance::Leaky inst = LAZY_INSTANCE_INITIALIZER; - -// Return true if the key is found, otherwise false -bool KeyCache::get_key(const std::string& key_name, std::string* key_value) { - // Make this function synchronous - std::lock_guard guard(lock); - - auto iter = key_map_.find(key_name); - if (iter != key_map_.end()) { - // Refresh the entry's time to the latest - iter->second.time_ = key_time_++; - - // Return a copy of the key - if (key_value != nullptr) { - *key_value = iter->second.value_; - } - - // key found - return true; - } - - // Key not found - return false; -} - -// Add a key to the map -void KeyCache::add_key(const std::string& key_name, const std::string& key_value) { - // Make this function synchronous - std::lock_guard guard(lock); - - // Check if total map size exceeds the limit - if (key_map_.size() >= MAX_KEY_MAP_SIZE) { - // Find the entry with the smallest time - auto iter_to_drop = key_map_.begin(); - for (auto iter = key_map_.begin(); iter != key_map_.end(); ++iter) { - if (iter->second.time_ < iter_to_drop->second.time_) { - iter_to_drop = iter; - } - } - - // Drop the entry - key_map_.erase(iter_to_drop); - } - - // Add the new entry - key_map_[key_name] = - key_map_entry_t{.value_ = key_value, .time_ = key_time_++}; -} - -} // namespace anonymous - -//------------------------------------------------------------------------------ -// Implementations -//------------------------------------------------------------------------------ -// Retired for the moment - s84078948 - March 1st, 2018 -static std::string _hex_repr(const std::string& s) { - static const char hex_table[16] = {'0', '1', '2', '3', '4', '5', '6', '7', - '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'}; - - std::string h(s.size() * 2, 0); - for (size_t i = 0; i < s.size(); ++i) { - const unsigned char c = (unsigned char)s[i]; - h[i + i] = hex_table[(c >> 4) & 0xf]; - h[i + i + 1] = hex_table[c & 0xf]; - } - - return h; -} - -static std::string _generate_key(const std::string& key_name) { - std::vector key_byte_array; - - std::string digest = crypto::SHA256HashString(key_name); - return crypto::ohos::GetKey(_hex_repr(digest)); -} - -std::string _get_random(size_t sz) { - std::random_device rd; - std::mt19937 gen{rd()}; - std::uniform_int_distribution<> dis{0, 255}; - - std::string rn(sz, 0); - for (size_t i = 0; i < sz; ++i) { - rn[i] = (std::string::value_type)dis(gen); - } - - return rn; -} - -std::string get_symmetric_key_256(const std::string& key_name) { - std::string key_value; - - if (inst.Get().get_key(key_name, &key_value)) { - // Key found - return key_value; - } - - // Key not found. Generate it first - key_value = _generate_key(key_name); - - inst.Get().add_key(key_name, key_value); - // Return the generated key - return key_value; -} - -std::string get_iv(size_t sz) { - return _get_random(sz); -} - -} // end namespace huawei -} // end namespace crypto diff --git a/components/os_crypt/ohos_crypto.h b/components/os_crypt/ohos_crypto.h deleted file mode 100644 index d9ae841e68..0000000000 --- a/components/os_crypt/ohos_crypto.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2022. All rights reserved. - */ - -#ifndef OHOS_COMPONENTS_OS_CRYPT_OHOS_CRYPTO_H_ -#define OHOS_COMPONENTS_OS_CRYPT_OHOS_CRYPTO_H_ - -#include -#include -#include -#include - -namespace crypto { -namespace ohos { - -// Constants -const size_t IV_SIZE = 16; - -// Get symmetric key -std::string get_symmetric_key_256(const std::string& key_name); - -// Get random IV for encryption -std::string get_iv(size_t sz = IV_SIZE); - -} // end namespace ohos -} // end namespace crypto - -#endif // OHOS_COMPONENTS_OS_CRYPT_OHOS_CRYPTO_H_ diff --git a/components/os_crypt/ohos_keystore.cc b/components/os_crypt/ohos_keystore.cc deleted file mode 100644 index 1cb4ffdbac..0000000000 --- a/components/os_crypt/ohos_keystore.cc +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2023. All rights reserved. - * Waterloo Cyber Security Center - * - * Creation Date: February 28th, 2018 - * Creator : Stefany Allaire (s84078948) - * Location : Waterloo CSC - */ - -#include "ohos_keystore.h" - -#include "base/files/file_path.h" -#include "base/feature_list.h" -#include "base/files/file_util.h" -#include "base/guid.h" -#include "base/logging.h" -#include "base/memory/singleton.h" -#include "base/path_service.h" -#include "ohos_adapter_helper.h" -#include -#include -#include -#include -#include - -#include "ohos_adapter_helper.h" - -namespace crypto { -namespace ohos { - -const int COUNT_FOR_RETRY = 3; -const size_t KEY_LENGTH = 32; -constexpr base::FilePath::CharType kNWebKeyStoreDir[] = - FILE_PATH_LITERAL("nwebks"); - -std::string GetKey(const std::string& alias) { - base::FilePath cache_path; - base::PathService::Get(base::DIR_CACHE, &cache_path); - if (cache_path.empty()) { - return std::string(); - } - base::FilePath key_dir = cache_path.Append(FILE_PATH_LITERAL(kNWebKeyStoreDir)); - if (!base::PathExists(key_dir)) { - if (!base::CreateDirectory(key_dir)) { - LOG(ERROR) << "create directory failed: " << key_dir.value(); - return std::string(); - } - } - base::FilePath key_file = key_dir.Append(FILE_PATH_LITERAL(alias)); - - if (base::PathExists(key_file)) { - std::string encryptedData; - bool res = base::ReadFileToString(key_file, &encryptedData); - if (!res) { - return std::string(); - } - std::string local_key; - for (int i = 0; i < COUNT_FOR_RETRY; i++) { - local_key = OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetKeystoreAdapterInstance() - .DecryptKey(alias, encryptedData); - if (!local_key.empty()) { - return local_key; - } - } - return local_key; - } else { - std::string local_key = GenerateLocalKey(KEY_LENGTH); - - std::string encryptedData; - for (int i = 0; i < COUNT_FOR_RETRY; i++) { - encryptedData = OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetKeystoreAdapterInstance() - .EncryptKey(alias, local_key); - if (!encryptedData.empty()) { - base::WriteFile(key_file, encryptedData.c_str(), encryptedData.length()); - return local_key; - } - } - return local_key; - } -} - -std::string GenerateLocalKey(size_t sz) { - std::random_device rd; - std::mt19937 gen{rd()}; - std::uniform_int_distribution<> dis{0, 255}; - - std::string rn(sz, 0); - for (size_t i = 0; i < sz; ++i) { - rn[i] = (std::string::value_type)dis(gen); - } - - return rn; -} - -} // namespace ohos -} // namespace crypto diff --git a/components/os_crypt/ohos_keystore.h b/components/os_crypt/ohos_keystore.h deleted file mode 100644 index 987b4727d4..0000000000 --- a/components/os_crypt/ohos_keystore.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2018-2022. All rights reserved. - * Waterloo Cyber Security Center - * - * Creation Date: February 28th, 2018 - * Creator : Stefany Allaire (s84078948) - * Location : Waterloo CSC - */ - -#ifndef COMPONENTS_OS_CRYPT_HUAWEI_KEYSTORE_H_ -#define COMPONENTS_OS_CRYPT_HUAWEI_KEYSTORE_H_ - -#include -#include -#include - -#include "base/component_export.h" -#include "base/strings/string_piece.h" - -namespace crypto { -namespace ohos { - -// -// |alias| is a string that get access to a 256Bits Key -// |key| will receive the key on success. -// -COMPONENT_EXPORT(OS_CRYPT) -std::string GetKey(const std::string& alias); - -COMPONENT_EXPORT(OS_CRYPT) -std::string GenerateLocalKey(size_t key_size); - -} //namespace ohos -} // namespace crypto - -#endif // COMPONENTS_OS_CRYPT_HUAWEI_KEYSTORE_H_ diff --git a/components/os_crypt/os_crypt_linux.cc b/components/os_crypt/os_crypt_linux.cc index cf740919f7..95eb5f545f 100644 --- a/components/os_crypt/os_crypt_linux.cc +++ b/components/os_crypt/os_crypt_linux.cc @@ -22,16 +22,11 @@ #include "crypto/encryptor.h" #include "crypto/symmetric_key.h" -#if BUILDFLAG(IS_OHOS) -#include "ohos_crypto.h" -#endif - namespace { // Salt for Symmetric key derivation. const char kSalt[] = "saltysalt"; -#if !BUILDFLAG(IS_OHOS) // Key size required for 128 bit AES. const size_t kDerivedKeySizeInBits = 128; @@ -40,12 +35,6 @@ const size_t kEncryptionIterations = 1; // Size of initialization vector for AES 128-bit. const size_t kIVBlockSizeAES128 = 16; -#endif - -#if BUILDFLAG(IS_OHOS) -// Size of initialization vectore for GCM -const size_t kIVSizeAESGCM = 12; -#endif // Password version. V10 means that the hardcoded password will be used. // V11 means that a password is/will be stored using an OS-level library (e.g @@ -101,18 +90,11 @@ std::unique_ptr GenerateEncryptionKey( const std::string& password) { std::string salt(kSalt); -#if BUILDFLAG(IS_OHOS) - std::unique_ptr encryption_key( - crypto::SymmetricKey::Import( - crypto::SymmetricKey::AES, - crypto::ohos::get_symmetric_key_256("nweb_data_key"))); -#else // Create an encryption key from our password and salt. std::unique_ptr encryption_key( crypto::SymmetricKey::DeriveKeyFromPasswordUsingPbkdf2( crypto::SymmetricKey::AES, password, salt, kEncryptionIterations, kDerivedKeySizeInBits)); -#endif DCHECK(encryption_key); return encryption_key; @@ -190,23 +172,14 @@ bool OSCrypt::EncryptString(const std::string& plaintext, if (!encryption_key) return false; -#if BUILDFLAG(IS_OHOS) - std::string iv = crypto::ohos::get_iv(kIVSizeAESGCM); - crypto::Encryptor encryptor; - if (!encryptor.Init(encryption_key, crypto::Encryptor::GCM, iv)) -#else std::string iv(kIVBlockSizeAES128, ' '); crypto::Encryptor encryptor; if (!encryptor.Init(encryption_key, crypto::Encryptor::CBC, iv)) -#endif return false; if (!encryptor.Encrypt(plaintext, ciphertext)) return false; -#if BUILDFLAG(IS_OHOS) - ciphertext->insert(0, iv); -#endif // Prefix the cipher text with version information. ciphertext->insert(0, kObfuscationPrefix[version]); return true; @@ -243,26 +216,15 @@ bool OSCrypt::DecryptString(const std::string& ciphertext, return false; } -#if BUILDFLAG(IS_OHOS) - std::string iv = ciphertext.substr(sizeof(kObfuscationPrefix[version]) - 1, kIVSizeAESGCM); - crypto::Encryptor encryptor; - if (!encryptor.Init(encryption_key, crypto::Encryptor::GCM, iv)) -#else std::string iv(kIVBlockSizeAES128, ' '); crypto::Encryptor encryptor; if (!encryptor.Init(encryption_key, crypto::Encryptor::CBC, iv)) -#endif return false; -#if BUILDFLAG(IS_OHOS) - std::string raw_ciphertext = - ciphertext.substr(sizeof(kObfuscationPrefix[version]) + kIVSizeAESGCM - 1); // Strip off the versioning prefix before decrypting. -#else std::string raw_ciphertext = ciphertext.substr(strlen(kObfuscationPrefix[version])); -#endif if (!encryptor.Decrypt(raw_ciphertext, plaintext)) { VLOG(1) << "Decryption failed"; return false; diff --git a/components/password_manager/core/browser/BUILD.gn b/components/password_manager/core/browser/BUILD.gn index 9cf126869c..49418f6cbd 100644 --- a/components/password_manager/core/browser/BUILD.gn +++ b/components/password_manager/core/browser/BUILD.gn @@ -258,15 +258,6 @@ static_library("browser") { "well_known_change_password_util.h", ] - # ifdef OHOS_NWEB_EX - if (is_ohos) { - sources += [ - "oh_sync_credentials_filter.cc", - "oh_sync_credentials_filter.h", - ] - } - # endif - all_dependent_configs = [ ":password_reuse_detection_config" ] public_deps = [ diff --git a/components/password_manager/core/browser/form_fetcher_impl.cc b/components/password_manager/core/browser/form_fetcher_impl.cc index 8ca56c86c6..98e29e4792 100644 --- a/components/password_manager/core/browser/form_fetcher_impl.cc +++ b/components/password_manager/core/browser/form_fetcher_impl.cc @@ -266,10 +266,6 @@ void FormFetcherImpl::SplitResults( non_federated_.clear(); federated_.clear(); for (auto& form : forms) { -#if defined(OHOS_NWEB_EX) - if (form->password_value.empty()) - continue; -#endif if (form->blocked_by_user) { // Ignore non-exact matches for blocklisted entries. if (password_manager_util::GetMatchType(*form) == @@ -301,6 +297,7 @@ void FormFetcherImpl::OnGetPasswordStoreResultsFrom( std::vector> results) { DCHECK_EQ(State::WAITING, state_); DCHECK_GT(wait_counter_, 0); + if (should_migrate_http_passwords_ && results.empty() && form_digest_.url.SchemeIs(url::kHttpsScheme)) { http_migrators_[store] = std::make_unique( diff --git a/components/password_manager/core/browser/form_parsing/form_parser.cc b/components/password_manager/core/browser/form_parsing/form_parser.cc index 4ff251ff95..fbcecbe895 100644 --- a/components/password_manager/core/browser/form_parsing/form_parser.cc +++ b/components/password_manager/core/browser/form_parsing/form_parser.cc @@ -30,12 +30,6 @@ #include "components/password_manager/core/browser/password_form.h" #include "components/password_manager/core/common/password_manager_features.h" -#if defined(OHOS_NWEB_EX) -#include "base/base_switches.h" -#include "base/command_line.h" -#include "content/public/common/content_switches.h" -#endif - using autofill::FieldPropertiesFlags; using autofill::FormData; using autofill::FormFieldData; @@ -471,11 +465,6 @@ void ParseUsingAutocomplete(const std::vector& processed_fields, result->password = processed_field.field; break; case AutocompleteFlag::kNewPassword: -#if defined(OHOS_NWEB_EX) - if (!processed_field.is_password) { - return; - } -#endif if (!processed_field.is_password || new_password_found_by_server || processed_field.server_hints_not_password || should_ignore_new_password_autocomplete) @@ -899,15 +888,6 @@ std::vector ProcessFields( std::set seen_username_values; const bool consider_only_non_empty = mode == FormDataParser::Mode::kSaving; -#if defined(OHOS_NWEB_EX) - bool is_password_visible = false; - for (const FormFieldData& field : fields) { - if (field.form_control_type == "password" && field.IsVisible()) { - is_password_visible = true; - break; - } - } -#endif for (const FormFieldData& field : fields) { if (!field.IsTextInputElement()) continue; @@ -941,21 +921,8 @@ std::vector ProcessFields( if (field.properties_mask & FieldPropertiesFlags::kUserTyped) processed_field.interactability = Interactability::kCertain; -#if defined(OHOS_NWEB_EX) - else if (field.is_focusable) { - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kForBrowser)) { - if (is_password_visible) { - processed_field.interactability = Interactability::kPossible; - } - } else { - processed_field.interactability = Interactability::kPossible; - } - } -#else else if (field.is_focusable) processed_field.interactability = Interactability::kPossible; -#endif result.push_back(processed_field); } diff --git a/components/password_manager/core/browser/oh_sync_credentials_filter.cc b/components/password_manager/core/browser/oh_sync_credentials_filter.cc deleted file mode 100644 index 84b59d7cc0..0000000000 --- a/components/password_manager/core/browser/oh_sync_credentials_filter.cc +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved. - * Created by lin on 19-1-16. - */ - -#include "components/password_manager/core/browser/oh_sync_credentials_filter.h" - -#include - -#include "base/metrics/field_trial.h" -#include "base/metrics/user_metrics.h" -#include "components/password_manager/core/browser/password_form_manager.h" -#include "components/password_manager/core/browser/password_form_manager_for_ui.h" -#include "components/password_manager/core/browser/password_manager_util.h" -#include "components/password_manager/core/browser/password_sync_util.h" -#include "components/password_manager/core/common/password_manager_features.h" -#include "net/base/url_util.h" - -namespace password_manager { - -OhSyncCredentialsFilter::OhSyncCredentialsFilter(PasswordManagerClient* client) - : client_(client) {} - -OhSyncCredentialsFilter::~OhSyncCredentialsFilter() {} - -bool OhSyncCredentialsFilter::ShouldSave(const PasswordForm& form) const { - return !client_->IsIncognito(); -} - -bool OhSyncCredentialsFilter::ShouldSaveGaiaPasswordHash( - const PasswordForm& form) const { - return false; -} - -bool OhSyncCredentialsFilter::ShouldSaveEnterprisePasswordHash( - const PasswordForm& form) const { - return !client_->IsIncognito() && sync_util::ShouldSaveEnterprisePasswordHash( - form, *client_->GetPrefs()); -} - -bool OhSyncCredentialsFilter::IsSyncAccountEmail( - const std::string& username) const { - return sync_util::IsSyncAccountEmail(username, client_->GetIdentityManager()); -} - -void OhSyncCredentialsFilter::ReportFormLoginSuccess( - const PasswordFormManager& form_manager) const { - if (!form_manager.IsNewLogin()) { - base::RecordAction(base::UserMetricsAction( - "PasswordManager_SyncCredentialFilledAndLoginSuccessfull")); - } -} - -} // namespace password_manager diff --git a/components/password_manager/core/browser/oh_sync_credentials_filter.h b/components/password_manager/core/browser/oh_sync_credentials_filter.h deleted file mode 100644 index f7db9c6ba8..0000000000 --- a/components/password_manager/core/browser/oh_sync_credentials_filter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Huawei Technologies Co., Ltd. 2019-2022. All rights reserved. - * Created by lin on 19-1-16. - */ - -#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_OH_SYNC_CREDENTIALS_FILTER_H_ -#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_OH_SYNC_CREDENTIALS_FILTER_H_ - -#include -#include -#include - -#include "base/callback.h" -#include "base/memory/raw_ptr.h" -#include "components/password_manager/core/browser/credentials_filter.h" -#include "components/password_manager/core/browser/password_form.h" -#include "components/password_manager/core/browser/password_manager_client.h" -#include "components/sync/driver/sync_service.h" - -namespace password_manager { -struct PasswordForm; -class PasswordFormManager; - -class OhSyncCredentialsFilter : public CredentialsFilter { - public: - using SyncServiceFactoryFunction = - base::RepeatingCallback; - - OhSyncCredentialsFilter(PasswordManagerClient* client); - ~OhSyncCredentialsFilter() override; - - // CredentialsFilter - bool ShouldSave(const PasswordForm& form) const override; - bool ShouldSaveGaiaPasswordHash(const PasswordForm& form) const override; - bool ShouldSaveEnterprisePasswordHash( - const PasswordForm& form) const override; - void ReportFormLoginSuccess( - const PasswordFormManager& form_manager) const override; - bool IsSyncAccountEmail(const std::string& username) const override; - - private: - const raw_ptr client_; - - const SyncServiceFactoryFunction sync_service_factory_function_; -}; - -} // namespace password_manager -#endif // COMPONENTS_PASSWORD_MANAGER_SYNC_BROWSER_AW_SYNC_CREDENTIALS_FILTER_H_ diff --git a/components/password_manager/core/browser/password_autofill_manager.cc b/components/password_manager/core/browser/password_autofill_manager.cc index 47dac78743..52fd554d6a 100644 --- a/components/password_manager/core/browser/password_autofill_manager.cc +++ b/components/password_manager/core/browser/password_autofill_manager.cc @@ -53,11 +53,6 @@ #include "ui/base/l10n/l10n_util.h" #include "url/gurl.h" -#if defined(OHOS_NWEB_EX) -#include "base/base_switches.h" -#include "content/public/common/content_switches.h" -#endif - namespace password_manager { namespace { @@ -225,12 +220,6 @@ void MaybeAppendManagePasswordsEntry( suggestions->back().frontend_id = autofill::POPUP_ITEM_ID_SEPARATOR; } -#if defined(OHOS_NWEB_EX) - if (base::CommandLine::ForCurrentProcess()->HasSwitch( - switches::kForBrowser)) { - return; - } -#endif autofill::Suggestion suggestion( l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_MANAGE_PASSWORDS)); suggestion.frontend_id = autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY; diff --git a/components/password_manager/core/browser/password_form_manager.cc b/components/password_manager/core/browser/password_form_manager.cc index 41fd69f5e8..90ace97c59 100644 --- a/components/password_manager/core/browser/password_form_manager.cc +++ b/components/password_manager/core/browser/password_form_manager.cc @@ -899,11 +899,7 @@ PasswordFormManager::PasswordFormManager( ? *observed_digest() : PasswordFormDigest(*observed_form()), client_, -#if defined(OHOS_NWEB_EX) - false /* should_migrate_http_passwords */)), -#else true /* should_migrate_http_passwords */)), -#endif form_fetcher_(form_fetcher ? form_fetcher : owned_form_fetcher_.get()), password_save_manager_(std::move(password_save_manager)), // TODO(https://crbug.com/831123): set correctly diff --git a/components/password_manager/core/browser/password_store.cc b/components/password_manager/core/browser/password_store.cc index 9ccef26c58..c5c6f9796d 100644 --- a/components/password_manager/core/browser/password_store.cc +++ b/components/password_manager/core/browser/password_store.cc @@ -468,16 +468,4 @@ void PasswordStore::InjectAffiliationAndBrandingInformation( } } -#if BUILDFLAG(IS_OHOS) -std::vector> PasswordStore::GetMatchingLogins( - const PasswordFormDigest& form) { - DCHECK(main_task_runner_->RunsTasksInCurrentSequence()); - if (!backend_) { - return {}; // Once the shutdown started, ignore new requests. - } - - return backend_->FillMatchingLogins(FormSupportsPSL(form), {form}); -} -#endif - } // namespace password_manager diff --git a/components/password_manager/core/browser/password_store.h b/components/password_manager/core/browser/password_store.h index 3bdd9c4e77..ba2a6ec1c9 100644 --- a/components/password_manager/core/browser/password_store.h +++ b/components/password_manager/core/browser/password_store.h @@ -121,11 +121,6 @@ class PasswordStore : public PasswordStoreInterface { CreateSyncControllerDelegate() override; PasswordStoreBackend* GetBackendForTesting() override; -#if BUILDFLAG(IS_OHOS) - std::vector> GetMatchingLogins( - const PasswordFormDigest& form); -#endif - protected: friend class base::RefCountedThreadSafe; diff --git a/components/password_manager/core/browser/password_store_backend.h b/components/password_manager/core/browser/password_store_backend.h index e1fa6ad145..465424070a 100644 --- a/components/password_manager/core/browser/password_store_backend.h +++ b/components/password_manager/core/browser/password_store_backend.h @@ -131,11 +131,6 @@ class PasswordStoreBackend { // Clears all the passwords from the local storage. virtual void ClearAllLocalPasswords() = 0; -#if BUILDFLAG(IS_OHOS) - virtual LoginsResult FillMatchingLogins( - bool include_psl, - const std::vector& forms) = 0; -#endif // Factory function for creating the backend. The Local backend requires the // provided `login_db` for storage and Android backend for migration purposes. static std::unique_ptr Create( diff --git a/components/password_manager/core/browser/password_store_backend_migration_decorator.cc b/components/password_manager/core/browser/password_store_backend_migration_decorator.cc index 4072076ebe..96bbcb62e2 100644 --- a/components/password_manager/core/browser/password_store_backend_migration_decorator.cc +++ b/components/password_manager/core/browser/password_store_backend_migration_decorator.cc @@ -215,12 +215,4 @@ void PasswordStoreBackendMigrationDecorator::SyncStatusChanged() { } } -#if BUILDFLAG(IS_OHOS) -LoginsResult PasswordStoreBackendMigrationDecorator::FillMatchingLogins( - bool include_psl, - const std::vector& forms) { - return {}; -} -#endif - } // namespace password_manager diff --git a/components/password_manager/core/browser/password_store_backend_migration_decorator.h b/components/password_manager/core/browser/password_store_backend_migration_decorator.h index 65f0ed0fc2..8453e06687 100644 --- a/components/password_manager/core/browser/password_store_backend_migration_decorator.h +++ b/components/password_manager/core/browser/password_store_backend_migration_decorator.h @@ -79,11 +79,6 @@ class PasswordStoreBackendMigrationDecorator : public PasswordStoreBackend { CreateSyncControllerDelegate() override; void ClearAllLocalPasswords() override; -#if BUILDFLAG(IS_OHOS) - LoginsResult FillMatchingLogins( - bool include_psl, - const std::vector& forms) override; -#endif // Creates 'migrator_' and starts migration process. void StartMigration(); diff --git a/components/password_manager/core/browser/password_store_built_in_backend.cc b/components/password_manager/core/browser/password_store_built_in_backend.cc index ed1130a426..008fccc8ad 100644 --- a/components/password_manager/core/browser/password_store_built_in_backend.cc +++ b/components/password_manager/core/browser/password_store_built_in_backend.cc @@ -296,14 +296,4 @@ void PasswordStoreBuiltInBackend::RemoveFieldInfoByTime( std::move(completion)); } -#if BUILDFLAG(IS_OHOS) -LoginsResult PasswordStoreBuiltInBackend::FillMatchingLogins( - bool include_psl, - const std::vector& forms) { - DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); - DCHECK(helper_); - return helper_->FillMatchingLogins(forms, include_psl); -} -#endif - } // namespace password_manager diff --git a/components/password_manager/core/browser/password_store_built_in_backend.h b/components/password_manager/core/browser/password_store_built_in_backend.h index 14b568a145..7223f76d3b 100644 --- a/components/password_manager/core/browser/password_store_built_in_backend.h +++ b/components/password_manager/core/browser/password_store_built_in_backend.h @@ -42,12 +42,6 @@ class PasswordStoreBuiltInBackend : public PasswordStoreBackend, ~PasswordStoreBuiltInBackend() override; -#if BUILDFLAG(IS_OHOS) - LoginsResult FillMatchingLogins( - bool include_psl, - const std::vector& forms) override; -#endif - private: // Implements PasswordStoreBackend interface. base::WeakPtr GetWeakPtr() override; diff --git a/components/password_manager/core/browser/password_store_proxy_backend.cc b/components/password_manager/core/browser/password_store_proxy_backend.cc index 7af4ca4051..a56777905c 100644 --- a/components/password_manager/core/browser/password_store_proxy_backend.cc +++ b/components/password_manager/core/browser/password_store_proxy_backend.cc @@ -515,11 +515,4 @@ void PasswordStoreProxyBackend::ClearAllLocalPasswords() { NOTIMPLEMENTED(); } -#if BUILDFLAG(IS_OHOS) -LoginsResult PasswordStoreProxyBackend::FillMatchingLogins( - bool include_psl, - const std::vector& forms) { - return {}; -} -#endif } // namespace password_manager diff --git a/components/password_manager/core/browser/password_store_proxy_backend.h b/components/password_manager/core/browser/password_store_proxy_backend.h index c315d68853..bc6e2fa5e7 100644 --- a/components/password_manager/core/browser/password_store_proxy_backend.h +++ b/components/password_manager/core/browser/password_store_proxy_backend.h @@ -73,11 +73,6 @@ class PasswordStoreProxyBackend : public PasswordStoreBackend { CreateSyncControllerDelegate() override; void ClearAllLocalPasswords() override; -#if BUILDFLAG(IS_OHOS) - LoginsResult FillMatchingLogins( - bool include_psl, - const std::vector& forms) override; -#endif const raw_ptr main_backend_; const raw_ptr shadow_backend_; raw_ptr const prefs_ = nullptr; diff --git a/components/password_manager/core/browser/test_password_store.cc b/components/password_manager/core/browser/test_password_store.cc index df3bec3c22..d0db0bc420 100644 --- a/components/password_manager/core/browser/test_password_store.cc +++ b/components/password_manager/core/browser/test_password_store.cc @@ -392,12 +392,4 @@ PasswordStoreChangeList TestPasswordStore::RemoveLoginImpl( return changes; } -#if BUILDFLAG(IS_OHOS) -LoginsResult TestPasswordStore::FillMatchingLogins( - bool include_psl, - const std::vector& forms) { - return {}; -} -#endif - } // namespace password_manager diff --git a/components/password_manager/core/browser/test_password_store.h b/components/password_manager/core/browser/test_password_store.h index a770a73d82..d44eec831c 100644 --- a/components/password_manager/core/browser/test_password_store.h +++ b/components/password_manager/core/browser/test_password_store.h @@ -101,12 +101,6 @@ class TestPasswordStore : public PasswordStore, public PasswordStoreBackend { CreateSyncControllerDelegate() override; void ClearAllLocalPasswords() override; -#if BUILDFLAG(IS_OHOS) - LoginsResult FillMatchingLogins( - bool include_psl, - const std::vector& forms) override; -#endif - private: LoginsResult GetAllLoginsInternal(); LoginsResult GetAutofillableLoginsInternal(); diff --git a/components/password_manager/core/common/password_manager_features.cc b/components/password_manager/core/common/password_manager_features.cc index 6495817403..6386ab63a6 100644 --- a/components/password_manager/core/common/password_manager_features.cc +++ b/components/password_manager/core/common/password_manager_features.cc @@ -107,13 +107,7 @@ const base::Feature kPasswordImport = {"PasswordImport", // Enables password reuse detection. const base::Feature kPasswordReuseDetectionEnabled = { - "PasswordReuseDetectionEnabled", -#if BUILDFLAG(IS_OHOS) - base::FEATURE_DISABLED_BY_DEFAULT -#else - base::FEATURE_ENABLED_BY_DEFAULT -#endif -}; + "PasswordReuseDetectionEnabled", base::FEATURE_ENABLED_BY_DEFAULT}; // Enables a revised opt-in flow for the account-scoped password storage. const base::Feature kPasswordsAccountStorageRevisedOptInFlow = { diff --git a/components/policy/core/common/BUILD.gn b/components/policy/core/common/BUILD.gn index ccb104c221..9aa66afafd 100644 --- a/components/policy/core/common/BUILD.gn +++ b/components/policy/core/common/BUILD.gn @@ -325,12 +325,6 @@ source_set("internal") { frameworks += [ "Foundation.framework" ] } } - if (is_ohos) { - sources += [ - "policy_loader_ohos.cc", - "policy_loader_ohos.h", - ] - } } static_library("test_support") { diff --git a/components/policy/core/common/policy_loader_ohos.cc b/components/policy/core/common/policy_loader_ohos.cc deleted file mode 100644 index 6148fd169a..0000000000 --- a/components/policy/core/common/policy_loader_ohos.cc +++ /dev/null @@ -1,113 +0,0 @@ -// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "components/policy/core/common/policy_loader_ohos.h" - -#include - -#include "base/json/json_string_value_serializer.h" -#include "base/logging.h" -#include "components/policy/core/common/policy_bundle.h" -#include "components/policy/core/common/policy_load_status.h" -#include "components/policy/core/common/policy_types.h" - -#include "ohos_adapter_helper.h" - -namespace policy { - -PolicyLoaderOhos::PolicyLoaderOhos( - scoped_refptr task_runner) - : AsyncPolicyLoader(task_runner, /*periodic_updates*/ false) {} - -PolicyLoaderOhos::~PolicyLoaderOhos() {} - -void PolicyLoaderOhos::InitOnBackgroundThread() { - // 目前未对鸿蒙policy进行后台扫描监控,暂时为空实现 -} - -std::unique_ptr PolicyLoaderOhos::Load() { - std::string policies; - int32_t error_code = OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetEnterpriseDeviceManagementInstance() - .GetPolicies(policies); - LOG(INFO) << "GetPolicies error_code:" << error_code - << ", policies:" << policies; - std::unique_ptr bundle = std::make_unique(); - LoadOhosPolicy(policies, bundle.get()); - return bundle; -} - -void PolicyLoaderOhos::LoadOhosPolicy(const std::string& json, - PolicyBundle* bundle) { - /* policy json demo - "InsecurePrivateNetworkRequestsAllowed": { - "level": "mandatory", - "scope": "machine", - "source": "platform", - "value": true - }*/ - if (bundle == nullptr) { - return; - } - - base::DictionaryValue dictionary_value; - JSONStringValueDeserializer deserializer(json); - std::string error_msg; - std::unique_ptr json_value = - deserializer.Deserialize(/*error_code=*/nullptr, &error_msg); - if (!json_value) { - LOG(WARNING) << "Unable to deserialize json data. error_msg: " << error_msg; - return; - } - - if (json_value->type() == base::Value::Type::DICTIONARY) { - for (auto kv : json_value->DictItems()) { - std::string key = kv.first; - if (kv.second.type() != base::Value::Type::DICTIONARY) { - LOG(WARNING) << "key: " << key << " type is not DICTIONARY"; - continue; - } - base::Value* policy_value = kv.second.FindKey("value"); - if (!policy_value) { - LOG(WARNING) << "key: " << key << " has no value"; - continue; - } - - switch (policy_value->type()) { - case base::Value::Type::BOOLEAN: { - dictionary_value.SetBoolean(key, policy_value->GetBool()); - break; - } - case base::Value::Type::INTEGER: { - dictionary_value.SetInteger(key, policy_value->GetInt()); - break; - } - case base::Value::Type::DOUBLE: { - dictionary_value.SetDouble(key, policy_value->GetDouble()); - break; - } - case base::Value::Type::STRING: { - dictionary_value.SetString(key, policy_value->GetString()); - break; - } - case base::Value::Type::LIST: { - dictionary_value.SetList( - key, std::make_unique(policy_value->GetList())); - break; - } - default: - LOG(WARNING) << "unkown type"; - } - } - } - - PolicyMap policy_map; - policy_map.LoadFrom(&dictionary_value, POLICY_LEVEL_MANDATORY, - POLICY_SCOPE_MACHINE, POLICY_SOURCE_PLATFORM); - bundle->Get(PolicyNamespace(POLICY_DOMAIN_CHROME, std::string())) - .MergeFrom(policy_map); - return; -} - -} // namespace policy diff --git a/components/policy/core/common/policy_loader_ohos.h b/components/policy/core/common/policy_loader_ohos.h deleted file mode 100644 index 2b23ee2cb5..0000000000 --- a/components/policy/core/common/policy_loader_ohos.h +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright (c) 2023 Huawei Device Co., Ltd. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_OHOS_H_ -#define COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_OHOS_H_ - -#include "base/task/sequenced_task_runner.h" -#include "components/policy/core/common/async_policy_loader.h" -#include "components/policy/policy_export.h" - -namespace base { -class Value; -} - -namespace policy { - -class POLICY_EXPORT PolicyLoaderOhos : public AsyncPolicyLoader { - public: - PolicyLoaderOhos(scoped_refptr task_runner); - PolicyLoaderOhos(const PolicyLoaderOhos&) = delete; - PolicyLoaderOhos& operator=(const PolicyLoaderOhos&) = delete; - ~PolicyLoaderOhos() override; - - // AsyncPolicyLoader implementation. - void InitOnBackgroundThread() override; - std::unique_ptr Load() override; - - private: - void LoadOhosPolicy(const std::string& json, PolicyBundle* bundle); -}; - -} // namespace policy - -#endif // COMPONENTS_POLICY_CORE_COMMON_POLICY_LOADER_OHOS_H_ diff --git a/components/printing/browser/print_to_pdf/pdf_print_manager.cc b/components/printing/browser/print_to_pdf/pdf_print_manager.cc index 98ed2d7135..410fda1bb5 100644 --- a/components/printing/browser/print_to_pdf/pdf_print_manager.cc +++ b/components/printing/browser/print_to_pdf/pdf_print_manager.cc @@ -298,10 +298,6 @@ void PdfPrintManager::ReleaseJob(PrintResult result) { Reset(); } -#if BUILDFLAG(IS_OHOS) -void PdfPrintManager::PrintRequested(PrintRequestedCallback callback) {} -#endif - WEB_CONTENTS_USER_DATA_KEY_IMPL(PdfPrintManager); } // namespace print_to_pdf diff --git a/components/printing/browser/print_to_pdf/pdf_print_manager.h b/components/printing/browser/print_to_pdf/pdf_print_manager.h index ccc0d31812..14449b2468 100644 --- a/components/printing/browser/print_to_pdf/pdf_print_manager.h +++ b/components/printing/browser/print_to_pdf/pdf_print_manager.h @@ -73,9 +73,6 @@ class PdfPrintManager : public printing::PrintManager, GetDefaultPrintSettingsCallback callback) override; void ScriptedPrint(printing::mojom::ScriptedPrintParamsPtr params, ScriptedPrintCallback callback) override; -#if BUILDFLAG(IS_OHOS) - void PrintRequested(PrintRequestedCallback callback) override; -#endif void ShowInvalidPrinterSettingsError() override; void PrintingFailed(int32_t cookie) override; #if BUILDFLAG(ENABLE_PRINT_PREVIEW) diff --git a/components/printing/common/print.mojom b/components/printing/common/print.mojom index 708ade930c..51ebcb4ae3 100644 --- a/components/printing/common/print.mojom +++ b/components/printing/common/print.mojom @@ -384,7 +384,4 @@ interface PrintManagerHost { // that. Instead, this dependency is enforced by GN. [EnableIf=enable_tagged_pdf] SetAccessibilityTree(int32 cookie, ax.mojom.AXTreeUpdate accessibility_tree); - - [EnableIf=is_ohos] - PrintRequested() => (); }; diff --git a/components/printing/renderer/print_render_frame_helper.cc b/components/printing/renderer/print_render_frame_helper.cc index c3dea12ab7..da44581625 100644 --- a/components/printing/renderer/print_render_frame_helper.cc +++ b/components/printing/renderer/print_render_frame_helper.cc @@ -6,6 +6,7 @@ #include #include + #include #include #include @@ -678,23 +679,6 @@ void ClosuresForMojoResponse::RunPrintSettingFromUserQuitClosure() { std::move(get_print_settings_from_user_quit_closure_).Run(); } -#if BUILDFLAG(IS_OHOS) -void ClosuresForMojoResponse::SetPrintRequestedPreviewQuitClosure( - base::OnceClosure quit_print_preview) { - DCHECK(!print_requested_preview_quit_closure_); - print_requested_preview_quit_closure_ = std::move(quit_print_preview); -} - -void ClosuresForMojoResponse::RunPrintRequestedPreviewQuitClosure() { - if (!print_requested_preview_quit_closure_) - return; - - std::move(print_requested_preview_quit_closure_).Run(); -} - -blink::WebLocalFrame* PrintRenderFrameHelper::static_web_frame_ = nullptr; -#endif // IS_OHOS - // static double PrintRenderFrameHelper::GetScaleFactor(double input_scale_factor, bool is_pdf) { @@ -1256,22 +1240,9 @@ void PrintRenderFrameHelper::ScriptedPrint(bool user_initiated) { // Detached documents can't be printed. if (!web_frame->GetDocument().GetFrame()) return; - + #if BUILDFLAG(IS_OHOS) if (delegate_->IsScriptedPrintEnabled()) { - LOG(INFO) << "delegate_->IsScriptedPrintEnabled()"; - web_frame->DispatchBeforePrintEvent(/*print_client=*/nullptr); - - static_web_frame_ = web_frame; - - base::RunLoop loop{base::RunLoop::Type::kNestableTasksAllowed}; - closures_for_mojo_responses_->SetPrintRequestedPreviewQuitClosure( - loop.QuitClosure()); - GetPrintManagerHost()->PrintRequested(base::BindOnce( - &ClosuresForMojoResponse::RunPrintRequestedPreviewQuitClosure, - closures_for_mojo_responses_)); - loop.Run(); - web_frame->DispatchAfterPrintEvent(); return; } #endif // IS_OHOS @@ -1327,13 +1298,9 @@ void PrintRenderFrameHelper::PrintRequestedPages() { ScopedIPC scoped_ipc(weak_ptr_factory_.GetWeakPtr()); if (ipc_nesting_level_ > kAllowedIpcDepthForPrint) return; - blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); -#if BUILDFLAG(IS_OHOS) - frame = static_web_frame_; -#else + blink::WebLocalFrame* frame = render_frame()->GetWebFrame(); frame->DispatchBeforePrintEvent(/*print_client=*/nullptr); -#endif // Don't print if the RenderFrame is gone. if (render_frame_gone_) return; @@ -1344,11 +1311,8 @@ void PrintRenderFrameHelper::PrintRequestedPages() { Print(frame, plugin, PrintRequestType::kRegular); -#if BUILDFLAG(IS_OHOS) -#else if (!render_frame_gone_) frame->DispatchAfterPrintEvent(); -#endif // WARNING: |this| may be gone at this point. Do not do any more work here and // just return. } diff --git a/components/printing/renderer/print_render_frame_helper.h b/components/printing/renderer/print_render_frame_helper.h index 792b3cae26..2b703118bf 100644 --- a/components/printing/renderer/print_render_frame_helper.h +++ b/components/printing/renderer/print_render_frame_helper.h @@ -96,11 +96,6 @@ class ClosuresForMojoResponse void SetPrintSettingFromUserQuitClosure(base::OnceClosure quit_print_setting); void RunPrintSettingFromUserQuitClosure(); -#if BUILDFLAG(IS_OHOS) - void SetPrintRequestedPreviewQuitClosure( - base::OnceClosure quit_print_preview); - void RunPrintRequestedPreviewQuitClosure(); -#endif // IS_OHOS private: friend class base::RefCounted; ~ClosuresForMojoResponse(); @@ -108,10 +103,6 @@ class ClosuresForMojoResponse // Stores quit closures for the runloops that are waiting for Mojo replies. base::OnceClosure scripted_print_preview_quit_closure_; base::OnceClosure get_print_settings_from_user_quit_closure_; - -#if BUILDFLAG(IS_OHOS) - base::OnceClosure print_requested_preview_quit_closure_; -#endif // IS_OHOS }; // PrintRenderFrameHelper handles most of the printing grunt work for @@ -703,10 +694,6 @@ class PrintRenderFrameHelper mojo::AssociatedRemote print_manager_host_; base::WeakPtrFactory weak_ptr_factory_{this}; - -#if BUILDFLAG(IS_OHOS) - static blink::WebLocalFrame* static_web_frame_; -#endif // IS_OHOS }; } // namespace printing diff --git a/components/viz/client/frame_eviction_manager.cc b/components/viz/client/frame_eviction_manager.cc index 2a0e4f7678..68e814663c 100644 --- a/components/viz/client/frame_eviction_manager.cc +++ b/components/viz/client/frame_eviction_manager.cc @@ -127,7 +127,7 @@ FrameEvictionManager::FrameEvictionManager() OHOS::NWeb::ProductDeviceType deviceType = system_properties_adapter.GetProductDeviceType(); - if (deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_2IN1 || + if (deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_PC || deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_TABLET) { max_number_of_saved_frames_ = kMaxNumberOfSavedFrames; } diff --git a/components/viz/service/display_embedder/compositor_gpu_thread.cc b/components/viz/service/display_embedder/compositor_gpu_thread.cc index 17031e670f..983f8724a2 100644 --- a/components/viz/service/display_embedder/compositor_gpu_thread.cc +++ b/components/viz/service/display_embedder/compositor_gpu_thread.cc @@ -29,13 +29,6 @@ #include "gpu/vulkan/vulkan_implementation.h" #endif -#if BUILDFLAG(IS_OHOS) -#include "base/process/process_handle.h" -#include "content/public/browser/browser_task_traits.h" -#include "content/public/browser/browser_thread.h" -#include "res_sched_client_adapter.h" -#endif - namespace viz { // static @@ -96,15 +89,6 @@ CompositorGpuThread::CompositorGpuThread( weak_ptr_factory_(this) {} CompositorGpuThread::~CompositorGpuThread() { -#if BUILDFLAG(IS_OHOS) - using namespace OHOS::NWeb; - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&ResSchedClientAdapter::ReportKeyThread), - ResSchedStatusAdapter::THREAD_DESTROYED, base::GetCurrentProcId(), - GetThreadId(), ResSchedRoleAdapter::IMPORTANT_DISPLAY)); -#endif base::Thread::Stop(); } @@ -118,15 +102,6 @@ bool CompositorGpuThread::Initialize() { // Wait until threas is started and Init() is executed in order to return // updated |init_succeeded_|. WaitUntilThreadStarted(); -#if BUILDFLAG(IS_OHOS) - using namespace OHOS::NWeb; - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&ResSchedClientAdapter::ReportKeyThread), - ResSchedStatusAdapter::THREAD_CREATED, base::GetCurrentProcId(), - GetThreadId(), ResSchedRoleAdapter::IMPORTANT_DISPLAY)); -#endif return init_succeeded_; } diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_impl.cc b/components/viz/service/frame_sinks/compositor_frame_sink_impl.cc index 04e2c0b7dc..c127f8b069 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_impl.cc +++ b/components/viz/service/frame_sinks/compositor_frame_sink_impl.cc @@ -17,12 +17,6 @@ #include "components/viz/service/frame_sinks/frame_sink_manager_impl.h" #include "ui/gfx/overlay_transform.h" -#if BUILDFLAG(IS_OHOS) -#include "content/public/browser/browser_task_traits.h" -#include "content/public/browser/browser_thread.h" -#include "res_sched_client_adapter.h" -#endif - namespace viz { namespace { @@ -209,25 +203,6 @@ void CompositorFrameSinkImpl::SetThreadIds( } #endif -#if BUILDFLAG(IS_OHOS) -void CompositorFrameSinkImpl::ReportKeyThreadIds( - const std::vector& thread_ids, - int32_t process_id, - bool is_created) { - using namespace OHOS::NWeb; - ResSchedStatusAdapter status = is_created - ? ResSchedStatusAdapter::THREAD_CREATED - : ResSchedStatusAdapter::THREAD_DESTROYED; - for (auto thread_id : thread_ids) { - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&ResSchedClientAdapter::ReportKeyThread), status, - process_id, thread_id, ResSchedRoleAdapter::IMPORTANT_DISPLAY)); - } -} -#endif - void CompositorFrameSinkImpl::OnClientConnectionLost() { // The client that owns this CompositorFrameSink is either shutting down or // has done something invalid and the connection to the client was terminated. diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_impl.h b/components/viz/service/frame_sinks/compositor_frame_sink_impl.h index e50bcf6332..f357891cd2 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_impl.h +++ b/components/viz/service/frame_sinks/compositor_frame_sink_impl.h @@ -21,10 +21,6 @@ #include "services/viz/public/mojom/compositing/compositor_frame_sink.mojom.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if BUILDFLAG(IS_OHOS) -#include "base/process/process_handle.h" -#endif - namespace viz { class FrameSinkManagerImpl; @@ -69,12 +65,6 @@ class CompositorFrameSinkImpl : public mojom::CompositorFrameSink { void SetThreadIds(const std::vector& thread_ids) override; #endif -#if BUILDFLAG(IS_OHOS) - void ReportKeyThreadIds(const std::vector& thread_ids, - int32_t process_id, - bool is_created) override; -#endif - private: void SubmitCompositorFrameInternal( const LocalSurfaceId& local_surface_id, diff --git a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc index 0c8a2205ef..62fcc47682 100644 --- a/components/viz/service/frame_sinks/compositor_frame_sink_support.cc +++ b/components/viz/service/frame_sinks/compositor_frame_sink_support.cc @@ -762,7 +762,7 @@ void CompositorFrameSinkSupport::DidPresentCompositorFrame( DCHECK_LE(pending_received_frame_times_.size(), 25u); auto received_frame_timestamp = pending_received_frame_times_.find(frame_token); - CHECK(received_frame_timestamp != pending_received_frame_times_.end()); + DCHECK(received_frame_timestamp != pending_received_frame_times_.end()); FrameTimingDetails details; details.received_compositor_frame_timestamp = @@ -775,7 +775,8 @@ void CompositorFrameSinkSupport::DidPresentCompositorFrame( pending_received_frame_times_.erase(received_frame_timestamp); // We should only ever get one PresentationFeedback per frame_token. - CHECK(!frame_timing_details_.contains(frame_token)); + DCHECK(frame_timing_details_.find(frame_token) == + frame_timing_details_.end()); frame_timing_details_.emplace(frame_token, details); UpdateNeedsBeginFramesInternal(); diff --git a/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc b/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc index 96a02753ad..7861bca4fb 100644 --- a/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc +++ b/components/viz/service/frame_sinks/external_begin_frame_source_ohos.cc @@ -18,16 +18,18 @@ constexpr int64_t VSYNC_PERIOD_6090HZ_MID = 13000000; class ExternalBeginFrameSourceOHOS::VSyncUserData { public: VSyncUserData(const scoped_refptr& current, - const base::WeakPtr& weakPtr) - : current_(current), weak_ptr_(weakPtr) { - LOG(INFO) << "VSyncUserData constructor!!!"; - }; + viz::ExternalBeginFrameSourceOHOS* weakPtr) + : current_(current), weakPtr_(weakPtr){ + LOG(INFO) << "VSyncUserData constructor!!!"; + }; VSyncUserData(const VSyncUserData&) = delete; VSyncUserData& operator=(const VSyncUserData&) = delete; - ~VSyncUserData() { LOG(INFO) << "VSyncUserData destructor!!!"; }; + ~VSyncUserData() { + LOG(INFO) << "VSyncUserData destructor!!!"; + }; const scoped_refptr& current_; - base::WeakPtr weak_ptr_; + base::WeakPtrFactory weakPtr_; }; ExternalBeginFrameSourceOHOS::ExternalBeginFrameSourceOHOS( @@ -35,13 +37,14 @@ ExternalBeginFrameSourceOHOS::ExternalBeginFrameSourceOHOS( FrameSinkManagerImpl* frame_sink_manager) : ExternalBeginFrameSource(this, restart_id), vsync_notification_enabled_(false), + user_data_( + std::make_unique(base::ThreadTaskRunnerHandle::Get(), + this)), vsync_adapter_(OhosAdapterHelper::GetInstance().GetVSyncAdapter()), frame_sink_manager_(frame_sink_manager) { TRACE_EVENT0("viz", "ExternalBeginFrameSourceOHOS::ExternalBeginFrameSourceOHOS"); LOG(INFO) << "ExternalBeginFrameSourceOHOS constructor!!!"; - user_data_ = std::make_unique( - base::ThreadTaskRunnerHandle::Get(), weak_factory_.GetWeakPtr()); } ExternalBeginFrameSourceOHOS::~ExternalBeginFrameSourceOHOS() { @@ -72,12 +75,13 @@ void ExternalBeginFrameSourceOHOS::OnVSync(int64_t timestamp, void* data) { userData->current_->PostTask( FROM_HERE, base::BindOnce(&ExternalBeginFrameSourceOHOS::OnVSyncImpl, - userData->weak_ptr_, timestamp, userData)); + userData->weakPtr_.GetWeakPtr(), timestamp)); } -void ExternalBeginFrameSourceOHOS::OnVSyncImpl(int64_t timestamp, - VSyncUserData* user_data) { - user_data_.reset(user_data); +void ExternalBeginFrameSourceOHOS::OnVSyncImpl(int64_t timestamp) { + if (!vsync_notification_enabled_) { + return; + } last_vsync_period_ = timestamp; int64_t period = last_vsync_period_ - pre_vsync_period_; pre_vsync_period_ = last_vsync_period_; @@ -100,8 +104,8 @@ void ExternalBeginFrameSourceOHOS::OnVSyncImpl(int64_t timestamp, "ExternalBeginFrameSourceOHOS::OnVSyncImpl::BackToMainThread"); frame_sink_manager_->OnVsync(frame_sink_id_); } - - vsync_adapter_->RequestVsync(user_data_.release(), + + vsync_adapter_->RequestVsync(reinterpret_cast(user_data_.get()), ExternalBeginFrameSourceOHOS::OnVSync); } @@ -117,7 +121,7 @@ void ExternalBeginFrameSourceOHOS::SetEnabled(bool enabled) { enabled); vsync_notification_enabled_ = enabled; if (vsync_notification_enabled_) { - vsync_adapter_->RequestVsync(user_data_.release(), + vsync_adapter_->RequestVsync(reinterpret_cast(user_data_.get()), ExternalBeginFrameSourceOHOS::OnVSync); } } diff --git a/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h b/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h index e25ae5dad3..81b40d2d0f 100644 --- a/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h +++ b/components/viz/service/frame_sinks/external_begin_frame_source_ohos.h @@ -1,7 +1,6 @@ #ifndef COMPONENTS_VIZ_SERVICE_FRAME_SINKS_EXTERNAL_BEGIN_FRAME_SOURCE_OHOS_H_ #define COMPONENTS_VIZ_SERVICE_FRAME_SINKS_EXTERNAL_BEGIN_FRAME_SOURCE_OHOS_H_ -#include #include #include @@ -17,9 +16,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceOHOS : public ExternalBeginFrameSource, public ExternalBeginFrameSourceClient { public: - explicit ExternalBeginFrameSourceOHOS( - uint32_t restart_id, - FrameSinkManagerImpl* frame_sink_manager); + explicit ExternalBeginFrameSourceOHOS(uint32_t restart_id, FrameSinkManagerImpl* frame_sink_manager); ~ExternalBeginFrameSourceOHOS() override; ExternalBeginFrameSourceOHOS(const ExternalBeginFrameSourceOHOS&) = delete; ExternalBeginFrameSourceOHOS& operator=(const ExternalBeginFrameSourceOHOS&) = @@ -31,8 +28,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceOHOS dynamic_begin_frame_deadline_offset_source) override; static void OnVSync(int64_t timestamp, void* data); - class VSyncUserData; - void OnVSyncImpl(int64_t timestamp, VSyncUserData* user_data); + void OnVSyncImpl(int64_t timestamp); // ExternalBeginFrameSource implementation. void SetCurrentFrameSinkId(const FrameSinkId& frame_sink_id) override { @@ -48,6 +44,7 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceOHOS BeginFrameArgsGenerator begin_frame_args_generator_; bool vsync_notification_enabled_; + class VSyncUserData; std::unique_ptr user_data_; std::unique_ptr vsync_adapter_; @@ -56,7 +53,6 @@ class VIZ_SERVICE_EXPORT ExternalBeginFrameSourceOHOS int64_t vsync_period_ = 16666666; int64_t pre_vsync_period_ = 0; int64_t last_vsync_period_ = 0; - base::WeakPtrFactory weak_factory_{this}; }; } // namespace viz diff --git a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h index 82c027f3b3..6edc1a4328 100644 --- a/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h +++ b/components/viz/service/frame_sinks/root_compositor_frame_sink_impl.h @@ -121,10 +121,8 @@ class VIZ_SERVICE_EXPORT RootCompositorFrameSinkImpl #if BUILDFLAG(IS_ANDROID) void SetThreadIds(const std::vector& thread_ids) override; #endif + #if BUILDFLAG(IS_OHOS) - void ReportKeyThreadIds(const std::vector& thread_ids, - int32_t process_id, - bool is_created) override {}; void SetCurrentFrameSinkId(const FrameSinkId& frame_sink_id) override; #endif diff --git a/components/viz/service/main/viz_compositor_thread_runner_impl.cc b/components/viz/service/main/viz_compositor_thread_runner_impl.cc index 7e8378f50a..25bdb8e241 100644 --- a/components/viz/service/main/viz_compositor_thread_runner_impl.cc +++ b/components/viz/service/main/viz_compositor_thread_runner_impl.cc @@ -35,13 +35,6 @@ #include "ui/ozone/public/ozone_platform.h" #endif -#if BUILDFLAG(IS_OHOS) -#include "base/process/process_handle.h" -#include "content/public/browser/browser_task_traits.h" -#include "content/public/browser/browser_thread.h" -#include "res_sched_client_adapter.h" -#endif - namespace viz { namespace { @@ -89,16 +82,6 @@ std::unique_ptr CreateAndStartCompositorThread() { CHECK(thread->StartWithOptions(std::move(thread_options))); -#if BUILDFLAG(IS_OHOS) - using namespace OHOS::NWeb; - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&ResSchedClientAdapter::ReportKeyThread), - ResSchedStatusAdapter::THREAD_CREATED, base::GetCurrentProcId(), - thread->GetThreadId(), ResSchedRoleAdapter::IMPORTANT_DISPLAY)); -#endif - // Setup tracing sampler profiler as early as possible. thread->task_runner()->PostTask( FROM_HERE, @@ -120,15 +103,6 @@ VizCompositorThreadRunnerImpl::~VizCompositorThreadRunnerImpl() { base::BindOnce(&VizCompositorThreadRunnerImpl::TearDownOnCompositorThread, base::Unretained(this))); thread_->Stop(); -#if BUILDFLAG(IS_OHOS) - using namespace OHOS::NWeb; - content::GetUIThreadTaskRunner({})->PostTask( - FROM_HERE, - base::BindOnce( - base::IgnoreResult(&ResSchedClientAdapter::ReportKeyThread), - ResSchedStatusAdapter::THREAD_DESTROYED, base::GetCurrentProcId(), - thread_->GetThreadId(), ResSchedRoleAdapter::IMPORTANT_DISPLAY)); -#endif } base::PlatformThreadId VizCompositorThreadRunnerImpl::thread_id() { diff --git a/content/browser/devtools/devtools_http_handler.cc b/content/browser/devtools/devtools_http_handler.cc index 2eff1d1c66..ff9aad0e92 100644 --- a/content/browser/devtools/devtools_http_handler.cc +++ b/content/browser/devtools/devtools_http_handler.cc @@ -239,16 +239,12 @@ void ServerStartedOnUI(base::WeakPtr handler, std::unique_ptr ip_address) { DCHECK_CURRENTLY_ON(BrowserThread::UI); if (handler && thread && server_wrapper) { - LOG(INFO) << "Domain Socket Server Started."; - handler->ServerStarted( std::unique_ptr(thread), std::unique_ptr(server_wrapper), std::unique_ptr(socket_factory), std::move(ip_address)); } else { - LOG(INFO) << "Domain Socket Server Terminate On UI."; - TerminateOnUI(std::unique_ptr(thread), std::unique_ptr(server_wrapper), std::unique_ptr(socket_factory)); @@ -299,7 +295,7 @@ void StartServerOnHandlerThread( } } } else { -#if !BUILDFLAG(IS_ANDROID) && !BUILDFLAG(IS_OHOS) +#if !BUILDFLAG(IS_ANDROID) // Android uses UNIX domain sockets which don't have an IP address. LOG(ERROR) << "Cannot start http server for devtools."; #endif @@ -794,9 +790,7 @@ DevToolsHttpHandler::DevToolsHttpHandler( new base::Thread(kDevToolsHandlerThreadName)); base::Thread::Options options; options.message_pump_type = base::MessagePumpType::IO; - LOG(INFO) << "Is Domain Socket Dev Tools Http Handler Entry?"; if (thread->StartWithOptions(std::move(options))) { - LOG(INFO) << "Is Domain Socket Dev Tools Http Handler Entry!"; auto task_runner = thread->task_runner(); task_runner->PostTask( FROM_HERE, diff --git a/content/browser/gpu/gpu_process_host.cc b/content/browser/gpu/gpu_process_host.cc index d8b0cf5857..926ea905b7 100644 --- a/content/browser/gpu/gpu_process_host.cc +++ b/content/browser/gpu/gpu_process_host.cc @@ -85,10 +85,6 @@ #include "components/metrics/stability_metrics_helper.h" #endif -#if BUILDFLAG(IS_OHOS) -#include "res_sched_client_adapter.h" -#endif - #if BUILDFLAG(IS_WIN) #include "base/win/win_util.h" #include "sandbox/policy/win/sandbox_win.h" @@ -764,14 +760,6 @@ GpuProcessHost::~GpuProcessHost() { } #endif -#if BUILDFLAG(IS_OHOS) - if (in_process_gpu_thread_) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_DESTROYED, - base::GetCurrentProcId(), in_process_gpu_thread_->GetThreadId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_DISPLAY); -#endif - // This is only called on the IO thread so no race against the constructor // for another GpuProcessHost. if (g_gpu_process_hosts[kind_] == this) @@ -918,12 +906,6 @@ bool GpuProcessHost::Init() { if (base::FeatureList::IsEnabled(features::kGpuUseDisplayThreadPriority)) options.priority = base::ThreadPriority::DISPLAY; in_process_gpu_thread_->StartWithOptions(std::move(options)); -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_CREATED, - base::GetCurrentProcId(), in_process_gpu_thread_->GetThreadId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_DISPLAY); -#endif } else if (!LaunchGpuProcess()) { return false; } diff --git a/content/browser/media/session/media_session_impl.cc b/content/browser/media/session/media_session_impl.cc index da3bfa2705..dd329b3746 100644 --- a/content/browser/media/session/media_session_impl.cc +++ b/content/browser/media/session/media_session_impl.cc @@ -975,9 +975,6 @@ void MediaSessionImpl::OnResumeInternal(SuspendType suspend_type) { MediaSessionImpl::MediaSessionImpl(WebContents* web_contents) : WebContentsObserver(web_contents), WebContentsUserData(*web_contents), -#if BUILDFLAG(IS_OHOS) - weakMediaSessionFactory_(this), -#endif audio_focus_state_(State::INACTIVE), desired_audio_focus_type_(AudioFocusType::kGainTransientMayDuck), is_ducking_(false), diff --git a/content/browser/media/session/media_session_impl.h b/content/browser/media/session/media_session_impl.h index 07d27975e4..c6422778a7 100644 --- a/content/browser/media/session/media_session_impl.h +++ b/content/browser/media/session/media_session_impl.h @@ -36,7 +36,7 @@ #if BUILDFLAG(IS_OHOS) namespace media { -class OHOSAudioOutputStream; + class OHOSAudioOutputStream; } #endif @@ -328,12 +328,11 @@ class MediaSessionImpl : public MediaSession, const base::UnguessableToken& GetRequestId() const; #if BUILDFLAG(IS_OHOS) - public: +public: std::unordered_set activeAudioStream_; int audioResumeInterval_ = 0; bool audioExclusive_ = true; bool isStreamSuspended_ = false; - base::WeakPtrFactory weakMediaSessionFactory_; #endif private: diff --git a/content/browser/renderer_host/input/fling_controller.cc b/content/browser/renderer_host/input/fling_controller.cc index be9a9b5008..39aab3f628 100644 --- a/content/browser/renderer_host/input/fling_controller.cc +++ b/content/browser/renderer_host/input/fling_controller.cc @@ -80,7 +80,7 @@ bool FlingController::ObserveAndFilterForTapSuppression( case WebInputEvent::Type::kGestureTap: case WebInputEvent::Type::kGestureDoubleTap: case WebInputEvent::Type::kGestureLongPress: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case WebInputEvent::Type::kGestureDragLongPress: #endif case WebInputEvent::Type::kGestureLongTap: diff --git a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc index 9e3453871f..7bab4541c1 100644 --- a/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc +++ b/content/browser/renderer_host/input/render_widget_host_latency_tracker.cc @@ -58,7 +58,7 @@ const char* GetTraceNameFromType(blink::WebInputEvent::Type type) { CASE_TYPE(GestureDoubleTap); CASE_TYPE(GestureTwoFingerTap); CASE_TYPE(GestureLongPress); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP CASE_TYPE(GestureDragLongPress); #endif CASE_TYPE(GestureLongTap); diff --git a/content/browser/renderer_host/input/stylus_text_selector.cc b/content/browser/renderer_host/input/stylus_text_selector.cc index a4e372bbed..50a252954a 100644 --- a/content/browser/renderer_host/input/stylus_text_selector.cc +++ b/content/browser/renderer_host/input/stylus_text_selector.cc @@ -30,7 +30,7 @@ std::unique_ptr CreateGestureDetector( std::unique_ptr detector( new ui::GestureDetector(config, listener, null_double_tap_listener)); detector->set_longpress_enabled(false); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP detector->set_draglongpress_enabled(false); #endif detector->set_showpress_enabled(false); diff --git a/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.cc b/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.cc index e78bd4b419..3e033a9a19 100644 --- a/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.cc +++ b/content/browser/renderer_host/input/touchscreen_tap_suppression_controller.cc @@ -26,7 +26,7 @@ bool TouchscreenTapSuppressionController::FilterTapEvent( case WebInputEvent::Type::kGestureShowPress: case WebInputEvent::Type::kGestureLongPress: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case WebInputEvent::Type::kGestureDragLongPress: #endif case WebInputEvent::Type::kGestureTapUnconfirmed: diff --git a/content/browser/renderer_host/render_frame_host_delegate.h b/content/browser/renderer_host/render_frame_host_delegate.h index a328dddf2b..4dba5b2bab 100644 --- a/content/browser/renderer_host/render_frame_host_delegate.h +++ b/content/browser/renderer_host/render_frame_host_delegate.h @@ -664,10 +664,10 @@ class CONTENT_EXPORT RenderFrameHostDelegate { bool is_hung) {} #endif -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP // Notified to UI, contextmenu popup window should be dimissed virtual void ClearContextMenu() {} -#endif // BUILDFLAG(IS_OHOS) +#endif // OHOS_ENABLE_DRAG_DROP protected: virtual ~RenderFrameHostDelegate() = default; }; diff --git a/content/browser/renderer_host/render_frame_host_impl.cc b/content/browser/renderer_host/render_frame_host_impl.cc index 565245aad7..78e7bb09fd 100644 --- a/content/browser/renderer_host/render_frame_host_impl.cc +++ b/content/browser/renderer_host/render_frame_host_impl.cc @@ -12980,11 +12980,11 @@ std::ostream& operator<<(std::ostream& o, return o << RenderFrameHostImpl::LifecycleStateImplToString(s); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void RenderFrameHostImpl::OnClearContextMenu() { if (IsInactiveAndDisallowActivation(DisallowActivationReasonId::kShowContextMenu)) return; delegate_->ClearContextMenu(); } -#endif // BUILDFLAG(IS_OHOS) +#endif // OHOS_ENABLE_DRAG_DROP } // namespace content diff --git a/content/browser/renderer_host/render_frame_host_impl.h b/content/browser/renderer_host/render_frame_host_impl.h index 6e854dbfc5..b077ec5820 100644 --- a/content/browser/renderer_host/render_frame_host_impl.h +++ b/content/browser/renderer_host/render_frame_host_impl.h @@ -2704,9 +2704,9 @@ class CONTENT_EXPORT RenderFrameHostImpl void OpenURL(blink::mojom::OpenURLParamsPtr params) override; void DidStopLoading() override; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void OnClearContextMenu() override; -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP friend class RenderAccessibilityHost; void HandleAXEvents(const ui::AXTreeID& tree_id, diff --git a/content/browser/renderer_host/render_process_host_impl.cc b/content/browser/renderer_host/render_process_host_impl.cc index 3227f6568d..ea9842d0a9 100644 --- a/content/browser/renderer_host/render_process_host_impl.cc +++ b/content/browser/renderer_host/render_process_host_impl.cc @@ -208,7 +208,6 @@ #if BUILDFLAG(IS_OHOS) #include "content/browser/font_unique_name_lookup/font_unique_name_lookup_service.h" -#include "res_sched_client_adapter.h" #include "third_party/blink/public/mojom/android_font_lookup/android_font_lookup.mojom.h" #endif @@ -3704,12 +3703,6 @@ void RenderProcessHostImpl::OnChannelConnected(int32_t peer_pid) { peer_pid, child_process_.get()); #endif -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_CREATED, peer_pid, peer_pid, - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_DISPLAY); -#endif - if (IsReady()) { DCHECK(!sent_render_process_ready_); sent_render_process_ready_ = true; @@ -4726,13 +4719,6 @@ void RenderProcessHostImpl::ProcessDied( // while we are dying. DCHECK(!deleting_soon_); -#if BUILDFLAG(IS_OHOS) - base::ProcessId process_id = GetProcess().Pid(); - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_DESTROYED, process_id, process_id, - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_DISPLAY); -#endif - // child_process_launcher_ can be NULL in single process mode or if fast // termination happened. ChildProcessTerminationInfo info; diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc index 686a385828..8d885e1041 100644 --- a/content/browser/storage_partition_impl.cc +++ b/content/browser/storage_partition_impl.cc @@ -1421,6 +1421,30 @@ StoragePartitionImpl::GetCookieManagerForBrowserProcess() { return cookie_manager_for_browser_process_.get(); } +#if BUILDFLAG(IS_OHOS) +network::mojom::CookieManager* StoragePartitionImpl::GetCookieManagerForOhos() { + DCHECK(initialized_); + // Create the CookieManager remote for ohos as needed. + if (!cookie_manager_for_ohos_ || !cookie_manager_for_ohos_.is_connected()) { + // Reset |cookie_manager_for_ohos_| before binding it again. + + cookie_manager_for_ohos_.reset(); + GetIOThreadTaskRunner({})->PostTask( + FROM_HERE, + base::BindOnce(&StoragePartitionImpl::GetCookieManagerForOhosInternal, + base::Unretained(this))); + completion_.Wait(); + } + return cookie_manager_for_ohos_.get(); +} + +void StoragePartitionImpl::GetCookieManagerForOhosInternal() { + GetNetworkContext()->GetCookieManager( + cookie_manager_for_ohos_.BindNewPipeAndPassReceiver()); + completion_.Signal(); +} +#endif + void StoragePartitionImpl::CreateRestrictedCookieManager( network::mojom::RestrictedCookieManagerRole role, const url::Origin& origin, @@ -2761,6 +2785,7 @@ void StoragePartitionImpl::InitNetworkContext() { context_params->cert_verifier_params = GetCertVerifierParams(std::move(cert_verifier_creation_params)); + // This mechanisms should be used only for legacy internal headers. You can // find a recommended alternative approach on URLRequest::cors_exempt_headers // at services/network/public/mojom/url_loader.mojom. diff --git a/content/browser/storage_partition_impl.h b/content/browser/storage_partition_impl.h index 4ba42c08a9..89198301eb 100644 --- a/content/browser/storage_partition_impl.h +++ b/content/browser/storage_partition_impl.h @@ -149,6 +149,9 @@ class CONTENT_EXPORT StoragePartitionImpl std::unique_ptr GetURLLoaderFactoryForBrowserProcessIOThread() override; network::mojom::CookieManager* GetCookieManagerForBrowserProcess() override; +#if BUILDFLAG(IS_OHOS) + network::mojom::CookieManager* GetCookieManagerForOhos() override; +#endif void CreateHasTrustTokensAnswerer( mojo::PendingReceiver receiver, const url::Origin& top_frame_origin) override; @@ -678,6 +681,12 @@ class CONTENT_EXPORT StoragePartitionImpl bool is_test_url_loader_factory_for_browser_process_with_corb_ = false; mojo::Remote cookie_manager_for_browser_process_; +#if BUILDFLAG(IS_OHOS) + mojo::Remote cookie_manager_for_ohos_; + base::WaitableEvent completion_{ + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED}; +#endif mojo::Remote origin_policy_manager_for_browser_process_; diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc index 0bc81428dc..6429496f82 100644 --- a/content/browser/web_contents/web_contents_impl.cc +++ b/content/browser/web_contents/web_contents_impl.cc @@ -992,8 +992,8 @@ WebContentsImpl::WebContentsImpl(BrowserContext* browser_context) } WebContentsImpl::~WebContentsImpl() { - TRACE_EVENT0("content", "WebContentsImpl::~WebContentsImpl"); + // Imperfect sanity check against double free, given some crashes unexpectedly // observed in the wild. CHECK(!IsBeingDestroyed()); @@ -2390,13 +2390,7 @@ void WebContentsImpl::SetPrimaryMainFrameImportance( void WebContentsImpl::WasOccluded() { TRACE_EVENT0("content", "WebContentsImpl::WasOccluded"); -#if BUILDFLAG(IS_OHOS) - // Many observers observe the visibility and they do not handle OCCLUDED. - // So Temporarily use HIDDEN. - UpdateVisibilityAndNotifyPageAndView(Visibility::HIDDEN); -#else UpdateVisibilityAndNotifyPageAndView(Visibility::OCCLUDED); -#endif } Visibility WebContentsImpl::GetVisibility() { @@ -2907,16 +2901,7 @@ void WebContentsImpl::SetSlowWebPreferences( std::string touch_enabled_default_switch = switches::kTouchEventFeatureDetectionDisabled; #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) - auto& system_properties_adapter = - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetSystemPropertiesInstance(); - OHOS::NWeb::ProductDeviceType deviceType = - system_properties_adapter.GetProductDeviceType(); - if (deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_TABLET || - deviceType == OHOS::NWeb::ProductDeviceType::DEVICE_TYPE_MOBILE) { - touch_enabled_default_switch = - switches::kTouchEventFeatureDetectionEnabled; - } + touch_enabled_default_switch = switches::kTouchEventFeatureDetectionEnabled; #endif // BUILDFLAG(IS_ANDROID) const std::string touch_enabled_switch = command_line.HasSwitch(switches::kTouchEventFeatureDetection) @@ -9456,43 +9441,6 @@ void WebContentsImpl::SetEnableBlankTargetPopupIntercept( OnWebPreferencesChanged(); } } - -void WebContentsImpl::PromptSaveOrUpdatePassword( - bool is_update, - std::unique_ptr form_to_save) { - form_to_save_ = std::move(form_to_save); - if (GetSavePasswordAutomatically()) { - SaveOrUpdatePassword(is_update); - return; - } - std::string full_url = form_to_save_->GetPendingCredentials().url.spec(); - if (delegate_) { - delegate_->ShowPasswordDialog(is_update, full_url); - } -} - -void WebContentsImpl::SaveOrUpdatePassword(bool is_update) { - if (is_update) { - form_to_save_->Update(form_to_save_->GetPendingCredentials()); - } else { - form_to_save_->Save(); - } -} - -void WebContentsImpl::ShowAutofillPopup( - const gfx::RectF& element_bounds, - bool is_rtl, - const std::vector& suggestions) { - if (delegate_) { - delegate_->OnShowAutofillPopup(element_bounds, is_rtl, suggestions); - } -} -void WebContentsImpl::HideAutofillPopup() { - // notify ui to dismiss hideAutofillPopup - if (delegate_) { - delegate_->OnHideAutofillPopup(); - } -} #endif // static @@ -9507,11 +9455,11 @@ std::pair WebContentsImpl::GetAvailablePointerAndHoverTypes() { return ui::GetAvailablePointerAndHoverTypes(); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void WebContentsImpl::ClearContextMenu() { if (delegate_) { delegate_->ClearContextMenu(); } } -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP } // namespace content diff --git a/content/browser/web_contents/web_contents_impl.h b/content/browser/web_contents/web_contents_impl.h index 271a4873b7..32e500be1d 100644 --- a/content/browser/web_contents/web_contents_impl.h +++ b/content/browser/web_contents/web_contents_impl.h @@ -79,11 +79,6 @@ #include "ui/native_theme/native_theme.h" #include "ui/native_theme/native_theme_observer.h" -#if defined(OHOS_NWEB_EX) -#include "components/password_manager/core/browser/password_form_manager_for_ui.h" -#include "components/password_manager/core/browser/password_manager.h" -#endif - #if BUILDFLAG(IS_ANDROID) #include "content/public/browser/android/child_process_importance.h" #endif @@ -403,27 +398,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, void SetForceEnableZoom(bool forceEnableZoom) override; bool GetForceEnableZoom() override { return force_enable_zoom_; } - - void SetSavePasswordAutomatically(bool enable) override { - LOG(INFO) << "set save password automatically: " << enable; - save_password_automatically_ = enable; - } - - bool GetSavePasswordAutomatically() override { - return save_password_automatically_; - } - void SetSavePassword(bool enable) override { - LOG(INFO) << "set save password enabled: " << enable; - save_password_ = enable; - } - - bool GetSavePassword() override { return save_password_; } - - void PromptSaveOrUpdatePassword( - bool is_update_password, - std::unique_ptr form_to_save); - void SaveOrUpdatePassword(bool is_update) override; - void SelectAndCopy() override; void SetShouldShowFreeCopy(bool is_selectable); @@ -433,12 +407,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, bool GetEnableBlankTargetPopupIntercept() override { return enable_blank_target_popup_intercept_; } - - void ShowAutofillPopup( - const gfx::RectF& element_bounds, - bool is_rtl, - const std::vector& suggestions) override; - void HideAutofillPopup() override; #endif // OHOS_NWEB_EX #endif @@ -932,9 +900,9 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) override; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void ClearContextMenu() override; -#endif // BUILDFLAG(IS_OHOS) +#endif // OHOS_ENABLE_DRAG_DROP // NavigatorDelegate --------------------------------------------------------- @@ -2379,9 +2347,6 @@ class CONTENT_EXPORT WebContentsImpl : public WebContents, bool is_selectable_; std::string user_agent_{""}; bool enable_blank_target_popup_intercept_ = true; - bool save_password_ = true; - bool save_password_automatically_ = false; - std::unique_ptr form_to_save_; #endif // OHOS_NWEB_EX base::WeakPtrFactory loading_weak_factory_{this}; diff --git a/content/common/frame.mojom b/content/common/frame.mojom index 86e64f64cc..df4e6d9960 100644 --- a/content/common/frame.mojom +++ b/content/common/frame.mojom @@ -795,6 +795,8 @@ interface FrameHost { // Called when the renderer is done loading a frame. DidStopLoading(); + // #ifdef OHOS_ENABLE_DRAG_DROP [EnableIf=is_ohos] OnClearContextMenu(); + // #endif OHOS_ENABLE_DRAG_DROP }; diff --git a/content/public/browser/content_browser_client.cc b/content/public/browser/content_browser_client.cc index 4a537bd1ad..0f2ae0ade7 100644 --- a/content/public/browser/content_browser_client.cc +++ b/content/public/browser/content_browser_client.cc @@ -135,12 +135,6 @@ bool ContentBrowserClient::IsExplicitNavigation(ui::PageTransition transition) { } bool ContentBrowserClient::ShouldUseMobileFlingCurve() { -#if BUILDFLAG(IS_OHOS) - if (base::SysInfo::IsLowEndDevice()) { - LOG(INFO) << "low device do not trigger fling"; - return false; - } -#endif #if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_OHOS) return true; #else diff --git a/content/public/browser/render_frame_host.h b/content/public/browser/render_frame_host.h index d74092d97f..3c0e789564 100644 --- a/content/public/browser/render_frame_host.h +++ b/content/public/browser/render_frame_host.h @@ -1036,9 +1036,9 @@ class CONTENT_EXPORT RenderFrameHost : public IPC::Listener, virtual DocumentRef GetDocumentRef() = 0; virtual WeakDocumentPtr GetWeakDocumentPtr() = 0; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP virtual void OnClearContextMenu() = 0; -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP private: // This interface should only be implemented inside content. diff --git a/content/public/browser/storage_partition.h b/content/public/browser/storage_partition.h index 4eee6e8e66..e2cd4e8a8c 100644 --- a/content/public/browser/storage_partition.h +++ b/content/public/browser/storage_partition.h @@ -118,6 +118,9 @@ class CONTENT_EXPORT StoragePartition { GetURLLoaderFactoryForBrowserProcessIOThread() = 0; virtual network::mojom::CookieManager* GetCookieManagerForBrowserProcess() = 0; +#if BUILDFLAG(IS_OHOS) + virtual network::mojom::CookieManager* GetCookieManagerForOhos() = 0; +#endif virtual void CreateHasTrustTokensAnswerer( mojo::PendingReceiver receiver, const url::Origin& top_frame_origin) = 0; diff --git a/content/public/browser/web_contents.h b/content/public/browser/web_contents.h index 570f65e01c..7ffbcb02b7 100644 --- a/content/public/browser/web_contents.h +++ b/content/public/browser/web_contents.h @@ -38,9 +38,7 @@ #include "services/network/public/mojom/web_sandbox_flags.mojom-shared.h" #include "third_party/abseil-cpp/absl/types/optional.h" #if BUILDFLAG(IS_OHOS) -#include "components/autofill/core/browser/ui/suggestion.h" #include "third_party/blink/public/common/messaging/web_message_port.h" -#include "ui/gfx/geometry/rect_f.h" #endif #include "third_party/blink/public/mojom/favicon/favicon_url.mojom-forward.h" #include "third_party/blink/public/mojom/frame/find_in_page.mojom-forward.h" @@ -54,6 +52,7 @@ #include "ui/gfx/geometry/size.h" #include "ui/gfx/native_widget_types.h" #include "url/gurl.h" + #if BUILDFLAG(IS_ANDROID) #include "base/android/scoped_java_ref.h" #endif @@ -601,8 +600,6 @@ class WebContents : public PageNavigator, virtual bool GetTouchInsertHandleMenuShow() = 0; virtual void OpenDateTimeChooser() = 0; virtual void CloseDateTimeChooser() = 0; -#endif - #if defined (OHOS_NWEB_EX) virtual void SetForceEnableZoom(bool forceEnableZoom) = 0; virtual bool GetForceEnableZoom() = 0; @@ -610,17 +607,8 @@ class WebContents : public PageNavigator, virtual bool ShouldShowFreeCopy() = 0; virtual void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) = 0; virtual bool GetEnableBlankTargetPopupIntercept() = 0; - virtual void SetSavePasswordAutomatically(bool enable) = 0; - virtual bool GetSavePasswordAutomatically() = 0; - virtual void SetSavePassword(bool enable) = 0; - virtual bool GetSavePassword() = 0; - virtual void SaveOrUpdatePassword(bool is_update) = 0; - virtual void ShowAutofillPopup( - const gfx::RectF& element_bounds, - bool is_rtl, - const std::vector& suggestions) = 0; - virtual void HideAutofillPopup() = 0; -#endif // OHOS_NWEB_EX +#endif // OHOS_NWEB_EX +#endif // Saves the given title to the navigation entry and does associated work. It // will update history and the view with the new title, and also synthesize @@ -1406,9 +1394,9 @@ class WebContents : public PageNavigator, PrerenderTriggerType trigger_type, const std::string& embedder_histogram_suffix) = 0; - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP virtual void ClearContextMenu() = 0; -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP private: // This interface should only be implemented inside content. diff --git a/content/public/browser/web_contents_delegate.cc b/content/public/browser/web_contents_delegate.cc index 55be775b36..cc0376af7b 100644 --- a/content/public/browser/web_contents_delegate.cc +++ b/content/public/browser/web_contents_delegate.cc @@ -91,7 +91,7 @@ bool WebContentsDelegate::HandleContextMenu(RenderFrameHost& render_frame_host, return false; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void WebContentsDelegate::ClearContextMenu() { } #endif diff --git a/content/public/browser/web_contents_delegate.h b/content/public/browser/web_contents_delegate.h index 3def6f4d30..53873e3b0f 100644 --- a/content/public/browser/web_contents_delegate.h +++ b/content/public/browser/web_contents_delegate.h @@ -33,10 +33,6 @@ #include "ui/gfx/geometry/rect_f.h" #include "ui/gfx/native_widget_types.h" -#if BUILDFLAG(IS_OHOS) -#include "components/autofill/core/browser/ui/suggestion.h" -#endif - #if BUILDFLAG(IS_ANDROID) #include "base/android/scoped_java_ref.h" #endif @@ -282,16 +278,6 @@ class CONTENT_EXPORT WebContentsDelegate { virtual bool HandleContextMenu(RenderFrameHost& render_frame_host, const ContextMenuParams& params); -#if defined(OHOS_NWEB_EX) - // notify ui show save password dialog - virtual void ShowPasswordDialog(bool is_update, const std::string& url) {} - - virtual void OnShowAutofillPopup( - const gfx::RectF& element_bounds, - bool is_rtl, - const std::vector& suggestions) {} - virtual void OnHideAutofillPopup() {} -#endif // Allows delegates to handle keyboard events before sending to the renderer. // See enum for description of return values. virtual KeyboardEventProcessingResult PreHandleKeyboardEvent( @@ -767,9 +753,9 @@ class CONTENT_EXPORT WebContentsDelegate { // Whether the WebContents is privileged. // It's used to prevent drag and drop between privileged and non-privileged // WebContents. -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP virtual void ClearContextMenu(); -#endif // BUILDFLAG(IS_OHOS) +#endif // OHOS_ENABLE_DRAG_DROP virtual bool IsPrivileged(); protected: diff --git a/content/public/browser/web_contents_view_delegate.cc b/content/public/browser/web_contents_view_delegate.cc index 2198a580b1..b56000b6fe 100644 --- a/content/public/browser/web_contents_view_delegate.cc +++ b/content/public/browser/web_contents_view_delegate.cc @@ -61,9 +61,9 @@ void WebContentsViewDelegate::OnPerformDrop(const DropData& drop_data, return std::move(callback).Run(DropCompletionResult::kContinue); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void WebContentsViewDelegate::ClearContextMenu() { } -#endif // BUILDFLAG(IS_OHOS) +#endif // OHOS_ENABLE_DRAG_DROP } // namespace content diff --git a/content/public/browser/web_contents_view_delegate.h b/content/public/browser/web_contents_view_delegate.h index 53636d375e..a89d73e9cc 100644 --- a/content/public/browser/web_contents_view_delegate.h +++ b/content/public/browser/web_contents_view_delegate.h @@ -58,9 +58,9 @@ class CONTENT_EXPORT WebContentsViewDelegate { virtual void ShowContextMenu(RenderFrameHost& render_frame_host, const ContextMenuParams& params); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP virtual void ClearContextMenu(); -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP // Tests can use ExecuteCommandForTesting to simulate executing a context menu // item (after first opening the context menu using the ShowContextMenu diff --git a/content/renderer/render_frame_impl.cc b/content/renderer/render_frame_impl.cc index b368f8dc39..7c9b95eedf 100644 --- a/content/renderer/render_frame_impl.cc +++ b/content/renderer/render_frame_impl.cc @@ -6255,12 +6255,12 @@ bool RenderFrameImpl::DeferMediaLoad(bool has_played_media_before, this, has_played_media_before, std::move(closure)); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void RenderFrameImpl::ClearContextMenu() { // It does not postTask here because contextmenu popup windows should be // dismissed before drag start. GetFrameHost()->OnClearContextMenu(); } -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP } // namespace content diff --git a/content/renderer/render_frame_impl.h b/content/renderer/render_frame_impl.h index 066362d93d..ec5172b374 100644 --- a/content/renderer/render_frame_impl.h +++ b/content/renderer/render_frame_impl.h @@ -397,7 +397,7 @@ class CONTENT_EXPORT RenderFrameImpl float GetDeviceScaleFactor() override; blink::scheduler::WebAgentGroupScheduler& GetAgentGroupScheduler() override; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void ClearContextMenu() override; #endif // blink::mojom::AutoplayConfigurationClient implementation: diff --git a/content/renderer/render_remote_proxy.cc b/content/renderer/render_remote_proxy.cc index 89ddb0bc03..188f7fbcaa 100644 --- a/content/renderer/render_remote_proxy.cc +++ b/content/renderer/render_remote_proxy.cc @@ -92,7 +92,8 @@ bool RenderRemoteProxy::WaitForBrowserFd() { while (++wait_count <= kMaxWaitCount) { if (!browser_fd_cv_.wait_for(lk, std::chrono::milliseconds(kTimeOutDur), []() { return is_browser_fd_received_; })) { - LOG(INFO) << "wait browser fd for " << wait_count * kTimeOutDur << " ms"; + LOG(INFO) << "retry AttachRenderProcess for " << wait_count << "time"; + g_app_mgr_client_adapter->AttachRenderProcess(g_render_remote_proxy); } else { LOG(INFO) << "success, wait for browser fd end"; return true; diff --git a/content/test/test_render_frame.cc b/content/test/test_render_frame.cc index df8ad2289f..52de573c3a 100644 --- a/content/test/test_render_frame.cc +++ b/content/test/test_render_frame.cc @@ -149,7 +149,7 @@ class MockFrameHost : public mojom::FrameHost { std::move(browser_interface_broker_receiver)); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void OnClearContextMenu() override { } diff --git a/crypto/encryptor.cc b/crypto/encryptor.cc index b06f67974d..0d21db3365 100644 --- a/crypto/encryptor.cc +++ b/crypto/encryptor.cc @@ -15,11 +15,6 @@ #include "third_party/boringssl/src/include/openssl/aes.h" #include "third_party/boringssl/src/include/openssl/evp.h" -#if BUILDFLAG(IS_OHOS) -#define GCM_TAG_SIZE 16 -#define GCM_IV_SIZE 12 -#endif - namespace crypto { namespace { @@ -33,19 +28,6 @@ const EVP_CIPHER* GetCipherForKey(const SymmetricKey* key) { } } -#if BUILDFLAG(IS_OHOS) -const EVP_CIPHER* GetCipherForKeyGCM(const SymmetricKey* key) { - switch (key->key().length()) { - case 16: - return EVP_aes_128_gcm(); - case 32: - return EVP_aes_256_gcm(); - default: - return nullptr; - } -} -#endif - } // namespace ///////////////////////////////////////////////////////////////////////////// @@ -63,11 +45,7 @@ bool Encryptor::Init(const SymmetricKey* key, Mode mode, base::span iv) { DCHECK(key); -#if BUILDFLAG(IS_OHOS) - DCHECK(mode == CBC || mode == CTR || mode == GCM); -#else DCHECK(mode == CBC || mode == CTR); -#endif EnsureOpenSSLInit(); if (mode == CBC && iv.size() != AES_BLOCK_SIZE) @@ -79,11 +57,6 @@ bool Encryptor::Init(const SymmetricKey* key, if (GetCipherForKey(key) == nullptr) return false; -#if BUILDFLAG(IS_OHOS) - if (mode == GCM && iv.size() != GCM_IV_SIZE) - return false; -#endif - key_ = key; mode_ = mode; iv_.assign(iv.begin(), iv.end()); @@ -135,53 +108,16 @@ bool Encryptor::CryptString(bool do_encrypt, uint8_t* out_ptr = reinterpret_cast(base::WriteInto(&result, out_size + 1)); - absl::optional len; -#if BUILDFLAG(IS_OHOS) - std::string tag(GCM_TAG_SIZE, 0); - if (mode_ == CTR) { - len = CryptCTR(do_encrypt, base::as_bytes(base::make_span(input)), - base::make_span(out_ptr, out_size)); - } else if (mode_ == GCM) { - if (do_encrypt) { - len = EncryptGCM(base::as_bytes(base::make_span(input)), - base::make_span(out_ptr, out_size), &tag); - } else { - // Get the tag that we attached with cipher during encryption from input - tag = - std::string(input.substr(input.length() - GCM_TAG_SIZE, GCM_TAG_SIZE)); - // Get the cipher part only from input - std::string ciphertext = std::string( - input.substr(0, input.length() - GCM_TAG_SIZE)); - const size_t output_size = ciphertext.length(); - CHECK_GT(output_size, 0u); - CHECK_GT(output_size + 1, ciphertext.length()); - out_ptr = - reinterpret_cast(base::WriteInto(&result, output_size + 1)); - len = DecryptGCM(ciphertext, base::make_span(out_ptr, output_size), &tag); - } - } else { - len = Crypt(do_encrypt, base::as_bytes(base::make_span(input)), - base::make_span(out_ptr, out_size)); - } -#else - len = (mode_ == CTR) - ? CryptCTR(do_encrypt, base::as_bytes(base::make_span(input)), - base::make_span(out_ptr, out_size)) - : Crypt(do_encrypt, base::as_bytes(base::make_span(input)), - base::make_span(out_ptr, out_size)); -#endif - + absl::optional len = + (mode_ == CTR) + ? CryptCTR(do_encrypt, base::as_bytes(base::make_span(input)), + base::make_span(out_ptr, out_size)) + : Crypt(do_encrypt, base::as_bytes(base::make_span(input)), + base::make_span(out_ptr, out_size)); if (!len) return false; result.resize(*len); - -#if BUILDFLAG(IS_OHOS) - // concat tag with cipher at the end. - if (mode_ == GCM && do_encrypt) - result += tag; -#endif - *output = std::move(result); return true; } @@ -202,13 +138,7 @@ bool Encryptor::CryptBytes(bool do_encrypt, } size_t Encryptor::MaxOutput(bool do_encrypt, size_t length) { -#if BUILDFLAG(IS_OHOS) - size_t result = length + ((do_encrypt && mode_ == CBC) ? 16 : - (do_encrypt && mode_ == GCM) ? 12 : 0); -#else size_t result = length + ((do_encrypt && mode_ == CBC) ? 16 : 0); -#endif - CHECK_GE(result, length); // Overflow return result; } @@ -277,130 +207,4 @@ absl::optional Encryptor::CryptCTR(bool do_encrypt, return input.size(); } -#if BUILDFLAG(IS_OHOS) -absl::optional Encryptor::EncryptGCM(base::span input, - base::span output, - std::string* tag) { - DCHECK(key_); - DCHECK(output.data()); - - const EVP_CIPHER* cipher = GetCipherForKeyGCM(key_); - DCHECK(cipher); - - const std::string& key = key_->key(); - DCHECK_EQ(EVP_CIPHER_iv_length(cipher), iv_.size()); - DCHECK_EQ(EVP_CIPHER_key_length(cipher), key.size()); - - OpenSSLErrStackTracer err_tracer(FROM_HERE); - - bssl::ScopedEVP_CIPHER_CTX ctx; - /* Initialise the encryption operation */ - if (!EVP_EncryptInit_ex(ctx.get(), cipher, nullptr, nullptr, nullptr)) - return absl::nullopt; - - /* Set the IV length, default is 12 byte which is not appropriate */ - if (!EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv_.size(), - nullptr)) - return absl::nullopt; - - /* Initialise Key and IV */ - if (!EVP_EncryptInit_ex(ctx.get(), nullptr, nullptr, - reinterpret_cast(key.data()), - iv_.data())) { - return absl::nullopt; - } - - const size_t output_size = input.size() + (iv_.size()); - CHECK_GT(output_size, 0u); - CHECK_GT(output_size + 1, input.size()); - - int out_len; - - /* Provide the plaintext and obtain the encrypted update - * EVP_EncryptUpdate may call multiples times if necessary - */ - if (!EVP_EncryptUpdate(ctx.get(), output.data(), &out_len, - reinterpret_cast(input.data()), - input.size())) - return absl::nullopt; - - /* Finalise the encryption. Usually ciphertext byte may be - * written in this stage but this does not occure in GCM mode - */ - int len; - if (!EVP_EncryptFinal_ex(ctx.get(), output.data() + out_len, &len)) - return absl::nullopt; - - out_len += len; - - /*Get the tag */ - if (!EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_GET_TAG, GCM_TAG_SIZE, - (void*)tag->data())) - return absl::nullopt; - - DCHECK_LE(out_len, static_cast(output_size)); - - return out_len; -} - -absl::optional Encryptor::DecryptGCM(const std::string& input, - base::span output, - std::string* tag) { - DCHECK(key_); - DCHECK(output.data()); - - const EVP_CIPHER* cipher = GetCipherForKeyGCM(key_); - DCHECK(cipher); - - const std::string& key = key_->key(); - DCHECK_EQ(EVP_CIPHER_iv_length(cipher), iv_.size()); - DCHECK_EQ(EVP_CIPHER_key_length(cipher), key.size()); - - OpenSSLErrStackTracer err_tracer(FROM_HERE); - bssl::ScopedEVP_CIPHER_CTX ctx; - - /* Initialise the decryption process */ - if (!EVP_DecryptInit_ex(ctx.get(), cipher, nullptr, nullptr, nullptr)) - return absl::nullopt; - - /* Set the IV length */ - if (!EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv_.size(), - nullptr)) - return absl::nullopt; - - /* Initialise Key and IV */ - if (!EVP_DecryptInit_ex(ctx.get(), nullptr, nullptr, - reinterpret_cast(key.data()), - iv_.data())) - return absl::nullopt; - - int out_len; - - /* Provide the cipher text and get the output as plaintext */ - if (!EVP_DecryptUpdate(ctx.get(), output.data(), &out_len, - reinterpret_cast(input.data()), - input.length())) - return absl::nullopt; - - /* Set expected tag which is used during encryption */ - if (!EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_TAG, GCM_TAG_SIZE, - (void*)tag->data())) - return absl::nullopt; - /* Finalise the decryption. If plaintext is not trustworthy then - * it return as failure. - */ - int len; - int ret = EVP_DecryptFinal_ex(ctx.get(), output.data() + out_len, &len); - if (ret > 0) { - out_len += len; - } else { - return absl::nullopt; - } - - DCHECK_LE(out_len, static_cast(input.length())); - - return out_len; -} -#endif - } // namespace crypto diff --git a/crypto/encryptor.h b/crypto/encryptor.h index 4d7fe17fb1..8cd4cd9eff 100644 --- a/crypto/encryptor.h +++ b/crypto/encryptor.h @@ -31,10 +31,6 @@ class CRYPTO_EXPORT Encryptor { enum Mode { CBC, CTR, -#if BUILDFLAG(IS_OHOS) - GCM, -#endif - }; Encryptor(); @@ -97,15 +93,6 @@ class CRYPTO_EXPORT Encryptor { base::span input, base::span output); -#if BUILDFLAG(IS_OHOS) - absl::optional EncryptGCM(base::span input, - base::span output, - std::string* tag); - absl::optional DecryptGCM(const std::string& input, - base::span output, - std::string* tag); -#endif - // In CBC mode, the IV passed to Init(). In CTR mode, the counter value passed // to SetCounter(). std::vector iv_; diff --git a/media/audio/audio_thread_impl.cc b/media/audio/audio_thread_impl.cc index ce37d057da..f4bb46872b 100644 --- a/media/audio/audio_thread_impl.cc +++ b/media/audio/audio_thread_impl.cc @@ -11,11 +11,6 @@ #include "media/audio/audio_thread_hang_monitor.h" #include "third_party/abseil-cpp/absl/types/optional.h" -#if BUILDFLAG(IS_OHOS) -#include "base/process/process_handle.h" -#include "res_sched_client_adapter.h" -#endif - namespace media { AudioThreadImpl::AudioThreadImpl() @@ -40,13 +35,6 @@ AudioThreadImpl::AudioThreadImpl() #endif worker_task_runner_ = thread_.task_runner(); -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_CREATED, - base::GetCurrentProcId(), thread_.GetThreadId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_AUDIO); -#endif - #if !BUILDFLAG(IS_MAC) && !BUILDFLAG(IS_ANDROID) // Since we run on the main thread on Mac, we don't need a hang monitor. // https://crbug.com/946968: The hang monitor possibly causes crashes on @@ -66,13 +54,6 @@ void AudioThreadImpl::Stop() { hang_monitor_.reset(); -#if BUILDFLAG(IS_OHOS) - OHOS::NWeb::ResSchedClientAdapter::ReportKeyThread( - OHOS::NWeb::ResSchedStatusAdapter::THREAD_DESTROYED, - base::GetCurrentProcId(), thread_.GetThreadId(), - OHOS::NWeb::ResSchedRoleAdapter::IMPORTANT_AUDIO); -#endif - // Note that on MACOSX, we can still have tasks posted on the |task_runner_|, // since it is the main thread task runner and we do not stop the main thread. // But this is fine because none of those tasks will actually run. diff --git a/media/audio/ohos/ohos_audio_capturer_source.cc b/media/audio/ohos/ohos_audio_capturer_source.cc index 0e77c7f18f..c787a33972 100755 --- a/media/audio/ohos/ohos_audio_capturer_source.cc +++ b/media/audio/ohos/ohos_audio_capturer_source.cc @@ -97,7 +97,6 @@ void OHOSAudioCapturerSource::InitializeOnCapturerThread() { AudioAdapterSourceType::SOURCE_TYPE_VOICE_COMMUNICATION; capturerOptions.capturerFlags = 0; capturer_->Create(capturerOptions); - capturer_->GetFrameCount(frameCount_); } void OHOSAudioCapturerSource::StartOnCapturerThread() { @@ -135,19 +134,21 @@ void OHOSAudioCapturerSource::ReadData() { BufferDescAdapter bufferDesc; bufferDesc.bufLength = 0; capturer_->GetBufferDesc(bufferDesc); - if (static_cast(frameCount_) > 2 * params_.sample_rate() / 100) { + uint32_t frameCount = 0; + capturer_->GetFrameCount(frameCount); + if (static_cast(frameCount) > 2 * params_.sample_rate() / 100) { LOG(ERROR) << "audioBus cannot handle input audio data more than 20ms. " "frameCount: " - << static_cast(frameCount_); + << static_cast(frameCount); capturer_->Enqueue(bufferDesc); return; } base::TimeTicks timeStamp = base::TimeTicks() + base::Nanoseconds(capturer_->GetAudioTime()); - auto audio_bus = AudioBus::Create(params_.channels(), frameCount_); + auto audio_bus = AudioBus::Create(params_.channels(), frameCount); audio_bus->FromInterleaved( reinterpret_cast(bufferDesc.buffer), - static_cast(frameCount_)); + static_cast(frameCount)); if (callback_) { callback_->Capture(audio_bus.get(), timeStamp, 1.0, false); } diff --git a/media/audio/ohos/ohos_audio_capturer_source.h b/media/audio/ohos/ohos_audio_capturer_source.h index 83a3e51678..72a6b9f834 100755 --- a/media/audio/ohos/ohos_audio_capturer_source.h +++ b/media/audio/ohos/ohos_audio_capturer_source.h @@ -64,7 +64,6 @@ class MEDIA_EXPORT OHOSAudioCapturerSource final : public AudioCapturerSource { void ReportError(const std::string& message); std::unique_ptr capturer_; - uint32_t frameCount_ = 0; scoped_refptr capturer_task_runner_; scoped_refptr main_task_runner_; AudioParameters params_; diff --git a/media/audio/ohos/ohos_audio_manager.cc b/media/audio/ohos/ohos_audio_manager.cc index 5986c65011..8578f7f358 100644 --- a/media/audio/ohos/ohos_audio_manager.cc +++ b/media/audio/ohos/ohos_audio_manager.cc @@ -5,11 +5,9 @@ #include "media/audio/ohos/ohos_audio_manager.h" #include -#include "base/bind.h" +#include "audio_system_manager_adapter.h" #include "base/command_line.h" #include "base/logging.h" -#include "base/system/system_monitor.h" -#include "media/base/bind_to_current_loop.h" #include "media/base/media_switches.h" #include "ohos_adapter_helper.h" @@ -19,23 +17,8 @@ constexpr int kDefaultSampleRate = 48000; constexpr int kDefaultChannelCount = 2; constexpr int kMinimumOutputBufferSize = 2048; constexpr int kMinimumInputBufferSize = 2048; -const int32_t AUDIO_DEFAULT_DEVICE_ID = 1000000; -const char* AUDIO_DEFAULT_DEVICE_NAME = "(default)"; static const char* AUDIO_MANAGER_NAME = "OHOS"; -AudioManagerDeviceChangeCallback::AudioManagerDeviceChangeCallback( - base::RepeatingClosure cb) - : outputDeviceChangeListenerCallback_(cb) {} - -AudioManagerDeviceChangeCallback::~AudioManagerDeviceChangeCallback() {} - -void AudioManagerDeviceChangeCallback::OnDeviceChange() { - LOG(INFO) << "AudioManagerDeviceChangeCallback::OnDeviceChange"; - outputDeviceChangeListenerCallback_.Run(); - if (auto* monitor = base::SystemMonitor::Get()) - monitor->ProcessDevicesChanged(base::SystemMonitor::DEVTYPE_AUDIO); -} - std::unique_ptr CreateAudioManager( std::unique_ptr audio_thread, AudioLogFactory* audio_log_factory) { @@ -47,14 +30,7 @@ OHOSAudioManager::OHOSAudioManager(std::unique_ptr audio_thread, AudioLogFactory* audio_log_factory) : AudioManagerBase(std::move(audio_thread), audio_log_factory) {} -OHOSAudioManager::~OHOSAudioManager() { - int32_t ret = OhosAdapterHelper::GetInstance() - .GetAudioSystemManager() - .UnsetDeviceChangeCallback(); - if (ret != 0) - LOG(ERROR) << "OHOSAudioManager::UnsetDeviceChangeCallback failed. ret: " - << ret; -}; +OHOSAudioManager::~OHOSAudioManager() = default; // Implementation of AudioManager. bool OHOSAudioManager::HasAudioOutputDevices() { @@ -79,18 +55,11 @@ void OHOSAudioManager::GetAudioOutputDeviceNames( OhosAdapterHelper::GetInstance().GetAudioSystemManager().GetDevices( AdapterDeviceFlag::OUTPUT_DEVICES_FLAG); for (auto audioDevice : audioDeviceList) { - device_names->emplace_back(audioDevice.deviceName, - base::NumberToString(audioDevice.deviceId)); + AudioDeviceName device; + device.unique_id = std::to_string(audioDevice.deviceId); + device.device_name = audioDevice.deviceName; + device_names->push_back(device); } - auto defaultOutputDevice = OhosAdapterHelper::GetInstance() - .GetAudioSystemManager() - .GetDefaultOutputDevice(); - std::string defaultOutputDeviceName = - AUDIO_DEFAULT_DEVICE_NAME + defaultOutputDevice.deviceName; - AudioDeviceName device_name; - device_name.unique_id = base::NumberToString(AUDIO_DEFAULT_DEVICE_ID); - device_name.device_name = defaultOutputDeviceName; - device_names->push_front(device_name); } void OHOSAudioManager::GetAudioInputDeviceNames( @@ -103,14 +72,11 @@ void OHOSAudioManager::GetAudioInputDeviceNames( OhosAdapterHelper::GetInstance().GetAudioSystemManager().GetDevices( AdapterDeviceFlag::INPUT_DEVICES_FLAG); for (auto audioDevice : audioDeviceList) { - device_names->emplace_back(audioDevice.deviceName, - base::NumberToString(audioDevice.deviceId)); + AudioDeviceName device; + device.unique_id = std::to_string(audioDevice.deviceId); + device.device_name = audioDevice.deviceName; + device_names->push_back(device); } - std::string defaultInputDeviceName = AUDIO_DEFAULT_DEVICE_NAME; - AudioDeviceName device_name; - device_name.unique_id = base::NumberToString(AUDIO_DEFAULT_DEVICE_ID); - device_name.device_name = defaultInputDeviceName; - device_names->push_front(device_name); } const char* OHOSAudioManager::GetName() { @@ -131,19 +97,6 @@ AudioOutputStream* OHOSAudioManager::MakeLowLatencyOutputStream( const LogCallback& log_callback) { LOG(INFO) << "OHOSAudioManager::MakeLowLatencyOutputStream"; SelectAudioDevice(device_id, false); - if (!outputDeviceChangeCallback_) { - outputDeviceChangeCallback_ = - std::make_shared( - BindToCurrentLoop(base::BindRepeating( - &OHOSAudioManager::NotifyAllOutputDeviceChangeListeners, - base::Unretained(this)))); - int32_t ret = OhosAdapterHelper::GetInstance() - .GetAudioSystemManager() - .SetDeviceChangeCallback(outputDeviceChangeCallback_); - if (ret != 0) - LOG(ERROR) << "OHOSAudioManager::SetDeviceChangeCallback failed. ret: " - << ret; - } return new OHOSAudioOutputStream(this, params, isCommunication_); } @@ -195,16 +148,9 @@ void OHOSAudioManager::ReleaseInputStream(AudioInputStream* stream) { void OHOSAudioManager::SelectAudioDevice(const std::string& device_id, bool isInput) { - if (device_id.empty()) { - LOG(ERROR) << "OHOSAudioManager::SelectAudioDevice device_id is empty."; - return; - } - LOG(INFO) << "OHOSAudioManager::SelectAudioDevice device_id is: " - << device_id; + LOG(INFO) << "OHOSAudioManager::SelectAudioDevice"; AudioAdapterDeviceDesc desc; - int deviceId = 0; - base::StringToInt(device_id, &deviceId); - desc.deviceId = deviceId; + desc.deviceId = atoi(device_id.c_str()); desc.deviceName = std::string(); int32_t ret = OhosAdapterHelper::GetInstance() .GetAudioSystemManager() diff --git a/media/audio/ohos/ohos_audio_manager.h b/media/audio/ohos/ohos_audio_manager.h index 71f08f9879..0f466c3677 100644 --- a/media/audio/ohos/ohos_audio_manager.h +++ b/media/audio/ohos/ohos_audio_manager.h @@ -5,25 +5,12 @@ #ifndef MEDIA_AUDIO_OHOS_AUDIO_MANAGER_H_ #define MEDIA_AUDIO_OHOS_AUDIO_MANAGER_H_ -#include "audio_system_manager_adapter.h" #include "media/audio/audio_manager_base.h" #include "media/audio/ohos/ohos_audio_input_stream.h" #include "media/audio/ohos/ohos_audio_output_stream.h" namespace media { -class AudioManagerDeviceChangeCallback - : public AudioManagerDeviceChangeCallbackAdapter { - public: - AudioManagerDeviceChangeCallback(base::RepeatingClosure cb); - ~AudioManagerDeviceChangeCallback(); - - void OnDeviceChange() override; - - private: - const base::RepeatingClosure outputDeviceChangeListenerCallback_; -}; - class MEDIA_EXPORT OHOSAudioManager : public AudioManagerBase { public: OHOSAudioManager(std::unique_ptr audio_thread, @@ -69,9 +56,7 @@ class MEDIA_EXPORT OHOSAudioManager : public AudioManagerBase { void SelectAudioDevice(const std::string& device_id, bool isInput); private: - bool isCommunication_ = false; - std::shared_ptr - outputDeviceChangeCallback_ = nullptr; + bool isCommunication_ = false; }; } // namespace media diff --git a/media/audio/ohos/ohos_audio_output_stream.cc b/media/audio/ohos/ohos_audio_output_stream.cc index 453eb69f8f..a6a9d885d1 100644 --- a/media/audio/ohos/ohos_audio_output_stream.cc +++ b/media/audio/ohos/ohos_audio_output_stream.cc @@ -65,15 +65,10 @@ OHOSAudioOutputStream::OHOSAudioOutputStream(OHOSAudioManager* manager, if (!webContent) { LOG(ERROR) << "AudioOutputStream get webContent failed."; } else { - content::MediaSessionImpl* mediaSession = - content::MediaSessionImpl::Get(webContent); - if (!mediaSession) { - LOG(ERROR) << "AudioOutputStream get mediaSession failed."; - } - weakMediaSession_ = mediaSession->weakMediaSessionFactory_.GetWeakPtr(); - if (!weakMediaSession_) - LOG(ERROR) << "OHOSAudioOutputStream::OHOSAudioOutputStream " - "weakMediaSession get failed"; + mediaSession_ = content::MediaSessionImpl::Get(webContent); + } + if (!mediaSession_) { + LOG(ERROR) << "AudioOutputStream get mediaSession failed."; } audio_renderer_ = OhosAdapterHelper::GetInstance().CreateAudioRendererAdapter(); @@ -89,7 +84,6 @@ OHOSAudioOutputStream::OHOSAudioOutputStream(OHOSAudioManager* manager, OHOSAudioOutputStream::~OHOSAudioOutputStream() { // Close() must be called first. - LOG(INFO) << "OHOSAudioOutputStream::~OHOSAudioOutputStream"; if (audio_renderer_ != nullptr) { (void)audio_renderer_->Release(); audio_renderer_ = nullptr; @@ -124,7 +118,6 @@ bool OHOSAudioOutputStream::Open() { } void OHOSAudioOutputStream::Close() { - LOG(INFO) << "OHOSAudioOutputStream::Close"; Stop(); ReleaseAudioBuffer(); manager_->ReleaseOutputStream(this); @@ -136,6 +129,25 @@ void OHOSAudioOutputStream::Start(AudioSourceCallback* callback) { DCHECK(reference_time_.is_null()); DCHECK(!timer_.IsRunning()); rendererCallback_->SetSuspendFlag(false); + if (!mediaSession_) { + LOG(ERROR) << "OHOSAudioOutputStream::Start mediaSession is null."; + return; + } + if (!mediaSession_->activeAudioStream_.empty()) { + for (auto stream : mediaSession_->activeAudioStream_) { + LOG(INFO) << "OHOSAudioOutputStream::Start refresh other active streams"; + if (!stream) { + LOG(ERROR) << "OHOSAudioOutputStream::Start the active stream is null"; + mediaSession_->activeAudioStream_.erase(stream); + continue; + } + stream->SetInterruptMode(false); + stream->Refresh(); + } + SetInterruptMode(false); + } else { + SetInterruptMode(mediaSession_->audioExclusive_); + } int32_t ret = audio_renderer_->SetAudioRendererCallback(rendererCallback_); if (ret != AudioAdapterCode::AUDIO_OK) { LOG(ERROR) @@ -143,8 +155,7 @@ void OHOSAudioOutputStream::Start(AudioSourceCallback* callback) { rendererCallback_.reset(); return; } - if (weakMediaSession_) - Prepare(weakMediaSession_.get()); + if (StartRender()) { callback_ = callback; memset(audio_data_[active_buffer_index_], 0, buffer_size_bytes_); @@ -154,13 +165,15 @@ void OHOSAudioOutputStream::Start(AudioSourceCallback* callback) { PumpSamples(); } } + mediaSession_->activeAudioStream_.insert(this); + mediaSession_->isStreamSuspended_ = false; } void OHOSAudioOutputStream::Stop() { LOG(INFO) << "OHOSAudioOutputStream::Stop"; main_task_runner_->PostTask( FROM_HERE, base::BindOnce(&OHOSAudioOutputStream::Erase, - base::Unretained(this), weakMediaSession_)); + base::Unretained(this), mediaSession_)); callback_ = nullptr; if (!reference_time_.is_null()) { reference_time_ = base::TimeTicks(); @@ -176,11 +189,6 @@ void OHOSAudioOutputStream::Stop() { } void OHOSAudioOutputStream::Refresh() { - LOG(INFO) << "OHOSAudioOutputStream::Refresh"; - if (!audio_renderer_) { - LOG(ERROR) << "OHOSAudioOutputStream::Refresh audio_renderer_ is null."; - return; - } isRefreshing_ = true; audio_renderer_->Stop(); audio_renderer_->Start(); @@ -188,13 +196,7 @@ void OHOSAudioOutputStream::Refresh() { } void OHOSAudioOutputStream::SetInterruptMode(bool audioExclusive) { - LOG(INFO) << "OHOSAudioOutputStream::SetInterruptMode audioExclusive: " - << audioExclusive; - if (!audio_renderer_) { - LOG(ERROR) - << "OHOSAudioOutputStream::SetInterruptMode audio_renderer_ is null."; - return; - } + LOG(INFO) << "OHOSAudioOutputStream::SetInterruptMode"; audio_renderer_->SetInterruptMode(audioExclusive); } @@ -227,12 +229,11 @@ bool OHOSAudioOutputStream::InitRender( } return false; } - if (!weakMediaSession_) { + if (!mediaSession_) { LOG(ERROR) << "OHOSAudioOutputStream::InitRender Get mediaSession failed."; return false; } - rendererCallback_ = - std::make_shared(weakMediaSession_.get()); + rendererCallback_ = std::make_shared(mediaSession_); if (!rendererCallback_) { LOG(ERROR) << "OHOSAudioOutputStream::InitRender Get rendererCallback failed."; @@ -259,53 +260,35 @@ bool OHOSAudioOutputStream::StartRender() { return true; } -void OHOSAudioOutputStream::Erase( - base::WeakPtr weakMediaSession) { - LOG(INFO) << "OHOSAudioOutputStream::Erase"; - if (!weakMediaSession) { - LOG(ERROR) << "OHOSAudioOutputStream::Erase mediaSession is null"; +void OHOSAudioOutputStream::Erase(content::MediaSessionImpl* mediaSession) { + content::RenderFrameHost* renderFrameHost = content::RenderFrameHost::FromID( + parameters_.render_process_id(), parameters_.render_frame_id()); + if (!renderFrameHost) { + LOG(ERROR) << "OHOSAudioOutputStream::Stop renderFrameHost is null."; + return; + } + if (!content::WebContents::FromRenderFrameHost(renderFrameHost) || + !mediaSession) { + LOG(ERROR) + << "OHOSAudioOutputStream::Stop webContent or mediaSession is null."; return; } - content::MediaSessionImpl* mediaSession = weakMediaSession.get(); if (!mediaSession->activeAudioStream_.empty()) { mediaSession->activeAudioStream_.erase(this); for (auto stream : mediaSession->activeAudioStream_) { if (!stream) { - LOG(ERROR) << "OHOSAudioOutputStream::Erase the active stream is null"; + LOG(ERROR) << "OHOSAudioOutputStream::Stop the active stream is null"; mediaSession->activeAudioStream_.erase(stream); continue; } if (mediaSession->isStreamSuspended_) { - LOG(INFO) << "OHOSAudioOutputStream::Erase has suspended stream"; + LOG(INFO) << "OHOSAudioOutputStream::Stop has suspended stream."; stream->Stop(); } } } } -void OHOSAudioOutputStream::Prepare(content::MediaSessionImpl* mediaSession) { - if (!mediaSession->activeAudioStream_.empty()) { - for (auto stream : mediaSession->activeAudioStream_) { - LOG(INFO) - << "OHOSAudioOutputStream::Prepare refresh other active streams"; - if (!stream) { - LOG(ERROR) - << "OHOSAudioOutputStream::Prepare the active stream is null"; - mediaSession->activeAudioStream_.erase(stream); - continue; - } - stream->SetInterruptMode(false); - stream->Refresh(); - } - LOG(ERROR) << "OHOSAudioOutputStream::Prepare setInterruptMode"; - SetInterruptMode(false); - } else { - SetInterruptMode(mediaSession->audioExclusive_); - } - mediaSession->activeAudioStream_.insert(this); - mediaSession->isStreamSuspended_ = false; -} - void OHOSAudioOutputStream::ReportError() { LOG(ERROR) << "ohos audio render error happened"; reference_time_ = base::TimeTicks(); @@ -351,16 +334,15 @@ void OHOSAudioOutputStream::PumpSamples() { LOG(DEBUG) << "Audio renderer write audio data failed."; if (!audio_renderer_->IsRendererStateRunning() && !isRefreshing_) { rendererCallback_->SetSuspendFlag(true); - if (!weakMediaSession_) { + if (!mediaSession_) { LOG(ERROR) << "Try to suspend audio but get mediaSession failed."; ReportError(); return; } - if (weakMediaSession_.get()->IsActive()) { + if (mediaSession_->IsActive()) { LOG(INFO) << "MediaSession is suspending the audio."; - weakMediaSession_.get()->Suspend( - content::MediaSession::SuspendType::kSystem); - weakMediaSession_.get()->isStreamSuspended_ = true; + mediaSession_->Suspend(content::MediaSession::SuspendType::kSystem); + mediaSession_->isStreamSuspended_ = true; } } else { ReportError(); diff --git a/media/audio/ohos/ohos_audio_output_stream.h b/media/audio/ohos/ohos_audio_output_stream.h index 449a741cd8..ad07d12800 100644 --- a/media/audio/ohos/ohos_audio_output_stream.h +++ b/media/audio/ohos/ohos_audio_output_stream.h @@ -85,9 +85,7 @@ class OHOSAudioOutputStream : public AudioOutputStream { bool StartRender(); - void Erase(base::WeakPtr weakMediaSession); - - void Prepare(content::MediaSessionImpl* mediaSession); + void Erase(content::MediaSessionImpl* mediaSession); OHOSAudioManager* manager_; @@ -120,7 +118,7 @@ class OHOSAudioOutputStream : public AudioOutputStream { std::unique_ptr audio_renderer_; - base::WeakPtr weakMediaSession_ = nullptr; + content::MediaSessionImpl* mediaSession_ = nullptr; std::shared_ptr rendererCallback_ = nullptr; diff --git a/mojo/public/cpp/bindings/lib/message.cc b/mojo/public/cpp/bindings/lib/message.cc index af0c6ee732..de137099f3 100644 --- a/mojo/public/cpp/bindings/lib/message.cc +++ b/mojo/public/cpp/bindings/lib/message.cc @@ -271,7 +271,7 @@ Message::Message(base::span payload, void* buffer; uint32_t buffer_size; - CHECK(base::IsValueInRangeForNumericType(payload.size())); + DCHECK(base::IsValueInRangeForNumericType(payload.size())); DCHECK(base::IsValueInRangeForNumericType(handles.size())); MojoAppendMessageDataOptions options; options.struct_size = sizeof(options); diff --git a/net/cert/cert_verify_proc_ohos.cc b/net/cert/cert_verify_proc_ohos.cc index a62a0cddbd..3f983c0b88 100644 --- a/net/cert/cert_verify_proc_ohos.cc +++ b/net/cert/cert_verify_proc_ohos.cc @@ -137,49 +137,17 @@ int GetVerifiedChain(X509_STORE_CTX* ctx, std::vector* verified_cha return X509_V_OK; } -int CertChainRootVerify(X509* server_cert[], - int32_t index, - X509_STORE* ca_store) { - if (!server_cert || !ca_store || index <= 0) { - return X509_V_ERR_UNSPECIFIED; - } - - STACK_OF(X509)* ca_stack = nullptr; - X509_STORE_CTX* ctx = nullptr; - ctx = X509_STORE_CTX_new(); - if (!ctx) { - return X509_V_ERR_UNSPECIFIED; - } - X509_STORE_CTX_init(ctx, ca_store, server_cert[index], ca_stack); - if (!X509_verify_cert(ctx)) { - auto error = ctx->error; - LOG(ERROR) << "Certificate verify error: " << error - << ", Certificate verify info: " - << X509_verify_cert_error_string(ctx->error); - X509_STORE_CTX_free(ctx); - return error; - } - X509_STORE_CTX_free(ctx); - return X509_V_OK; -} - int CertChainVerify(X509* server_cert[], int32_t server_cert_sum, X509_STORE* ca_store, std::vector* verified_chain) { - int32_t server_cert_index; + uint32_t i; STACK_OF(X509)* ca_stack = nullptr; X509_STORE_CTX* ctx = nullptr; // Add the server certificate to the certificate store - for (server_cert_index = server_cert_sum - 1; server_cert_index > 0; server_cert_index--) { - int ret = CertChainRootVerify(server_cert, server_cert_index, ca_store); - if (ret == X509_V_OK) { - for (int cert_index = server_cert_index; cert_index > 0; cert_index--) { - X509_STORE_add_cert(ca_store, server_cert[cert_index]); - } - break; - } + for (i = server_cert_sum - 1; i > 0; i--) { + X509_STORE_add_cert(ca_store, server_cert[i]); } // Create certificate store context function diff --git a/net/proxy_resolution/proxy_config_service_ohos.cc b/net/proxy_resolution/proxy_config_service_ohos.cc index 0449a48431..4380758551 100644 --- a/net/proxy_resolution/proxy_config_service_ohos.cc +++ b/net/proxy_resolution/proxy_config_service_ohos.cc @@ -155,24 +155,6 @@ void GetLatestProxyConfigInternal(const GetPropertyCallback& get_property, } } -std::string FixupProxyHostScheme(std::string host) { - // Strip the scheme if any. - std::string::size_type colon = host.find("://"); - if (colon != std::string::npos) - host = host.substr(colon + 3); - // If a username and perhaps password are specified, give a warning. - std::string::size_type at_sign = host.find("@"); - // Should this be supported? - if (at_sign != std::string::npos) { - // ProxyConfig does not support authentication parameters, but Chrome - // will prompt for the password later. Disregard the - // authentication parameters and continue with this hostname. - LOG(WARNING) << "Proxy authentication parameters ignored, see bug 16709"; - host = host.substr(at_sign + 1); - } - return host; -} - std::string GetProperty(const std::string& property) { // Use OH network to get configuration information. std::string host; @@ -183,7 +165,7 @@ std::string GetProperty(const std::string& property) { .GetNetProxyInstance().GetProperty(host, port, pac_url, exclusion); if (property == "http.proxyHost" || property == "https.proxyHost") { - return FixupProxyHostScheme(host); + return host; } else if (property == "http.proxyPort" || property == "https.proxyPort") { return std::to_string(port); } else if (property == "http.nonProxyHosts" || property == "https.nonProxyHosts") { diff --git a/net/socket/unix_domain_client_socket_posix.cc b/net/socket/unix_domain_client_socket_posix.cc index 8f6a5f558b..1474299ee2 100644 --- a/net/socket/unix_domain_client_socket_posix.cc +++ b/net/socket/unix_domain_client_socket_posix.cc @@ -47,12 +47,6 @@ bool UnixDomainClientSocket::FillAddress(const std::string& socket_path, // namespace pathname must start with '\0'. So, the size is always greater // than socket_path size by 1. size_t path_size = socket_path.size() + 1; - -#if BUILDFLAG(IS_OHOS) - LOG(INFO) << "Unix Domain Client Socket Fill Address: path_size = " - << path_size << " path_max = " << path_max; -#endif - if (path_size > path_max) return false; @@ -66,8 +60,7 @@ bool UnixDomainClientSocket::FillAddress(const std::string& socket_path, return true; } -#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) || \ - BUILDFLAG(IS_OHOS) +#if BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS) // Convert the path given into abstract socket name. It must start with // the '\0' character, so we are adding it. |addr_len| must specify the // length of the structure exactly, as potentially the socket name may diff --git a/ohos_nweb/BUILD.gn b/ohos_nweb/BUILD.gn index a3cb837e51..0cd0cb62c9 100755 --- a/ohos_nweb/BUILD.gn +++ b/ohos_nweb/BUILD.gn @@ -196,7 +196,6 @@ component("nweb_sources") { "include/nweb_value.h", "include/nweb_value_callback.h", "src/capi/nweb_app_client_extension_callback.h", - "src/capi/nweb_storage_extension_callback.h", "src/nweb_cookie_manager_delegate_interface.h", "src/nweb_cookie_manager_impl.cc", "src/nweb_cookie_manager_impl.h", diff --git a/ohos_nweb/include/nweb.h b/ohos_nweb/include/nweb.h index 938639213b..2cc1cc26bd 100755 --- a/ohos_nweb/include/nweb.h +++ b/ohos_nweb/include/nweb.h @@ -745,21 +745,6 @@ class OHOS_NWEB_EXPORT NWeb : public std::enable_shared_from_this { virtual void PrefetchPage( std::string& url, std::map additionalHttpHeaders) = 0; - - /** - * Set the window id. - */ - virtual void SetWindowId(uint32_t window_id) = 0; - - /** - * Notify that browser was occluded by other windows. - */ - virtual void OnOccluded() const = 0; - - /** - *Notify that browser was unoccluded by other windows. - */ - virtual void OnUnoccluded() const = 0; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/include/nweb_cookie_manager.h b/ohos_nweb/include/nweb_cookie_manager.h index 8e3aeef037..25b73c7db9 100644 --- a/ohos_nweb/include/nweb_cookie_manager.h +++ b/ohos_nweb/include/nweb_cookie_manager.h @@ -81,7 +81,7 @@ public: * @param url the URL for which the cookies are requested. * @return the cookie value for given URL. */ - virtual std::string ReturnCookie(const std::string &url, bool &is_valid) = 0; + virtual std::string ReturnCookie(const std::string &url) = 0; /** * @brief Sets a single cookie (key-value pair) for the given URL. * diff --git a/ohos_nweb/include/nweb_handler.h b/ohos_nweb/include/nweb_handler.h index cd301d1770..ca15804e1b 100755 --- a/ohos_nweb/include/nweb_handler.h +++ b/ohos_nweb/include/nweb_handler.h @@ -564,9 +564,9 @@ public: * @param firstContentfulPaintMs Time to first contentful paint from * navigation start. */ - virtual void OnFirstContentfulPaint(int64_t navigationStartTick, - int64_t firstContentfulPaintMs) {} - + virtual void OnFirstContentfulPaint(long navigationStartTick, + long firstContentfulPaintMs) {} + /** * @brief Called when swap buffer completed with new size. */ diff --git a/ohos_nweb/src/capi/nweb_app_client_extension_callback.h b/ohos_nweb/src/capi/nweb_app_client_extension_callback.h index 9900c1b7cd..35b01bd6fd 100644 --- a/ohos_nweb/src/capi/nweb_app_client_extension_callback.h +++ b/ohos_nweb/src/capi/nweb_app_client_extension_callback.h @@ -17,7 +17,6 @@ #define OHOS_NWEB_SRC_NWEB_APP_CLIENT_EXTENSION_CALLBACK_H_ #include -#include struct NWebAppClientExtensionCallback { size_t struct_size = sizeof(NWebAppClientExtensionCallback); @@ -29,16 +28,6 @@ struct NWebAppClientExtensionCallback { int alpha_type, int nweb_id); void (*OnLoadStarted)(bool toDifferentDocument, int nweb_id); - void (*OnHidePasswordAutofillPopup)(int nweb_id); - void (*OnSaveOrUpdatePassword)(bool isUpdate, std::string url, int nweb_id); - void (*OnShowPasswordAutofillPopup)(int left, - int top, - int width, - int height, - bool is_rtl, - std::vector labels, - std::vector sublabels, - int nweb_id); }; #endif // OHOS_NWEB_SRC_NWEB_APP_CLIENT_EXTENSION_CALLBACK_H_ diff --git a/ohos_nweb/src/capi/nweb_storage_extension_callback.h b/ohos_nweb/src/capi/nweb_storage_extension_callback.h deleted file mode 100644 index fe3ca84837..0000000000 --- a/ohos_nweb/src/capi/nweb_storage_extension_callback.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef OHOS_NWEB_SRC_NWEB_STORAGE_EXTENSION_CALLBACK_H_ -#define OHOS_NWEB_SRC_NWEB_STORAGE_EXTENSION_CALLBACK_H_ - -#include -#include - -struct NWebStorageExtensionCallback { - size_t struct_size = sizeof(NWebStorageExtensionCallback); - void (*OnGetPassword)(const char* result, int callback_id); - void (*OnGetSavedPasswords)(std::vector url, - std::vector username, - int callback_id); -}; - -#endif // OHOS_NWEB_SRC_NWEB_STORAGE_EXTENSION_CALLBACK_H_ diff --git a/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.cc index 32fe809b49..ca3e2b76ac 100644 --- a/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.cc @@ -106,9 +106,7 @@ class HasCookieVisitor : public CefCookieVisitor { } } - bool IsExistCookies() const { - return total_cookies_number == 0 ? false : true; - } + bool IsExistCookies() const { return total_cookies_number == 0 ? false : true; } private: std::shared_ptr event_; @@ -278,29 +276,30 @@ void NWebCookieManagerDelegate::ReturnCookie( LOG(ERROR) << "GetGlobalCookieManager failed"; return; } - CefRefPtr visitor = - new ReturnCookieVisitor(nullptr, callback); - if (!cookie_manager->VisitUrlCookies(CefString(url), false, visitor, false)) { + CefRefPtr visitor = new ReturnCookieVisitor(nullptr, callback); + if (!cookie_manager->VisitUrlCookies(CefString(url), false, visitor)) { LOG(ERROR) << "VisitUrlCookies failed"; return; } } -std::string NWebCookieManagerDelegate::ReturnCookie(const std::string& url, - bool& is_valid) { +std::string NWebCookieManagerDelegate::ReturnCookie( + const std::string& url) { CefRefPtr cookie_manager = GetGlobalCookieManager(); if (cookie_manager == nullptr) { LOG(ERROR) << "GetGlobalCookieManager failed"; return ""; } - CefRefPtr visitor = - new ReturnCookieVisitor(nullptr, nullptr); - is_valid = true; - if (!cookie_manager->VisitUrlCookies(CefString(url), false, visitor, true)) { + std::shared_ptr event = + std::make_shared( + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED); + CefRefPtr visitor = new ReturnCookieVisitor(event, nullptr); + if (!cookie_manager->VisitUrlCookies(CefString(url), false, visitor)) { LOG(ERROR) << "VisitUrlCookies failed"; - is_valid = false; return ""; } + event->TimedWait(base::Milliseconds(ENOUGH_WAITED_TIME)); return visitor->ReturnCookieLine(); } @@ -321,15 +320,15 @@ void NWebCookieManagerDelegate::SetCookie( } if (!cookie_manager->SetCookie(CefString(url), cef_cookie, - new CookieSetCallback(nullptr, callback), - false)) { + new CookieSetCallback(nullptr, callback))) { LOG(ERROR) << "SetCookie error"; return; } } -int NWebCookieManagerDelegate::SetCookie(const std::string& url, - const std::string& value) { +int NWebCookieManagerDelegate::SetCookie( + const std::string& url, + const std::string& value) { CefRefPtr cookie_manager = GetGlobalCookieManager(); if (cookie_manager == nullptr) { LOG(ERROR) << "GetGlobalCookieManager failed"; @@ -341,12 +340,16 @@ int NWebCookieManagerDelegate::SetCookie(const std::string& url, LOG(ERROR) << "CreateCefCookie failed"; return NWEB_INVALID_COOKIE_VALUE; } - CefRefPtr callback( - new CookieSetCallback(nullptr, nullptr)); - if (!cookie_manager->SetCookie(CefString(url), cef_cookie, callback, true)) { + std::shared_ptr completion = + std::make_shared( + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED); + CefRefPtr callback(new CookieSetCallback(completion, nullptr)); + if (!cookie_manager->SetCookie(CefString(url), cef_cookie, callback)) { LOG(ERROR) << "SetCookie error"; return NWEB_INVALID_URL; } + completion->TimedWait(base::Milliseconds(ENOUGH_WAITED_TIME)); return callback->IsSetSuccess() ? NWEB_OK : NWEB_ERR; } @@ -356,8 +359,8 @@ void NWebCookieManagerDelegate::ExistCookies( if (cookie_manager == nullptr) { return; } - CefRefPtr visitor = new HasCookieVisitor(nullptr, callback); - if (!cookie_manager->VisitAllCookies(visitor, false)) { + CefRefPtr visitor = new HasCookieVisitor(nullptr ,callback); + if (!cookie_manager->VisitAllCookies(visitor)) { LOG(INFO) << "VisitAllCookies failed"; return; } @@ -369,9 +372,13 @@ bool NWebCookieManagerDelegate::ExistCookies() { LOG(ERROR) << "GetGlobalCookieManager failed"; return false; } - CefRefPtr visitor = - new HasCookieVisitor(nullptr, nullptr); - cookie_manager->VisitAllCookies(visitor, true); + std::shared_ptr completion = + std::make_shared( + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED); + CefRefPtr visitor = new HasCookieVisitor(completion, nullptr); + cookie_manager->VisitAllCookies(visitor); + completion->TimedWait(base::Milliseconds(ENOUGH_WAITED_TIME)); return visitor->IsExistCookies(); } @@ -395,9 +402,9 @@ bool NWebCookieManagerDelegate::Store() { return false; } std::shared_ptr event = - std::make_shared( - base::WaitableEvent::ResetPolicy::AUTOMATIC, - base::WaitableEvent::InitialState::NOT_SIGNALED); + std::make_shared( + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED); CefRefPtr complete = new CookieCompletionCallback(event, nullptr); if (!cookie_manager->FlushStore(complete)) { @@ -418,7 +425,7 @@ void NWebCookieManagerDelegate::DeleteSessionCookies( new CookieDeleteCallback(callback); if (!cookie_manager->DeleteCookies(CefString(std::string()), CefString(std::string()), true, - delete_callback, true)) { + delete_callback)) { LOG(ERROR) << "DeleteCookieEntirely Failed"; } } @@ -429,12 +436,19 @@ void NWebCookieManagerDelegate::DeleteCookieEntirely( if (cookie_manager == nullptr) { return; } + std::shared_ptr event = (callback != nullptr) ? + nullptr : std::make_shared( + base::WaitableEvent::ResetPolicy::AUTOMATIC, + base::WaitableEvent::InitialState::NOT_SIGNALED); CefRefPtr delete_callback = - new CookieDeleteCallback(nullptr, nullptr); + new CookieDeleteCallback(event, callback); if (!cookie_manager->DeleteCookies(CefString(std::string()), CefString(std::string()), false, - delete_callback, true)) { + delete_callback)) { LOG(ERROR) << "DeleteCookieEntirely Failed"; } + if (event != nullptr) { + event->TimedWait(base::Milliseconds(ENOUGH_WAITED_TIME)); + } } } // namespace OHOS::NWeb \ No newline at end of file diff --git a/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.h b/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.h index 09a5c00880..f2faaf3de0 100644 --- a/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_cookie_manager_delegate.h @@ -37,7 +37,7 @@ class NWebCookieManagerDelegate : public NWebCookieManagerDelegateInterface { void ReturnCookie( const std::string& url, std::shared_ptr> callback) override; - std::string ReturnCookie(const std::string& url, bool& is_valid) override; + std::string ReturnCookie(const std::string& url) override; void SetCookie(const std::string& url, const std::string& value, std::shared_ptr> callback) override; diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_delegate.cc index 3f5914edc9..0fcd98c67e 100755 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.cc @@ -42,7 +42,7 @@ namespace OHOS::NWeb { void ConvertCefValueToNWebMessage(CefRefPtr src, std::shared_ptr dst) { int type = src->GetType(); - LOG(DEBUG) << "OnMessage type:" << type; + LOG(INFO) << "OnMessage type:" << type; switch (type) { case VTYPE_STRING: { dst->SetType(NWebValue::Type::STRING); @@ -151,7 +151,7 @@ class CefWebMessageReceiverImpl : public CefWebMessageReceiver { std::shared_ptr>> callback) : callback_(callback){}; void OnMessage(CefRefPtr message) override { - LOG(DEBUG) << "OnMessage in nweb delegate"; + LOG(INFO) << "OnMessage in nweb delegate"; if (callback_ != nullptr) { auto data = std::make_shared(NWebValue::Type::NONE); ConvertCefValueToNWebMessage(message, data); @@ -249,7 +249,7 @@ bool NWebDelegate::HasBackgroundColorWithInit(int32_t& backgroundColor) { if (!strncmp(argv_[i], "--init-background-color=", strlen("--init-background-color="))) { const char* value = argv_[i] + strlen("--init-background-color="); backgroundColor = atoi(value); - LOG(DEBUG) << "HasBackgroundColorWithInit, background color = " << backgroundColor; + LOG(INFO) << "HasBackgroundColorWithInit, background color = " << backgroundColor; return true; } } @@ -379,7 +379,7 @@ void NWebDelegate::StartDownload(const char* url) { void NWebDelegate::ResumeDownload( std::shared_ptr web_download) { - LOG(DEBUG) << "NWebDelegate::ResumeDownload"; + LOG(INFO) << "NWebDelegate::ResumeDownload"; auto browser = GetBrowser(); if (web_download == nullptr) { @@ -504,10 +504,6 @@ void NWebDelegate::OnTouchPress(int32_t id, double y, bool from_overlay) { if (event_handler_ != nullptr) { - auto browser = GetBrowser(); - if (browser != nullptr && browser->GetHost() != nullptr) { - browser->GetHost()->SetFocus(true); - } event_handler_->OnTouchPress(id, x / default_virtual_pixel_ratio_, y / default_virtual_pixel_ratio_, from_overlay); @@ -635,7 +631,7 @@ int NWebDelegate::Load(const std::string& url) { return NWEB_INVALID_URL; } } - LOG(DEBUG) << "NWebDelegate::Load url=" << url; + LOG(INFO) << "NWebDelegate::Load url=" << url; auto browser = GetBrowser(); if (browser == nullptr) { LOG(ERROR) << "NWebDelegate::Load browser is nullptr"; @@ -647,7 +643,7 @@ int NWebDelegate::Load(const std::string& url) { } bool NWebDelegate::IsNavigatebackwardAllowed() const { - LOG(DEBUG) << "NWebDelegate::IsNavigatebackwardAllowed"; + LOG(INFO) << "NWebDelegate::IsNavigatebackwardAllowed"; if (GetBrowser().get()) { return GetBrowser()->CanGoBack(); } @@ -655,7 +651,7 @@ bool NWebDelegate::IsNavigatebackwardAllowed() const { } bool NWebDelegate::IsNavigateForwardAllowed() const { - LOG(DEBUG) << "NWebDelegate::IsNavigateForwardAllowed"; + LOG(INFO) << "NWebDelegate::IsNavigateForwardAllowed"; if (GetBrowser().get()) { return GetBrowser()->CanGoForward(); } @@ -663,7 +659,7 @@ bool NWebDelegate::IsNavigateForwardAllowed() const { } bool NWebDelegate::CanNavigateBackOrForward(int num_steps) const { - LOG(DEBUG) << "NWebDelegate::CanNavigateBackOrForward"; + LOG(INFO) << "NWebDelegate::CanNavigateBackOrForward"; if (GetBrowser().get()) { return GetBrowser()->CanGoBackOrForward(num_steps); } @@ -671,35 +667,35 @@ bool NWebDelegate::CanNavigateBackOrForward(int num_steps) const { } void NWebDelegate::NavigateBack() const { - LOG(DEBUG) << "NWebDelegate::NavigateBack"; + LOG(INFO) << "NWebDelegate::NavigateBack"; if (GetBrowser().get()) { GetBrowser()->GoBack(); } } void NWebDelegate::NavigateForward() const { - LOG(DEBUG) << "NWebDelegate::NavigateForward"; + LOG(INFO) << "NWebDelegate::NavigateForward"; if (GetBrowser().get()) { GetBrowser()->GoForward(); } } void NWebDelegate::NavigateBackOrForward(int step) const { - LOG(DEBUG) << "NWebDelegate::NavigateBackOrForward"; + LOG(INFO) << "NWebDelegate::NavigateBackOrForward"; if (GetBrowser().get()) { GetBrowser()->GoBackOrForward(step); } } void NWebDelegate::DeleteNavigateHistory() { - LOG(DEBUG) << "NWebDelegate::DeleteNavigateHistory"; + LOG(INFO) << "NWebDelegate::DeleteNavigateHistory"; if (GetBrowser().get()) { GetBrowser()->DeleteHistory(); } } void NWebDelegate::ClearSslCache() { - LOG(DEBUG) << "NWebDelegate::ClearSslCache"; + LOG(INFO) << "NWebDelegate::ClearSslCache"; CefRefPtr context = CefRequestContext::GetGlobalContext(); if (context != nullptr) { context->ClearCertificateExceptions(nullptr); @@ -707,7 +703,7 @@ void NWebDelegate::ClearSslCache() { } void NWebDelegate::ClearClientAuthenticationCache() { - LOG(DEBUG) << "NWebDelegate::ClearClientAuthenticationCache"; + LOG(INFO) << "NWebDelegate::ClearClientAuthenticationCache"; CefRefPtr context = CefRequestContext::GetGlobalContext(); if (context != nullptr) { context->ClearClientAuthenticationCache(nullptr); @@ -715,28 +711,21 @@ void NWebDelegate::ClearClientAuthenticationCache() { } void NWebDelegate::Reload() const { - LOG(DEBUG) << "NWebDelegate::Reload"; + LOG(INFO) << "NWebDelegate::Reload"; if (GetBrowser().get()) { GetBrowser()->Reload(); } } void NWebDelegate::ReloadOriginalUrl() const { - LOG(DEBUG) << "NWebDelegate::ReloadOriginalUrl"; + LOG(INFO) << "NWebDelegate::ReloadOriginalUrl"; if (GetBrowser().get()) { GetBrowser()->ReloadOriginalUrl(); } } -void NWebDelegate::PasswordSuggestionSelected(int list_index) const { - LOG(DEBUG) << "NWebDelegate::PasswordSuggestionSelected"; - if (GetBrowser().get()) { - GetBrowser()->PasswordSuggestionSelected(list_index); - } -} - const std::string NWebDelegate::GetOriginalUrl() { - LOG(DEBUG) << "NWebDelegate::GetOriginalUrl"; + LOG(INFO) << "NWebDelegate::GetOriginalUrl"; if (GetBrowser().get()) { return GetBrowser()->GetHost()->GetOriginalUrl(); } @@ -748,7 +737,7 @@ bool NWebDelegate::GetFavicon(const void** data, size_t& height, ImageColorType& colorType, ImageAlphaType& alphaType) { - LOG(DEBUG) << "NWebDelegate::getFavicon"; + LOG(INFO) << "NWebDelegate::getFavicon"; if (handler_delegate_) { return handler_delegate_->GetFavicon(data, width, height, colorType, alphaType); @@ -759,14 +748,14 @@ bool NWebDelegate::GetFavicon(const void** data, } void NWebDelegate::PutNetworkAvailable(bool avaiable) { - LOG(DEBUG) << "NWebDelegate::PutNetworkAvailable"; + LOG(INFO) << "NWebDelegate::PutNetworkAvailable"; if (GetBrowser().get()) { GetBrowser()->GetHost()->PutNetworkAvailable(avaiable); } } void NWebDelegate::SetBrowserUserAgentString(const std::string& user_agent) { - LOG(DEBUG) << "NWebDelegate::SetBrowserUserAgentString"; + LOG(INFO) << "NWebDelegate::SetBrowserUserAgentString"; if (GetBrowser().get()) { GetBrowser()->SetBrowserUserAgentString(user_agent); } @@ -785,7 +774,7 @@ void NWebDelegate::StoreWebArchive( } int NWebDelegate::Zoom(float zoomFactor) const { - LOG(DEBUG) << "NWebDelegate::Zoom"; + LOG(INFO) << "NWebDelegate::Zoom"; if (!preference_delegate_) { LOG(ERROR) << "preference_delegate_ get fail"; return NWEB_ERR; @@ -804,7 +793,7 @@ int NWebDelegate::Zoom(float zoomFactor) const { } int NWebDelegate::ZoomIn() const { - LOG(DEBUG) << "NWebDelegate::ZoomIn"; + LOG(INFO) << "NWebDelegate::ZoomIn"; if (!preference_delegate_) { return NWEB_ERR; } @@ -822,7 +811,7 @@ int NWebDelegate::ZoomIn() const { } int NWebDelegate::ZoomOut() const { - LOG(DEBUG) << "NWebDelegate::ZoomOut"; + LOG(INFO) << "NWebDelegate::ZoomOut"; if (!preference_delegate_) { return NWEB_ERR; } @@ -840,7 +829,7 @@ int NWebDelegate::ZoomOut() const { } bool NWebDelegate::SetZoomInFactor(float factor) { - LOG(DEBUG) << "NWebDelegate::SetZoomInFactor"; + LOG(INFO) << "NWebDelegate::SetZoomInFactor"; if (factor <= 0) { return false; } @@ -849,7 +838,7 @@ bool NWebDelegate::SetZoomInFactor(float factor) { } bool NWebDelegate::SetZoomOutFactor(float factor) { - LOG(DEBUG) << "NWebDelegate::SetZoomOutFactor"; + LOG(INFO) << "NWebDelegate::SetZoomOutFactor"; if (factor >= 0) { return false; } @@ -858,14 +847,14 @@ bool NWebDelegate::SetZoomOutFactor(float factor) { } void NWebDelegate::Stop() const { - LOG(DEBUG) << "NWebDelegate::Stop"; + LOG(INFO) << "NWebDelegate::Stop"; if (GetBrowser().get()) { GetBrowser()->StopLoad(); } } void NWebDelegate::ExecuteJavaScript(const std::string& code) const { - LOG(DEBUG) << "NWebDelegate::ExecuteJavaScript"; + LOG(INFO) << "NWebDelegate::ExecuteJavaScript"; if (GetBrowser().get()) { GetBrowser()->GetMainFrame()->ExecuteJavaScript( code, GetBrowser()->GetMainFrame()->GetURL(), 0); @@ -876,7 +865,7 @@ void NWebDelegate::ExecuteJavaScript( const std::string& code, std::shared_ptr>> callback, bool extention) const { - LOG(DEBUG) << "NWebDelegate::ExecuteJavaScript with callback"; + LOG(INFO) << "NWebDelegate::ExecuteJavaScript with callback"; if (GetBrowser().get()) { CefRefPtr JsResultCb = @@ -886,7 +875,7 @@ void NWebDelegate::ExecuteJavaScript( } void NWebDelegate::PutBackgroundColor(int color) const { - LOG(DEBUG) << "NWebDelegate::PutBackgroundColor color: " << (uint32_t)color; + LOG(INFO) << "NWebDelegate::PutBackgroundColor color: " << (uint32_t)color; if (GetBrowser().get()) { GetBrowser()->GetHost()->SetBackgroundColor(color); } @@ -896,7 +885,7 @@ void NWebDelegate::PutBackgroundColor(int color) const { } void NWebDelegate::InitialScale(float scale) const { - LOG(DEBUG) << "NWebDelegate::InitialScale"; + LOG(INFO) << "NWebDelegate::InitialScale"; if (scale == intial_scale_ || !render_handler_) { return; } @@ -907,23 +896,19 @@ void NWebDelegate::InitialScale(float scale) const { } void NWebDelegate::OnPause() { - LOG(DEBUG) << "NWebDelegate::OnPause"; + LOG(INFO) << "NWebDelegate::OnPause"; if (!GetBrowser().get()) { return; } // Remove focus from the browser. GetBrowser()->GetHost()->SetFocus(false); - if (handler_delegate_) { - handler_delegate_->SetFocusState(false); - } if (focus_nweb_id_.find(nweb_id_) != focus_nweb_id_.end()) { focus_nweb_id_.erase(nweb_id_); } if (!hidden_) { // Set the browser as hidden. - LOG(DEBUG) << "NWebDelegate::OnPause set hidden"; GetBrowser()->GetHost()->WasHidden(true); hidden_ = true; } @@ -931,21 +916,13 @@ void NWebDelegate::OnPause() { } void NWebDelegate::OnContinue() { - LOG(DEBUG) << "NWebDelegate::OnContinue"; + LOG(INFO) << "NWebDelegate::OnContinue"; if (!GetBrowser().get()) { return; } - if (occluded_) { - LOG(DEBUG) << "NWebDelegate::OnContinue set occluded"; - hidden_ = false; - GetBrowser()->GetHost()->WasOccluded(true); - return; - } - if (hidden_) { // Set the browser as visible. - LOG(DEBUG) << "NWebDelegate::OnContinue set unhidden"; GetBrowser()->GetHost()->WasHidden(false); hidden_ = false; } @@ -961,34 +938,6 @@ void NWebDelegate::OnContinue() { is_onPause_ = false; } -void NWebDelegate::OnOccluded() { - LOG(DEBUG) << "NWebDelegate::OnOccluded"; - if (!GetBrowser().get()) { - return; - } - - if (!hidden_ && !occluded_) { - // Set the browser as occluded. - LOG(DEBUG) << "NWebDelegate::OnOccluded set occluded"; - GetBrowser()->GetHost()->WasOccluded(true); - } - occluded_ = true; -} - -void NWebDelegate::OnUnoccluded() { - LOG(DEBUG) << "NWebDelegate::OnUnoccluded"; - if (!GetBrowser().get()) { - return; - } - - if (!hidden_ && occluded_) { - // Set the browser as visible. - LOG(DEBUG) << "NWebDelegate::OnUnoccluded set unoccluded"; - GetBrowser()->GetHost()->WasOccluded(false); - } - occluded_ = false; -} - void NWebDelegate::OnContextInitializeComplete(const std::string& url, void* window) { // Create browser after context initialzed complete. @@ -1196,7 +1145,7 @@ void NWebDelegate::PostPortMessage(std::string& portHandle, std::shared_ptr message = CefValue::Create(); ConvertNWebMsgToCefValue(data, message); @@ -1216,7 +1165,7 @@ void NWebDelegate::SetPortMessageCallback(std::string& portHandle, } std::string NWebDelegate::GetUrl() const { - LOG(DEBUG) << "NWebDelegate::get url"; + LOG(INFO) << "NWebDelegate::get url"; if (GetBrowser().get()) { auto entry = GetBrowser()->GetHost()->GetVisibleNavigationEntry(); if (entry) { @@ -1290,7 +1239,7 @@ int NWebDelegate::LoadWithDataAndBaseUrl(const std::string& baseUrl, const std::string& mimeType, const std::string& encoding, const std::string& historyUrl) { - LOG(DEBUG) << "NWebDelegate::LoadWithDataAndBaseUrl"; + LOG(INFO) << "NWebDelegate::LoadWithDataAndBaseUrl"; if (!GetBrowser().get()) { return NWEB_ERR; } @@ -1303,7 +1252,7 @@ int NWebDelegate::LoadWithDataAndBaseUrl(const std::string& baseUrl, int NWebDelegate::LoadWithData(const std::string& data, const std::string& mimeType, const std::string& encoding) { - LOG(DEBUG) << "NWebDelegate::LoadWithData"; + LOG(INFO) << "NWebDelegate::LoadWithData"; if (!GetBrowser().get()) { return NWEB_ERR; } @@ -1350,7 +1299,7 @@ int NWebDelegate::ContentHeight() { void NWebDelegate::RegisterArkJSfunction( const std::string& object_name, const std::vector& method_list) const { - LOG(DEBUG) << "RegisterArkJSfunction name : " << object_name.c_str(); + LOG(INFO) << "RegisterArkJSfunction name : " << object_name.c_str(); std::vector method_vector; for (std::string method : method_list) { method_vector.push_back(method); @@ -1361,7 +1310,7 @@ void NWebDelegate::RegisterArkJSfunction( void NWebDelegate::UnregisterArkJSfunction( const std::string& object_name, const std::vector& method_list) const { - LOG(DEBUG) << "UnregisterArkJSfunction name : " << object_name.c_str(); + LOG(INFO) << "UnregisterArkJSfunction name : " << object_name.c_str(); std::vector method_vector; for (std::string method : method_list) { method_vector.push_back(method); @@ -1389,10 +1338,8 @@ bool NWebDelegate::OnFocus(const FocusReason& focusReason) const { "capture when loading this web page."; return false; } - if (handler_delegate_ && !handler_delegate_->GetFocusState()) { - GetBrowser()->GetHost()->SetFocus(true); - focus_nweb_id_.insert(nweb_id_); - } + GetBrowser()->GetHost()->SetFocus(true); + focus_nweb_id_.insert(nweb_id_); return true; } @@ -1402,7 +1349,7 @@ void NWebDelegate::OnBlur() const { return; } - if (handler_delegate_ && handler_delegate_->GetFocusState()) { + if (handler_delegate_) { handler_delegate_->SetFocusState(false); GetBrowser()->GetHost()->SetFocus(false); if (focus_nweb_id_.find(nweb_id_) != focus_nweb_id_.end()) { @@ -1454,7 +1401,6 @@ void NWebDelegate::ClearDragData() const { if (!render_handler_) { return; } - render_handler_->FreePixlMapData(); auto drag_data = render_handler_->GetDragData(); if (drag_data) { drag_data->SetFragmentText(""); @@ -1476,13 +1422,13 @@ void NWebDelegate::SendDragEvent(const DelegateDragEvent& dragEvent) const { event.modifiers = EVENTFLAG_LEFT_MOUSE_BUTTON; switch (dragEvent.action) { case DelegateDragAction::DRAG_START: - LOG(DEBUG) << "DragDrop event SendDragEvent start"; + LOG(INFO) << "DragDrop event SendDragEvent start"; break; case DelegateDragAction::DRAG_ENTER: if (render_handler_) { - LOG(DEBUG) << "DragDrop event DRAG_ENTER SendDragEvent enter, send dragdata to chromium"; + LOG(INFO) << "DragDrop event DRAG_ENTER SendDragEvent enter, send dragdata to chromium"; ClearDragData(); - auto drag_data = render_handler_->GetDragData(); + auto drag_data = render_handler_->GetDragData(); GetBrowser()->GetHost()->DragTargetDragEnter( drag_data, event, DRAG_OPERATION_EVERY); } else { @@ -1490,7 +1436,7 @@ void NWebDelegate::SendDragEvent(const DelegateDragEvent& dragEvent) const { } break; case DelegateDragAction::DRAG_LEAVE: - LOG(DEBUG) << "DragDrop event SendDragEvent leave"; + LOG(INFO) << "DragDrop event SendDragEvent leave"; GetBrowser()->GetHost()->DragTargetDragLeave(); break; case DelegateDragAction::DRAG_OVER: @@ -1498,15 +1444,15 @@ void NWebDelegate::SendDragEvent(const DelegateDragEvent& dragEvent) const { break; case DelegateDragAction::DRAG_DROP: event.modifiers = EVENTFLAG_NONE; - LOG(DEBUG) << "DragDrop event SendDragEvent drop"; + LOG(INFO) << "DragDrop event SendDragEvent drop"; if (render_handler_) { auto drag_data1 = render_handler_->GetDragData(); auto fragment1 = drag_data1->GetFragmentText(); - LOG(DEBUG) << "DragDrop drag data GetFragmentText:" << fragment1.ToString(); + LOG(INFO) << "DragDrop drag data GetFragmentText:" << fragment1.ToString(); auto link_url1 = drag_data1->GetLinkURL(); - LOG(DEBUG) << "DragDrop drag data GetLinkURL:" << link_url1.ToString(); + LOG(INFO) << "DragDrop drag data GetLinkURL:" << link_url1.ToString(); auto link_html1 = drag_data1->GetFragmentHtml(); - LOG(DEBUG) << "DragDrop drag data GetFragmentHtml:" << link_html1.ToString(); + LOG(INFO) << "DragDrop drag data GetFragmentHtml:" << link_html1.ToString(); } else { LOG(ERROR) << "DragDrop drag data render_handler_ nullptr"; } @@ -1515,18 +1461,18 @@ void NWebDelegate::SendDragEvent(const DelegateDragEvent& dragEvent) const { break; case DelegateDragAction::DRAG_END: ClearDragData(); - LOG(DEBUG) << "DragDrop event SendDragEvent end"; + LOG(INFO) << "DragDrop event SendDragEvent end"; GetBrowser()->GetHost()->DragSourceEndedAt(event.x, event.y, DRAG_OPERATION_COPY); GetBrowser()->GetHost()->DragSourceSystemDragEnded(); break; case DelegateDragAction::DRAG_CANCEL: ClearDragData(); - LOG(DEBUG) << "DragDrop event SendDragEvent cancel"; + LOG(INFO) << "DragDrop event SendDragEvent cancel"; GetBrowser()->GetHost()->DragSourceSystemDragEnded(); break; default: - LOG(DEBUG) << "invalid drag action"; + LOG(INFO) << "invalid drag action"; break; } } @@ -1678,7 +1624,7 @@ bool NWebDelegate::GetCertChainDerDataInner(CefRefPtr cert, cert->GetDEREncodedIssuerChain(der_chain_list); der_chain_list.insert(der_chain_list.begin(), cert->GetDEREncoded()); - LOG(DEBUG) << "GetCertChainDerData der_chain_list size = " << der_chain_list.size(); + LOG(INFO) << "GetCertChainDerData der_chain_list size = " << der_chain_list.size(); for (size_t i = 0U; i < der_chain_list.size(); ++i) { if (!der_chain_list[i].get()) { LOG(ERROR) << "GetCertChainDerDataInner failed, der chain data is null, index = " << i; @@ -1691,13 +1637,13 @@ bool NWebDelegate::GetCertChainDerDataInner(CefRefPtr cert, der_chain_list[i]->GetData(const_cast(cert_data_item.data()), cert_data_size, 0); certChainData.emplace_back(cert_data_item); if (isSingleCert) { - LOG(DEBUG) << "get only one certificate of the current website"; + LOG(INFO) << "get only one certificate of the current website"; break; } } if (certChainData.size() == 0) { - LOG(DEBUG) << "GetCertChainDerData, no certificate data"; + LOG(INFO) << "GetCertChainDerData, no certificate data"; return false; } @@ -1719,19 +1665,6 @@ void NWebDelegate::NotifyPopupWindowResult(bool result) { } } -void NWebDelegate::SetWindowId(uint32_t window_id) { - if (handler_delegate_) { - handler_delegate_->SetWindowId(window_id); - } - - if (GetBrowser() == nullptr || GetBrowser()->GetHost() == nullptr) { - LOG(ERROR) << "SetWindowId can not get browser"; - return; - } - - GetBrowser()->GetHost()->SetWindowId(window_id, nweb_id_); -} - void NWebDelegate::PrefetchPage( std::string& url, std::map additionalHttpHeaders) { @@ -1752,7 +1685,7 @@ void NWebDelegate::PrefetchPage( #if defined (OHOS_NWEB_EX) void NWebDelegate::SetForceEnableZoom(bool forceEnableZoom) { - LOG(DEBUG) << "NWebDelegate::SetForceEnableZoom " << forceEnableZoom; + LOG(INFO) << "NWebDelegate::SetForceEnableZoom " << forceEnableZoom; if (GetBrowser().get()) { GetBrowser()->SetForceEnableZoom(forceEnableZoom); } @@ -1771,39 +1704,6 @@ void NWebDelegate::SelectAndCopy() { } } -void NWebDelegate::SaveOrUpdatePassword(bool is_update) { - if (GetBrowser().get()) { - GetBrowser()->SaveOrUpdatePassword(is_update); - } -} -void NWebDelegate::SetSavePasswordAutomatically(bool enable) { - LOG(DEBUG) << "NWebDelegate::SetSavePasswordAutomatically " << enable; - if (GetBrowser().get()) { - GetBrowser()->SetSavePasswordAutomatically(enable); - } -} - -bool NWebDelegate::GetSavePasswordAutomatically() { - if (GetBrowser().get()) { - return GetBrowser()->GetSavePasswordAutomatically(); - } - return false; -} - -void NWebDelegate::SetSavePassword(bool enable) { - LOG(DEBUG) << "NWebDelegate::SetSavePassword " << enable; - if (GetBrowser().get()) { - GetBrowser()->SetSavePassword(enable); - } -} - -bool NWebDelegate::GetSavePassword() { - if (GetBrowser().get()) { - return GetBrowser()->GetSavePassword(); - } - return false; -} - bool NWebDelegate::ShouldShowFreeCopy() { if (GetBrowser().get()) { return GetBrowser()->ShouldShowFreeCopy(); @@ -1813,7 +1713,7 @@ bool NWebDelegate::ShouldShowFreeCopy() { void NWebDelegate::SetEnableBlankTargetPopupIntercept( bool enableBlankTargetPopup) { - LOG(DEBUG) << "NWebDelegate::SetEnableBlankTargetPopupIntercept " + LOG(INFO) << "NWebDelegate::SetEnableBlankTargetPopupIntercept " << enableBlankTargetPopup; if (GetBrowser().get()) { GetBrowser()->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); @@ -1823,7 +1723,7 @@ void NWebDelegate::SetEnableBlankTargetPopupIntercept( // only. Set enableBlankTargetPopup in NWebPreferenceDelegate first, and // then set it in NWebHandlerDelegate::OnAfterCreated when browser is // created. - LOG(DEBUG) << "NWebDelegate::SetEnableBlankTargetPopupIntercept to " + LOG(INFO) << "NWebDelegate::SetEnableBlankTargetPopupIntercept to " "preference_delegate_ "<< enableBlankTargetPopup; preference_delegate_->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); } diff --git a/ohos_nweb/src/cef_delegate/nweb_delegate.h b/ohos_nweb/src/cef_delegate/nweb_delegate.h index f94a2ac66c..2330775b21 100755 --- a/ohos_nweb/src/cef_delegate/nweb_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_delegate.h @@ -101,7 +101,6 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void ClearClientAuthenticationCache() override; void Reload() const override; void ReloadOriginalUrl() const override; - void PasswordSuggestionSelected(int list_index) const override; int Zoom(float zoomFactor) const override; int ZoomIn() const override; int ZoomOut() const override; @@ -115,8 +114,6 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { void InitialScale(float scale) const override; void OnPause() override; void OnContinue() override; - void OnOccluded() override; - void OnUnoccluded() override; std::shared_ptr GetPreference() const override; std::string Title() override; void CreateWebMessagePorts(std::vector& ports) override; @@ -208,20 +205,12 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { #if defined (OHOS_NWEB_EX) void SetForceEnableZoom(bool forceEnableZoom) override; bool GetForceEnableZoom() override; - - void SetSavePasswordAutomatically(bool enable) override; - bool GetSavePasswordAutomatically() override; - void SetSavePassword(bool enable) override; - bool GetSavePassword() override; - void SaveOrUpdatePassword(bool is_udpate) override; - void SelectAndCopy() override; bool ShouldShowFreeCopy() override; void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) override; #endif void NotifyPopupWindowResult(bool result) override; - void SetWindowId(uint32_t window_id) override; public: int argc_; @@ -261,7 +250,6 @@ class NWebDelegate : public NWebDelegateInterface, public virtual CefRefCount { nullptr; // Members only accessed on the main thread. bool hidden_ = false; - bool occluded_ = false; uint32_t width_ = 0; uint32_t height_ = 0; #if defined(REPORT_SYS_EVENT) diff --git a/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.cc b/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.cc index 4518ef44da..b73d44d161 100755 --- a/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.cc +++ b/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.cc @@ -45,11 +45,6 @@ namespace { constexpr int SHADOW_COLOR = 0x33000000; constexpr int SHADOW_DX = 0; constexpr int SHADOW_DY = 4; - constexpr int WEIRD_PADDING = 30; - constexpr int IAMGE_SHADOW_RADIUS = 6; - constexpr int IMAGE_EXPAND_PADDING = 11; - constexpr int IMAGE_SHADOW_COLOR = 0xA0000000; - constexpr int IMAGE_SHADOW_DY = 3; } namespace OHOS::NWeb { @@ -167,16 +162,16 @@ SkPath NWebDragDataImpl::GetShadowPath(int width, int height) { bool is_oneline = ((start_edge_top_.y == end_edge_top_.y) && (start_edge_bottom_.y == end_edge_bottom_.y)); bool is_both_out_clip_region = (start_edge_top_.y < 0) && - (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) > ToOhCoordinate(WEIRD_PADDING)); - bool is_start_line_compelete = (start_edge_top_.y >= 0) && - (std::abs(start_edge_top_.x - drag_image_origin_point_.x) < ToOhCoordinate(DEFAULT_MARGIN + ADD_BOUND_RECT_RATIO)); + (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) < ToOhCoordinate(DEFAULT_MARGIN)); + bool is_start_line_compelete = (std::abs(start_edge_top_.y - drag_image_origin_point_.y) < ToOhCoordinate(DEFAULT_MARGIN)) && + (std::abs(start_edge_top_.x - drag_image_origin_point_.x) < ToOhCoordinate(DEFAULT_MARGIN)); is_start_line_compelete = is_start_line_compelete || (start_edge_top_.y < 0); - bool is_end_line_compelete = (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) <= ToOhCoordinate(WEIRD_PADDING)) && - (std::abs(drag_image_origin_point_.x + drag_clip_width_ - end_edge_bottom_.x) < ToOhCoordinate(DEFAULT_MARGIN + ADD_BOUND_RECT_RATIO)); + bool is_end_line_compelete = (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) < ToOhCoordinate(DEFAULT_MARGIN)) && + (std::abs(drag_image_origin_point_.x + drag_clip_width_ - end_edge_bottom_.x) < ToOhCoordinate(DEFAULT_MARGIN)); is_end_line_compelete = is_end_line_compelete || (std::abs(end_edge_bottom_.x - drag_image_origin_point_.x) < ToOhCoordinate(DEFAULT_MARGIN)); is_end_line_compelete = is_end_line_compelete || - (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) > ToOhCoordinate(WEIRD_PADDING)); + (std::abs(end_edge_bottom_.y - (drag_image_origin_point_.y + drag_clip_height_)) >= ToOhCoordinate(DEFAULT_MARGIN)); LOG(INFO) << "is one line = " << is_oneline << ", is_both_out_clip_region = " \ << is_both_out_clip_region << ", is_start_line_compelete = " \ << is_start_line_compelete << ", is_end_line_compelete = " << is_end_line_compelete; @@ -232,43 +227,39 @@ void NWebDragDataImpl::GenerateOhosDragBitmapFromOriginForImage(const SkBitmap& SkPath shadow_path; SkRect out_rect = SkRect::MakeXYWH(0, 0, width, height); - width += ToOhCoordinate(IMAGE_EXPAND_PADDING) * DOUBLE_RATIO; - height += ToOhCoordinate(IMAGE_EXPAND_PADDING) * DOUBLE_RATIO; + width += ToOhCoordinate(EXPAND_PADDING) * DOUBLE_RATIO; + height += ToOhCoordinate(EXPAND_PADDING) * DOUBLE_RATIO; shadow_path.addRoundRect(out_rect, ToOhCoordinate(IMAGE_ROUND_RECT_RATIO), ToOhCoordinate(IMAGE_ROUND_RECT_RATIO)); auto imageInfo = SkImageInfo::Make(width, height, SkColorType::kBGRA_8888_SkColorType , SkAlphaType::kUnpremul_SkAlphaType); out_bitmap.allocPixels(imageInfo); SkCanvas bitmapCanvas(out_bitmap); bitmapCanvas.clear(SK_ColorTRANSPARENT); - SkBitmap clip_image_bitmap; - SkPath clip_image_path; - SkRect image_rect = SkRect::MakeXYWH(0, 0, drag_clip_width_, drag_clip_height_); - clip_image_path.addRoundRect(image_rect, ToOhCoordinate(IMAGE_ROUND_RECT_RATIO), ToOhCoordinate(IMAGE_ROUND_RECT_RATIO)); - auto clip_image_info = SkImageInfo::Make(drag_clip_width_, drag_clip_height_, SkColorType::kBGRA_8888_SkColorType , SkAlphaType::kUnpremul_SkAlphaType); - clip_image_bitmap.allocPixels(clip_image_info); - SkCanvas clip_image_canvas(clip_image_bitmap); - clip_image_canvas.clear(SK_ColorTRANSPARENT); - - SkPaint clip_image_paint; - clip_image_paint.setAntiAlias(true); - clip_image_paint.setColor(DEFAULT_COLOR_BG); - clip_image_paint.setBlendMode(SkBlendMode::kSrcOver); - clip_image_paint.setStyle(SkPaint::kFill_Style); - clip_image_canvas.drawPath(clip_image_path, clip_image_paint); - - SkPaint clip_bitmap_paint; - clip_bitmap_paint.setAntiAlias(true); - clip_bitmap_paint.setBlendMode(SkBlendMode::kSrcIn); - clip_image_canvas.drawImage(in_bitmap.asImage(), 0, 0, SkSamplingOptions(), &clip_bitmap_paint); - clip_image_canvas.readPixels(clip_image_bitmap, 0, 0); + + shadow_path.offset(ToOhCoordinate(EXPAND_PADDING - SHADOW_DX), ToOhCoordinate(EXPAND_PADDING - SHADOW_DY)); + SkPaint out_paint; + out_paint.setAntiAlias(true); + out_paint.setColor(DEFAULT_COLOR_BG); + out_paint.setBlendMode(SkBlendMode::kSrcOver); + out_paint.setStyle(SkPaint::kFill_Style); + bitmapCanvas.drawPath(shadow_path, out_paint); SkPaint bitmap_paint; bitmap_paint.setAntiAlias(true); - auto shadow = SkImageFilters::DropShadow(ToOhCoordinate(SHADOW_DX), ToOhCoordinate(IMAGE_SHADOW_DY), - ToOhCoordinate(IAMGE_SHADOW_RADIUS), ToOhCoordinate(IAMGE_SHADOW_RADIUS), IMAGE_SHADOW_COLOR, nullptr); - bitmap_paint.setImageFilter(shadow); - bitmapCanvas.drawImage(clip_image_bitmap.asImage(), ToOhCoordinate(IMAGE_EXPAND_PADDING - SHADOW_DX), - ToOhCoordinate(IMAGE_EXPAND_PADDING - IMAGE_SHADOW_DY), SkSamplingOptions(), &bitmap_paint); + bitmap_paint.setBlendMode(SkBlendMode::kSrcIn); + bitmapCanvas.drawImage(in_bitmap.asImage(), ToOhCoordinate(EXPAND_PADDING - SHADOW_DX), + ToOhCoordinate(EXPAND_PADDING - SHADOW_DY), SkSamplingOptions(), &bitmap_paint); + + // draw shadow path + SkPaint shadow_layer_paint; + shadow_layer_paint.setAntiAlias(true); + shadow_layer_paint.setStyle(SkPaint::kFill_Style); + shadow_layer_paint.setColor(DEFAULT_COLOR_BG); + shadow_layer_paint.setBlendMode(SkBlendMode::kSrcOver); + auto shadow = SkImageFilters::DropShadowOnly(ToOhCoordinate(SHADOW_DX), ToOhCoordinate(SHADOW_DY), + ToOhCoordinate(SHADOW_RADIUS), ToOhCoordinate(SHADOW_RADIUS), SHADOW_COLOR, nullptr); + shadow_layer_paint.setImageFilter(shadow); + bitmapCanvas.drawPath(shadow_path, shadow_layer_paint); bitmapCanvas.readPixels(out_bitmap, 0, 0); } @@ -443,25 +434,12 @@ bool NWebDragDataImpl::GetPixelMapSetting(const void** data, size_t& len, int& w } len = read_size; *data = buffer; - if (image_buffer_) { - free(image_buffer_); - image_buffer_ = nullptr; - } - image_buffer_ = buffer; LOG(INFO) << "drag image width : " << width << ", height : " << height << ", buffer size : " << read_size; return true; } -void NWebDragDataImpl::FreePixlMapData() -{ - if (image_buffer_) { - free(image_buffer_); - image_buffer_ = nullptr; - } -} - bool NWebDragDataImpl::SetLinkURL(std::string& url) { if (!drag_data_) { diff --git a/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.h b/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.h index ac262760d4..b8d1ca8e50 100755 --- a/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.h +++ b/ohos_nweb/src/cef_delegate/nweb_drag_data_impl.h @@ -72,10 +72,7 @@ class NWebDragDataImpl : public NWebDragData { return drag_data_; } - void FreePixlMapData(); - private: - void* image_buffer_ = nullptr; void GenerateOhosDragBitmapFromOrigin(const SkBitmap& in_bitmap, SkBitmap& out_bitmap, int& width, int& height); void GenerateOhosDragBitmapFromOriginForRichtext(const SkBitmap& in_bitmap, SkBitmap& out_bitmap, int& width, int& height); diff --git a/ohos_nweb/src/cef_delegate/nweb_event_handler.cc b/ohos_nweb/src/cef_delegate/nweb_event_handler.cc index 7203ef992b..d2dd918944 100644 --- a/ohos_nweb/src/cef_delegate/nweb_event_handler.cc +++ b/ohos_nweb/src/cef_delegate/nweb_event_handler.cc @@ -23,7 +23,6 @@ #include "cef/include/internal/cef_types_wrappers.h" #include "base/trace_event/common/trace_event_common.h" -#include "res_sched_client_adapter.h" #include "ui/events/keycodes/keyboard_code_conversion_x.h" #include "ui/events/keycodes/keysym_to_unicode.h" @@ -70,9 +69,7 @@ void NWebEventHandler::OnTouchPress(int32_t id, bool from_overlay) { TRACE_EVENT0("input", "NWebEventHandler::OnTouchPress sliding response begin"); - LOG(DEBUG) << "NWebEventHandler::OnTouchPress sliding response begin. id = " - << id << ", x = " << x << ", y = " << y - << ", from_overlay = " << from_overlay; + LOG(DEBUG) << "NWebEventHandler::OnTouchPress sliding response begin"; CefTouchEvent touch_pressed; touch_pressed.type = CEF_TET_PRESSED; touch_pressed.pointer_type = CEF_POINTER_TYPE_TOUCH; @@ -90,8 +87,6 @@ void NWebEventHandler::OnTouchMove(int32_t id, double x, double y, bool from_overlay) { - LOG(DEBUG) << "NWebEventHandler::OnTouchMove id = " << id << ", x = " << x - << ", y = " << y << ", from_overlay = " << from_overlay; CefTouchEvent touch_move; touch_move.type = CEF_TET_MOVED; touch_move.pointer_type = CEF_POINTER_TYPE_TOUCH; @@ -246,9 +241,6 @@ void NWebEventHandler::SendMouseEvent(int x, if (browser_ && browser_->GetHost()) { if (NWebInputDelegate::IsMouseDown(action)) { - if (buttonType == MBT_LEFT) { - browser_->GetHost()->SetFocus(true); - } browser_->GetHost()->SendMouseClickEvent(mouseEvent, buttonType, false, count); } else if (NWebInputDelegate::IsMouseUp(action)) { diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc index 01ce5f5ab2..9983a5a898 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.cc @@ -220,7 +220,7 @@ DateTime ConvertMsToDateTime(double ms) { } double ConvertDateTimeToMonth(const DateTime& datetime) { - return (datetime.year - kEpochBeginYear) * kMonthPerYear + datetime.month; + return (datetime.year - kEpochBeginYear) * kMonthPerYear + datetime.month; } DateTime ConvertMonthToDateTime(double month) { @@ -479,11 +479,6 @@ CefRefPtr NWebHandlerDelegate::GetPrintHandler() { void NWebHandlerDelegate::OnAfterCreated(CefRefPtr browser) { LOG(INFO) << "NWebHandlerDelegate::OnAfterCreated IsPopup " << browser->IsPopup(); CEF_REQUIRE_UI_THREAD(); - if (browser && browser->GetHost()) { - if (window_id_ != 0 && nweb_id_ != 0) { - browser->GetHost()->SetWindowId(window_id_, nweb_id_); - } - } if (!main_browser_ && browser->IsPopup()) { main_browser_ = browser; @@ -704,7 +699,6 @@ void NWebHandlerDelegate::OnLoadingStateChange(CefRefPtr browser, void NWebHandlerDelegate::OnLoadStart(CefRefPtr browser, CefRefPtr frame, - const CefString& url, TransitionType transition_type) { LOG(INFO) << "NWebHandlerDelegate::OnLoadStart"; if (frame == nullptr || !frame->IsMain()) { @@ -714,7 +708,7 @@ void NWebHandlerDelegate::OnLoadStart(CefRefPtr browser, browser->GetHost()->SetFocus(true); } if (nweb_handler_ != nullptr) { - nweb_handler_->OnPageLoadBegin(url.ToString()); + nweb_handler_->OnPageLoadBegin(frame->GetURL().ToString()); } } @@ -761,9 +755,8 @@ void NWebHandlerDelegate::OnPageVisible(CefRefPtr browser, } } -void NWebHandlerDelegate::OnFirstContentfulPaint( - int64_t navigationStartTick, - int64_t firstContentfulPaintMs) { +void NWebHandlerDelegate::OnFirstContentfulPaint(long navigationStartTick, + long firstContentfulPaintMs) { LOG(INFO) << "NWebHandlerDelegate::OnFirstContentfulPaint"; if (nweb_handler_ != nullptr) { nweb_handler_->OnFirstContentfulPaint(navigationStartTick, @@ -897,12 +890,8 @@ void NWebHandlerDelegate::OnRefreshAccessedHistory( CefRefPtr frame, const CefString& url, bool isReload) { - std::string url1 = url.ToString(); - auto pos = url1.find("?"); - url1 = url1.substr(0, pos); - LOG(INFO) - << "NWebHandlerDelegate::OnRefreshAccessedHistory, intercepted url = " - << url1 << ", isReload = " << isReload; + LOG(INFO) << "NWebHandlerDelegate::OnRefreshAccessedHistory, url = " + << url.ToString() << ", isReload = " << isReload; if (nweb_handler_ == nullptr) { LOG(ERROR) << "nweb handler is null"; return; @@ -1217,6 +1206,9 @@ CefRefPtr NWebHandlerDelegate::GetResourceHandler( /* CefPrintHandler method begin */ void NWebHandlerDelegate::OnPrintStart(CefRefPtr browser) { LOG(INFO) << "NWebHandlerDelegate::OnPrintStart"; + if (main_browser_ && main_browser_->GetHost()) { + main_browser_->GetHost()->Print(); + } } void NWebHandlerDelegate::OnPrintSettings(CefRefPtr browser, @@ -1286,56 +1278,6 @@ void NWebHandlerDelegate::OnLoadingProgressChange(CefRefPtr browser, return; } -void NWebHandlerDelegate::ShowPasswordDialog(bool is_update, - const CefString& url) { -#if defined(OHOS_NWEB_EX) - if (web_app_client_extension_listener_ != nullptr && - web_app_client_extension_listener_->OnSaveOrUpdatePassword != nullptr) { - web_app_client_extension_listener_->OnSaveOrUpdatePassword( - is_update, url.ToString(), web_app_client_extension_listener_->nweb_id); - } -#endif // OHOS_NWEB_EX -} - -void NWebHandlerDelegate::OnShowAutofillPopup( - CefRefPtr browser, - const CefRect& bounds, - bool right_aligned, - const std::vector& menu_items) { -#if defined(OHOS_NWEB_EX) - if (!render_handler_) { - return; - } - float ratio = render_handler_->GetCefDeviceRatio(); - std::vector label_list; - std::vector sublabel_list; - for (auto& menu_item : menu_items) { - label_list.push_back(CefString(&menu_item.label).ToString()); - sublabel_list.push_back(CefString(&menu_item.sublabel).ToString()); - } - - if (web_app_client_extension_listener_ != nullptr && - web_app_client_extension_listener_->OnShowPasswordAutofillPopup != - nullptr) { - web_app_client_extension_listener_->OnShowPasswordAutofillPopup( - bounds.x * ratio, bounds.y * ratio, bounds.width * ratio, - bounds.height * ratio, right_aligned, label_list, sublabel_list, - web_app_client_extension_listener_->nweb_id); - } -#endif // OHOS_NWEB_EX -} - -void NWebHandlerDelegate::OnHideAutofillPopup() { -#if defined(OHOS_NWEB_EX) - if (web_app_client_extension_listener_ != nullptr && - web_app_client_extension_listener_->OnHidePasswordAutofillPopup != - nullptr) { - web_app_client_extension_listener_->OnHidePasswordAutofillPopup( - web_app_client_extension_listener_->nweb_id); - } -#endif // OHOS_NWEB_EX -} - void NWebHandlerDelegate::OnReceivedIcon(const void* data, size_t width, size_t height, @@ -1737,7 +1679,7 @@ void NWebHandlerDelegate::OnDateTimeChooserPopup( void NWebHandlerDelegate::OnDateTimeChooserClose() { if (!nweb_handler_) return; - + nweb_handler_->OnDateTimeChooserClose(); } /* CefDialogHandler method end */ @@ -1976,7 +1918,6 @@ void AddNWebValueCef(std::vector>& vector, break; default: LOG(INFO) << "AddNWebValueCef: not support value"; - vector.push_back(value); break; } } @@ -2002,11 +1943,9 @@ std::vector> ParseCefValueTONWebValue( AddNWebValueCef(value_vector, NWebValue::Type::STRING, argument); break; case CefValueType::VTYPE_INVALID: - AddNWebValueCef(value_vector, NWebValue::Type::NONE, argument); break; default: LOG(INFO) << "ParseCefValueTONWebValue: not support value"; - AddNWebValueCef(value_vector, NWebValue::Type::NONE, argument); break; } } diff --git a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h index 7a9fb4a618..c9d9b256b2 100644 --- a/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_handler_delegate.h @@ -127,16 +127,6 @@ class NWebHandlerDelegate : public CefClient, const CefString& method, const CefString& object_name, CefRefPtr result) override; - // #if defined(OHOS_NWEB_EX) - void ShowPasswordDialog(bool is_update, const CefString& url) override; - void OnShowAutofillPopup( - CefRefPtr browser, - const CefRect& bounds, - bool right_aligned, - const std::vector& menu_items) override; - void OnHideAutofillPopup() override; - // #endif - CefRefPtr GetFindHandler() override; CefRefPtr GetKeyboardHandler() override; CefRefPtr GetPrintHandler() override; @@ -175,7 +165,6 @@ class NWebHandlerDelegate : public CefClient, void OnLoadStart(CefRefPtr browser, CefRefPtr frame, - const CefString& url, TransitionType transition_type) override; void OnLoadEnd(CefRefPtr browser, @@ -208,8 +197,8 @@ class NWebHandlerDelegate : public CefClient, const CefString& url, bool success) override; - void OnFirstContentfulPaint(int64_t navigationStartTick, - int64_t firstContentfulPaintMs) override; + void OnFirstContentfulPaint(long navigationStartTick, + long firstContentfulPaintMs) override; void OnDataResubmission(CefRefPtr browser, CefRefPtr callback) override; @@ -464,7 +453,6 @@ class NWebHandlerDelegate : public CefClient, void SetNWebId(uint32_t nwebId); uint32_t GetNWebId(); #endif - void SetWindowId(uint32_t window_id) { window_id_ = window_id; }; void SetFavicon(const void* icon_data, size_t width, size_t height, ImageColorType color_type, ImageAlphaType alpha_type); @@ -525,7 +513,6 @@ class NWebHandlerDelegate : public CefClient, uint32_t access_success_count_ = 0; uint32_t access_fail_count_ = 0; #endif - uint32_t window_id_ = 0; static int32_t popIndex_; CefRefPtr popupWindowCallback_ = nullptr; diff --git a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc index 14e543c1fd..d81a901b6a 100755 --- a/ohos_nweb/src/cef_delegate/nweb_render_handler.cc +++ b/ohos_nweb/src/cef_delegate/nweb_render_handler.cc @@ -27,7 +27,6 @@ #include "nweb_drag_data_impl.h" #include "nweb_touch_handle_state_impl.h" #include "ohos_adapter_helper.h" -#include "res_sched_client_adapter.h" namespace { cef_screen_orientation_type_t ConvertOrientationType( @@ -199,9 +198,6 @@ void NWebRenderHandler::OnScrollOffsetChanged(CefRefPtr browser, if (auto handler = handler_.lock()) { handler->OnScroll(x, y); } - - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::SLIDE); } int NWebRenderHandler::ContentHeight() { @@ -402,12 +398,6 @@ CefRefPtr NWebRenderHandler::GetDragData() { return std::static_pointer_cast(nweb_drag_data_)->GetDragData(); } -void NWebRenderHandler::FreePixlMapData() { - if (nweb_drag_data_) { - std::static_pointer_cast(nweb_drag_data_)->FreePixlMapData(); - } -} - void NWebRenderHandler::OnCompleteSwapWithNewSize() { if (auto handler = handler_.lock()) { handler->OnCompleteSwapWithNewSize(); diff --git a/ohos_nweb/src/cef_delegate/nweb_render_handler.h b/ohos_nweb/src/cef_delegate/nweb_render_handler.h index d381a6e332..403de25c36 100755 --- a/ohos_nweb/src/cef_delegate/nweb_render_handler.h +++ b/ohos_nweb/src/cef_delegate/nweb_render_handler.h @@ -124,7 +124,6 @@ class NWebRenderHandler : public CefRenderHandler { NWebTouchHandleState::TouchHandleType type); CefRefPtr GetDragData(); - void FreePixlMapData(); float GetVirtualPixelRatio() const { return screen_info_.display_ratio; } float GetCefDeviceRatio() const { return cef_device_ratio_; } diff --git a/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.cc b/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.cc index 3712dbdae6..fc2d5c40b5 100644 --- a/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.cc +++ b/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.cc @@ -128,69 +128,6 @@ class GetOriginUsageOrQuotaCallback : public CefGetOriginUsageOrQuotaCallback { IMPLEMENT_REFCOUNTING(GetOriginUsageOrQuotaCallback); }; - -class GetPasswordCallback : public CefGetPasswordCallback { - public: - GetPasswordCallback(std::shared_ptr event, - std::shared_ptr> callback) - : event_(event), callback_(callback), result_("") {} - void OnComplete(const CefString& result) override { - result_ = result; - if (event_ != nullptr) { - event_->Signal(); - } - if (callback_ != nullptr) { - callback_->OnReceiveValue(result.ToString()); - } - } - - std::string GetPassword() const { return result_; } - - private: - std::shared_ptr event_; - std::shared_ptr> callback_; - std::string result_; - - IMPLEMENT_REFCOUNTING(GetPasswordCallback); -}; - -class GetSavedPasswordsCallback : public CefGetSavedPasswordsCallback { - public: - GetSavedPasswordsCallback( - std::shared_ptr event, - std::shared_ptr> callback) - : event_(event), callback_(callback), result_("") {} - void OnComplete(const std::vector& url, - const std::vector& username) override { - int size = url.size(); - for (int i = 0; i < size; i++) { - url_.push_back(url[i].ToString()); - username_.push_back(username[i].ToString()); - } - - if (event_ != nullptr) { - event_->Signal(); - } - if (callback_ != nullptr) { - callback_->OnReceiveValue(result_); - } - } - - std::string GetPassword() const { return result_; } - - std::vector GetPasswordUsername() { return username_; } - - std::vector GetPasswordUrl() { return url_; } - - private: - std::shared_ptr event_; - std::shared_ptr> callback_; - std::string result_; - std::vector url_; - - std::vector username_; - IMPLEMENT_REFCOUNTING(GetSavedPasswordsCallback); -}; } namespace OHOS::NWeb { @@ -301,101 +238,4 @@ long NWebWebStorageDelegate::GetOriginUsage(const std::string& origin) { completion->Wait(); return callback->GetUsageOrQuota(); } - -#if BUILDFLAG(IS_OHOS) -std::string NWebWebStorageDelegate::GetPassword(const std::string& url, - const std::string& username, - int callback_id) { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return ""; - } - - std::shared_ptr completion = - std::make_shared( - base::WaitableEvent::ResetPolicy::AUTOMATIC, - base::WaitableEvent::InitialState::NOT_SIGNALED); - CefRefPtr callback = - new GetPasswordCallback(completion, nullptr); - web_storage->GetPassword(CefString(url), CefString(username), callback); - completion->Wait(); - web_storage_extension_callback_->OnGetPassword( - callback->GetPassword().c_str(), callback_id); - return callback->GetPassword(); -#else - return ""; -#endif // OHOS_NWEB_EX -} - -void NWebWebStorageDelegate::GetSavedPasswordsInfo(int callback_id) { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return; - } - std::shared_ptr completion = - std::make_shared( - base::WaitableEvent::ResetPolicy::AUTOMATIC, - base::WaitableEvent::InitialState::NOT_SIGNALED); - CefRefPtr callback = - new GetSavedPasswordsCallback(completion, nullptr); - web_storage->GetSavedPasswordsInfo(callback); - completion->Wait(); - LOG(INFO) << "get saved password callback id: " << callback_id; - web_storage_extension_callback_->OnGetSavedPasswords( - callback->GetPasswordUrl(), callback->GetPasswordUsername(), callback_id); -#endif // OHOS_NWEB_EX -} - -void NWebWebStorageDelegate::RegisterWebStorageExtensionCallback( - std::shared_ptr - web_storage_extension_callback) { - web_storage_extension_callback_ = web_storage_extension_callback; -} - -void NWebWebStorageDelegate::ClearPassword() { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return; - } - web_storage->ClearPassword(); -#endif // OHOS_NWEB_EX -} - -void NWebWebStorageDelegate::RemovePassword(const std::string& url, - const std::string& username) { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return; - } - web_storage->RemovePassword(url, username); -#endif // OHOS_NWEB_EX -} - -void NWebWebStorageDelegate::ModifyPassword(const std::string& url, - const std::string& old_username, - const std::string& new_username, - const std::string& new_password) { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return; - } - web_storage->ModifyPassword(url, old_username, new_username, new_password); -#endif // OHOS_NWEB_EX -} - -void NWebWebStorageDelegate::RemovePasswordByUrl(const std::string& url) { -#if defined(OHOS_NWEB_EX) - CefRefPtr web_storage = GetGlobalWebStorage(); - if (web_storage == nullptr) { - return; - } - web_storage->RemovePasswordByUrl(url); -#endif // OHOS_NWEB_EX -} -#endif } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.h b/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.h index eac4b7bbd6..8547db2beb 100644 --- a/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.h +++ b/ohos_nweb/src/cef_delegate/nweb_web_storage_delegate.h @@ -38,29 +38,9 @@ class NWebWebStorageDelegate : public NWebWebStorageDelegateInterface { void GetOriginUsage(const std::string& origin, std::shared_ptr> callback) override; long GetOriginUsage(const std::string& origin) override; - -#if BUILDFLAG(IS_OHOS) - void RegisterWebStorageExtensionCallback( - std::shared_ptr - web_storage_extension_callback) override; - std::string GetPassword(const std::string& url, - const std::string& username, - int callback_id) override; - void GetSavedPasswordsInfo(int callback_id) override; - void ClearPassword() override; - void RemovePassword(const std::string& url, - const std::string& username) override; - void RemovePasswordByUrl(const std::string& url) override; - void ModifyPassword(const std::string& url, - const std::string& old_username, - const std::string& new_username, - const std::string& new_password) override; -#endif private: CefRefPtr GetGlobalWebStorage(); CefRefPtr web_storage_ = nullptr; - std::shared_ptr - web_storage_extension_callback_ = nullptr; }; } // namespace OHOS::NWeb #endif diff --git a/ohos_nweb/src/nweb_cookie_manager_delegate_interface.h b/ohos_nweb/src/nweb_cookie_manager_delegate_interface.h index 445570dd9e..8daafa4bfe 100644 --- a/ohos_nweb/src/nweb_cookie_manager_delegate_interface.h +++ b/ohos_nweb/src/nweb_cookie_manager_delegate_interface.h @@ -33,7 +33,7 @@ class NWebCookieManagerDelegateInterface { virtual void ReturnCookie( const std::string& url, std::shared_ptr> callback) = 0; - virtual std::string ReturnCookie(const std::string &url, bool &is_valid) = 0; + virtual std::string ReturnCookie(const std::string &url) = 0; virtual void SetCookie(const std::string& url, const std::string& value, std::shared_ptr> callback) = 0; diff --git a/ohos_nweb/src/nweb_cookie_manager_impl.cc b/ohos_nweb/src/nweb_cookie_manager_impl.cc index 2aeaddbc31..145f13ab5b 100644 --- a/ohos_nweb/src/nweb_cookie_manager_impl.cc +++ b/ohos_nweb/src/nweb_cookie_manager_impl.cc @@ -103,9 +103,9 @@ void NWebCookieManagerImpl::ReturnCookie( } std::string NWebCookieManagerImpl::ReturnCookie( - const std::string& url, bool& is_valid) { + const std::string& url) { if (delegate_ != nullptr) { - return delegate_->ReturnCookie(url, is_valid); + return delegate_->ReturnCookie(url); } return ""; } diff --git a/ohos_nweb/src/nweb_cookie_manager_impl.h b/ohos_nweb/src/nweb_cookie_manager_impl.h index 2d5a7d1b83..1a03052084 100644 --- a/ohos_nweb/src/nweb_cookie_manager_impl.h +++ b/ohos_nweb/src/nweb_cookie_manager_impl.h @@ -36,7 +36,7 @@ class NWebCookieManagerImpl : public NWebCookieManager { void ReturnCookie( const std::string& url, std::shared_ptr> callback) override; - std::string ReturnCookie(const std::string &url, bool &is_valid) override; + std::string ReturnCookie(const std::string &url) override; void SetCookie(const std::string& url, const std::string& value, std::shared_ptr> callback) override; diff --git a/ohos_nweb/src/nweb_delegate_interface.h b/ohos_nweb/src/nweb_delegate_interface.h index 0b58aaa674..735152a593 100755 --- a/ohos_nweb/src/nweb_delegate_interface.h +++ b/ohos_nweb/src/nweb_delegate_interface.h @@ -117,7 +117,6 @@ class NWebDelegateInterface virtual void ClearClientAuthenticationCache() = 0; virtual void Reload() const = 0; virtual void ReloadOriginalUrl() const = 0; - virtual void PasswordSuggestionSelected(int list_index) const = 0; virtual int Zoom(float zoomFactor) const = 0; virtual int ZoomIn() const = 0; virtual int ZoomOut() const = 0; @@ -131,8 +130,6 @@ class NWebDelegateInterface virtual void InitialScale(float scale) const = 0; virtual void OnPause() = 0; virtual void OnContinue() = 0; - virtual void OnOccluded() = 0; - virtual void OnUnoccluded() = 0; virtual std::shared_ptr GetPreference() const = 0; virtual std::string Title() = 0; virtual void CreateWebMessagePorts(std::vector& ports) = 0; @@ -218,19 +215,12 @@ class NWebDelegateInterface virtual void SelectAndCopy() = 0; virtual bool ShouldShowFreeCopy() = 0; virtual void SetEnableBlankTargetPopupIntercept(bool enableBlankTargetPopup) = 0; - - virtual void SetSavePasswordAutomatically(bool enable) = 0; - virtual bool GetSavePasswordAutomatically() = 0; - virtual void SetSavePassword(bool enable) = 0; - virtual bool GetSavePassword() = 0; - virtual void SaveOrUpdatePassword(bool is_update) = 0; #endif virtual void SetShouldFrameSubmissionBeforeDraw(bool should) = 0; virtual void SetAudioResumeInterval(int32_t resumeInterval) = 0; virtual void SetAudioExclusive(bool audioExclusive) = 0; virtual void NotifyPopupWindowResult(bool result) = 0; - virtual void SetWindowId(uint32_t window_id); }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_impl.cc b/ohos_nweb/src/nweb_impl.cc index cfb1f8fd71..2d4a7025be 100755 --- a/ohos_nweb/src/nweb_impl.cc +++ b/ohos_nweb/src/nweb_impl.cc @@ -50,9 +50,7 @@ #include "content/public/browser/browser_context.h" #include "content/public/browser/network_service_instance.h" #include "content/public/browser/storage_partition.h" -#include "res_sched_client_adapter.h" #include "services/network/network_service.h" -#include "soc_perf_client_adapter.h" #endif #include "libcef/browser/predictors/loading_predictor.h" @@ -78,11 +76,6 @@ uint32_t g_nweb_max_count = 0; namespace OHOS::NWeb { -#if BUILDFLAG(IS_OHOS) -static constexpr int32_t SOC_PERF_LOADURL_CONFIG_ID = 10070; -static constexpr int32_t SOC_PERF_MOUSEWHEEL_CONFIG_ID = 10071; -#endif - typedef std::unordered_map> NWebMap; base::LazyInstance::DestructorAtExit g_nweb_map = LAZY_INSTANCE_INITIALIZER; @@ -163,14 +156,11 @@ NWebImpl* NWebImpl::FromID(int32_t nweb_id) { return nullptr; } -NWebImpl::NWebImpl(uint32_t id) : nweb_id_(id) { - ResSchedClientAdapter::ReportNWebInit(ResSchedStatusAdapter::WEB_SCENE_ENTER, - nweb_id_); -} +std::set NWebImpl::focus_nweb_id_{}; + +NWebImpl::NWebImpl(uint32_t id) : nweb_id_(id) {} NWebImpl::~NWebImpl() { - ResSchedClientAdapter::ReportNWebInit(ResSchedStatusAdapter::WEB_SCENE_EXIT, - nweb_id_); g_nweb_map.Get().erase(nweb_id_); } @@ -202,7 +192,7 @@ bool NWebImpl::Init(const NWebCreateInfo& create_info) { } void NWebImpl::OnDestroy() { - WVLOG_I("NWebImpl::OnDestroy, nweb_id = %{public}u", nweb_id_); + WVLOG_I("NWebImpl::OnDestroy"); if (g_nweb_count == 0) { return; } @@ -355,11 +345,6 @@ void NWebImpl::PutDownloadCallback( } void NWebImpl::SetNWebHandler(std::shared_ptr client) { - if (nweb_delegate_ == nullptr) { - WVLOG_E("set nweb handler failed, nweb delegate is nullptr, nweb_id = %{public}u", nweb_id_); - return; - } - nweb_handle_ = client; nweb_delegate_->RegisterNWebHandler(client); client->SetNWeb(shared_from_this()); @@ -387,8 +372,6 @@ void NWebImpl::OnTouchPress(int32_t id, double x, double y, bool from_overlay) { return; } - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::CLICK, nweb_id_); input_handler_->OnTouchPress(id, x, y, from_overlay); } @@ -439,14 +422,6 @@ void NWebImpl::SendMouseWheelEvent(double x, if (input_handler_ == nullptr) { return; } - - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::SLIDE); - - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .CreateSocPerfClientAdapter() - ->ApplySocPerfConfigById(SOC_PERF_MOUSEWHEEL_CONFIG_ID); - input_handler_->SendMouseWheelEvent(x, y, deltaX, deltaY); } @@ -454,11 +429,6 @@ void NWebImpl::SendMouseEvent(int x, int y, int button, int action, int count) { if (input_handler_ == nullptr) { return; } - - if (action == MouseAction::PRESS) { - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::CLICK, nweb_id_); - } input_handler_->SendMouseEvent(x, y, button, action, count); } @@ -472,13 +442,6 @@ int NWebImpl::Load(const std::string& url) const { return NWEB_ERR; } - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::LOAD_URL, nweb_id_); - - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .CreateSocPerfClientAdapter() - ->ApplySocPerfConfigById(SOC_PERF_LOADURL_CONFIG_ID); - int result = nweb_delegate_->Load(url); output_handler_->StartRenderOutput(); return result; @@ -624,34 +587,18 @@ void NWebImpl::OnContinue() const { LOG(ERROR) << "nweb_delegate_ is nullptr."; return; } - nweb_delegate_->OnContinue(); if (inputmethod_handler_ == nullptr) { LOG(ERROR) << "inputmethod_handler_ is nullptr."; return; } if (inputmethod_handler_->Reattach( - nweb_id_, NWebInputMethodHandler::ReattachType::FROM_CONTINUE)) { + nweb_id_, NWebInputMethodHandler::ReattachType::FROM_CONTINUE)) { nweb_delegate_->OnFocus(); + focus_nweb_id_.insert(nweb_id_); } } -void NWebImpl::OnOccluded() const { - if (nweb_delegate_ == nullptr) { - LOG(ERROR) << "nweb_delegate_ is nullptr."; - return; - } - nweb_delegate_->OnOccluded(); -} - -void NWebImpl::OnUnoccluded() const { - if (nweb_delegate_ == nullptr) { - LOG(ERROR) << "nweb_delegate_ is nullptr."; - return; - } - nweb_delegate_->OnUnoccluded(); -} - void NWebImpl::StopCameraSession() const { if (!OhosAdapterHelper::GetInstance() .GetCameraManagerAdapter() @@ -694,14 +641,6 @@ void NWebImpl::OnWebviewShow() const { RestartCameraSession(); } -void NWebImpl::SetWindowId(uint32_t window_id) { - if (nweb_delegate_ == nullptr) { - WVLOG_E("SetWindowId nweb delegate is null"); - return; - } - nweb_delegate_->SetWindowId(window_id); -} - const std::shared_ptr NWebImpl::GetPreference() const { if (nweb_delegate_ == nullptr) { return nullptr; @@ -860,12 +799,19 @@ void NWebImpl::OnFocus(const FocusReason& focusReason) const { LOG(ERROR) << "nweb_delegate_ is nullptr."; return; } + if (focusReason == FocusReason::FOCUS_DEFAULT && !focus_nweb_id_.empty() && + focus_nweb_id_.find(nweb_id_) == focus_nweb_id_.end()) { + LOG(DEBUG) << "There is already web capture, and there is no need for " + "capture when loading this web page."; + return; + } if (inputmethod_handler_ == nullptr) { LOG(ERROR) << "inputmethod_handler_ is nullptr."; return; } if (nweb_delegate_->OnFocus(focusReason)) { + focus_nweb_id_.insert(nweb_id_); inputmethod_handler_->Reattach( nweb_id_, NWebInputMethodHandler::ReattachType::FROM_ONFOCUS); } @@ -877,6 +823,9 @@ void NWebImpl::OnBlur(const BlurReason& blurReason) const { return; } nweb_delegate_->OnBlur(); + if (focus_nweb_id_.find(nweb_id_) != focus_nweb_id_.end()) { + focus_nweb_id_.erase(nweb_id_); + } if (inputmethod_handler_ == nullptr) { LOG(ERROR) << "inputmethod_handler_ is nullptr."; return; @@ -1128,20 +1077,94 @@ bool NWebImpl::GetBrowserServiceApiEnabled() { return g_browser_service_api_enabled; } -void NWebImpl::ReloadOriginalUrl() const { - if (nweb_delegate_ == nullptr) { +void NWebImpl::SetUrlExceptionList(int contentType, + std::vector& urls, + bool accept) { +#if defined(OHOS_NWEB_EX) + // URL例外列表中域名的最大数量。 + static constexpr unsigned int kMaxUrlExceptions = 10000; + + ContentSettingsType content_type = + static_cast(contentType); + if (content_type != ContentSettingsType::COOKIES && + content_type != ContentSettingsType::JAVASCRIPT) { + LOG(ERROR) << "SetUrlExceptionList Unsupported content type: " + << contentType; return; } - nweb_delegate_->ReloadOriginalUrl(); + ContentSetting setting = CONTENT_SETTING_BLOCK; + if (accept) { + setting = CONTENT_SETTING_ALLOW; + } + + std::vector urls_vector; + for (std::string url : urls) { + urls_vector.push_back(url); + } + + if (urls_vector.size() > kMaxUrlExceptions) { + urls_vector.resize(kMaxUrlExceptions); + } + int size = urls_vector.size(); + for (const auto& cef_browser_context : CefBrowserContext::GetAll()) { + content::BrowserContext* browser_context = + cef_browser_context->AsBrowserContext(); + if (!browser_context) { + LOG(ERROR) << "SetUrlExceptionList null browser_context"; + return; + } + HostContentSettingsMap* host_content_settings_map = + HostContentSettingsMapFactory::GetForProfile(browser_context); + if (!host_content_settings_map) { + LOG(ERROR) << "SetUrlExceptionList null host_content_settings_map"; + return; + } + // Reset custom rules. + host_content_settings_map->ClearSettingsForOneType(content_type); + // Set custom rules. + for (int i = 0; i < size; i++) { + host_content_settings_map->SetContentSettingCustomScope( + ContentSettingsPattern::FromString(urls_vector[i]), + ContentSettingsPattern::Wildcard(), content_type, + static_cast(setting)); + } + + // Update cookies' setting on storage. + if (content_type == ContentSettingsType::COOKIES) { + ContentSettingsForOneType cookies_settings; + host_content_settings_map->GetSettingsForOneType( + ContentSettingsType::COOKIES, &cookies_settings); + + browser_context->ForEachStoragePartition(base::BindRepeating( + [](ContentSettingsForOneType settings, + content::StoragePartition* storage_partition) { + storage_partition->GetCookieManagerForBrowserProcess() + ->SetContentSettings(settings); + }, + cookies_settings)); + } + } + + LOG(INFO) << "SetUrlExceptionList Add " + << (setting == CONTENT_SETTING_BLOCK ? "Block" : "Allow") + << " exception for content type: " << int32_t(content_type) + << " with " << size; +#endif +} + +void NWebImpl::SetConnectTimeout(int32_t seconds) { +#if defined(OHOS_NWEB_EX) + content::GetNetworkService()->SetConnectTimeout(seconds); +#endif } -void NWebImpl::PasswordSuggestionSelected(int list_index) const { +void NWebImpl::ReloadOriginalUrl() const { if (nweb_delegate_ == nullptr) { return; } - nweb_delegate_->PasswordSuggestionSelected(list_index); + nweb_delegate_->ReloadOriginalUrl(); } void NWebImpl::SetBrowserUserAgentString(const std::string& user_agent) { @@ -1183,13 +1206,6 @@ void NWebImpl::SetForceEnableZoom(bool forceEnableZoom) const { nweb_delegate_->SetForceEnableZoom(forceEnableZoom); } -void NWebImpl::SaveOrUpdatePassword(bool is_update) { - if (nweb_delegate_ == nullptr) { - return; - } - nweb_delegate_->SaveOrUpdatePassword(is_update); -} - bool NWebImpl::GetForceEnableZoom() const { if (nweb_delegate_ == nullptr) { return false; @@ -1229,35 +1245,6 @@ void NWebImpl::SetEnableBlankTargetPopupIntercept( } nweb_delegate_->SetEnableBlankTargetPopupIntercept(enableBlankTargetPopup); } - -bool NWebImpl::GetSavePasswordAutomatically() const { - if (nweb_delegate_ == nullptr) { - return false; - } - return nweb_delegate_->GetSavePasswordAutomatically(); -} - -void NWebImpl::SetSavePasswordAutomatically(bool enable) const { - if (nweb_delegate_ == nullptr) { - return; - } - nweb_delegate_->SetSavePasswordAutomatically(enable); -} - -bool NWebImpl::GetSavePassword() const { - if (nweb_delegate_ == nullptr) { - return false; - } - return nweb_delegate_->GetSavePassword(); -} - -void NWebImpl::SetSavePassword(bool enable) const { - if (nweb_delegate_ == nullptr) { - return; - } - nweb_delegate_->SetSavePassword(enable); -} - #endif // OHOS_NWEB_EX void NWebImpl::PrefetchPage( diff --git a/ohos_nweb/src/nweb_impl.h b/ohos_nweb/src/nweb_impl.h index 19ebbd1bea..373ec61e2a 100755 --- a/ohos_nweb/src/nweb_impl.h +++ b/ohos_nweb/src/nweb_impl.h @@ -34,8 +34,8 @@ namespace OHOS::NWeb { class NWebImpl : public NWeb { public: - explicit NWebImpl(uint32_t id); - ~NWebImpl() override; + NWebImpl(uint32_t id); + ~NWebImpl(); bool Init(const NWebCreateInfo& create_info); void OnDestroy() override; @@ -82,8 +82,6 @@ class NWebImpl : public NWeb { void InitialScale(float scale) const override; void OnPause() const override; void OnContinue() const override; - void OnOccluded() const override; - void OnUnoccluded() const override; const std::shared_ptr GetPreference() const override; void PutDownloadCallback( std::shared_ptr downloadListener) override; @@ -160,7 +158,6 @@ class NWebImpl : public NWeb { void NotifyMemoryLevel(int32_t level) override; void OnWebviewHide() const override; void OnWebviewShow() const override; - void SetWindowId(uint32_t window_id) override; // For NWebEx static NWebImpl* FromID(int32_t nweb_id); @@ -181,24 +178,19 @@ class NWebImpl : public NWeb { static const std::vector& GetCommandLineArgsForNWebEx(); static void InitBrowserServiceApi(std::vector& browser_args); static bool GetBrowserServiceApiEnabled(); - + static void SetConnectTimeout(int32_t seconds); + static void SetUrlExceptionList(int contentType, + std::vector& urls, + bool accept); void PutWebAppClientExtensionCallback( std::shared_ptr web_app_client_extension_listener); void RemoveWebAppClientExtensionCallback(); void ReloadOriginalUrl() const; - void PasswordSuggestionSelected(int list_index) const; void SetBrowserUserAgentString(const std::string& user_agent); void SetForceEnableZoom(bool forceEnableZoom) const; bool GetForceEnableZoom() const; - - void SetSavePasswordAutomatically(bool enable) const; - bool GetSavePasswordAutomatically() const; - void SetSavePassword(bool enable) const; - bool GetSavePassword() const; - void SaveOrUpdatePassword(bool is_update); - void SelectAndCopy() const; bool ShouldShowFreeCopy() const; void PutWebDownloadDelegateCallback( @@ -230,6 +222,7 @@ class NWebImpl : public NWeb { std::list web_engine_args_; float device_pixel_ratio_ = 0.f; bool is_enhance_surface_ = false; + static std::set focus_nweb_id_; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_inputmethod_handler.cc b/ohos_nweb/src/nweb_inputmethod_handler.cc index bae1c950d9..6919852fc1 100644 --- a/ohos_nweb/src/nweb_inputmethod_handler.cc +++ b/ohos_nweb/src/nweb_inputmethod_handler.cc @@ -23,7 +23,6 @@ #include "content/public/browser/browser_thread.h" #include "libcef/browser/thread_util.h" #include "ohos_adapter_helper.h" -#include "res_sched_client_adapter.h" #include "ui/events/keycodes/keyboard_codes_posix.h" namespace OHOS::NWeb { @@ -131,20 +130,6 @@ NWebInputMethodHandler::~NWebInputMethodHandler() {} uint32_t NWebInputMethodHandler::lastAttachNWebId_ = 0; -IMFAdapterCursorInfo NWebInputMethodHandler::GetCursorInfo() { - IMFAdapterCursorInfo cursorInfo { - .left = (focus_rect_.x + focus_rect_.width) * device_pixel_ratio_ + - offset_x_, - .top = focus_rect_.y * device_pixel_ratio_ + offset_y_, - .width = focus_rect_.width * device_pixel_ratio_, - .height = focus_rect_.height * device_pixel_ratio_}; - LOG(DEBUG) << "NWebInputMethodHandler::Attach cursorInfo.left = " - << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top - << ", cursorInfo.width = " << cursorInfo.width - << ", cursorInfo.height = " << cursorInfo.height; - return cursorInfo; -} - void NWebInputMethodHandler::Attach(CefRefPtr browser, bool show_keyboard, cef_text_input_mode_t input_mode) { @@ -161,21 +146,27 @@ void NWebInputMethodHandler::Attach(CefRefPtr browser, if (inputmethod_listener_ == nullptr) { inputmethod_listener_ = std::make_shared(this); } - - IMFAdapterInputAttribute inputAttribute = { .inputPattern = static_cast(input_mode_), - .enterKeyType = static_cast(IMFAdapterEnterKeyType::DONE) }; - - IMFAdapterCursorInfo cursorInfo = GetCursorInfo(); - - IMFAdapterTextConfig textConfig = { .inputAttribute = inputAttribute, .cursorInfo = cursorInfo }; - if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard_, textConfig)) { + if (!inputmethod_adapter_->Attach(inputmethod_listener_, false)) { LOG(ERROR) << "inputmethod_adapter_ attach failed"; return; } isAttached_ = true; lastAttachNWebId_ = nweb_Id_; + if (show_keyboard) { + inputmethod_adapter_->ShowCurrentInput(input_mode_); + } if (focus_status_ && focus_rect_status_) { + IMFAdapterCursorInfo cursorInfo{ + .left = (focus_rect_.x + focus_rect_.width) * device_pixel_ratio_ + + offset_x_, + .top = focus_rect_.y * device_pixel_ratio_ + offset_y_, + .width = focus_rect_.width * device_pixel_ratio_, + .height = focus_rect_.height * device_pixel_ratio_}; + LOG(DEBUG) << "NWebInputMethodHandler::Attach cursorInfo.left = " + << cursorInfo.left << ", cursorInfo.top = " << cursorInfo.top + << ", cursorInfo.width = " << cursorInfo.width + << ", cursorInfo.height = " << cursorInfo.height; if (inputmethod_adapter_) { inputmethod_adapter_->OnCursorUpdate(cursorInfo); } @@ -214,20 +205,17 @@ bool NWebInputMethodHandler::Reattach(uint32_t nwebId, ReattachType type) { inputmethod_adapter_->Close(); return false; } - IMFAdapterInputAttribute inputAttribute = { .inputPattern = static_cast(input_mode_), - .enterKeyType = static_cast(IMFAdapterEnterKeyType::DONE) }; - - IMFAdapterCursorInfo cursorInfo = GetCursorInfo(); - - IMFAdapterTextConfig textConfig = { .inputAttribute = inputAttribute, .cursorInfo = cursorInfo }; - if (!inputmethod_adapter_->Attach(inputmethod_listener_, show_keyboard_, textConfig)) { + if (!inputmethod_adapter_->Attach(inputmethod_listener_, false)) { LOG(ERROR) << "inputmethod_adapter_ attach failed"; return false; } isAttached_ = true; lastAttachNWebId_ = nwebId; - - return show_keyboard_; + if (show_keyboard_) { + inputmethod_adapter_->ShowCurrentInput(input_mode_); + return true; + } + return false; } void NWebInputMethodHandler::ShowTextInput() { @@ -400,12 +388,6 @@ void NWebInputMethodHandler::InsertTextHandlerOnUI(const std::u16string& text) { keyEvent.type = KEYEVENT_RAWKEYDOWN; browser_->GetHost()->SendKeyEvent(keyEvent); - LOG(DEBUG) << "insert text length:" << text.length(); - if (text.length() > 1) { - ResSchedClientAdapter::ReportScene(ResSchedStatusAdapter::WEB_SCENE_ENTER, - ResSchedSceneAdapter::CLICK); - } - if (!ime_text_composing_) { ime_text_composing_ = true; composing_text_.clear(); @@ -437,17 +419,16 @@ void NWebInputMethodHandler::DeleteForwardHandlerOnUI(int32_t length) { return; } is_need_notify_all_ = false; - text_cursor_length_ = length; selected_from_ = selected_from_ >= whole_text_.size() ? whole_text_.size() : selected_from_; if (whole_text_.substr(selected_from_).size() <= length) { - text_cursor_length_ = whole_text_.substr(selected_from_).size(); + length = whole_text_.substr(selected_from_).size(); if (selected_from_ == 0) { is_need_notify_all_ = true; } } { std::unique_lock lock(textCursorMutex_); - textCursorReady_ += text_cursor_length_; + textCursorReady_ += length; } for (int32_t i = 0; i < length; i++) { keyEvent.type = KEYEVENT_RAWKEYDOWN; @@ -471,13 +452,12 @@ void NWebInputMethodHandler::DeleteBackwardHandlerOnUI(int32_t length) { LOG(ERROR) << "delete forward browser get failed"; return; } - text_cursor_length_ = length; if (selected_from_ <= length) { - text_cursor_length_ = selected_from_; + length = selected_from_; } { std::unique_lock lock(textCursorMutex_); - textCursorReady_ += text_cursor_length_; + textCursorReady_ += length; } for (int32_t i = 0; i < length; i++) { keyEvent.type = KEYEVENT_RAWKEYDOWN; diff --git a/ohos_nweb/src/nweb_inputmethod_handler.h b/ohos_nweb/src/nweb_inputmethod_handler.h index f7f2b13d02..dedc8783f1 100644 --- a/ohos_nweb/src/nweb_inputmethod_handler.h +++ b/ohos_nweb/src/nweb_inputmethod_handler.h @@ -66,7 +66,6 @@ class NWebInputMethodHandler : public NWebInputMethodClient { void DeleteForwardHandlerOnUI(int32_t length); bool IsCorrectParam(int32_t number, int32_t& selectBegin, int32_t& selectEnd); bool ResetTextSelectiondata(); - IMFAdapterCursorInfo GetCursorInfo(); static uint32_t lastAttachNWebId_; uint32_t nweb_Id_ = 0; @@ -97,7 +96,6 @@ class NWebInputMethodHandler : public NWebInputMethodClient { std::mutex textCursorMutex_; std::condition_variable textCursorCv_; bool is_need_notify_all_ = false; - int32_t text_cursor_length_ = 0; IMPLEMENT_REFCOUNTING(NWebInputMethodHandler); }; diff --git a/ohos_nweb/src/nweb_output_handler.cc b/ohos_nweb/src/nweb_output_handler.cc index 80153357fa..4b6f02489b 100644 --- a/ohos_nweb/src/nweb_output_handler.cc +++ b/ohos_nweb/src/nweb_output_handler.cc @@ -112,21 +112,6 @@ void NWebOutputHandler::Resize(uint32_t width, uint32_t height) { if (!dump_path_.empty() || dump_buf_ == nullptr) { dump_buf_.reset(new char[frame_size_]); } - - if (!is_initialized_resize_) { - int32_t ret = - OHOS::NWeb::OhosAdapterHelper::GetInstance() - .GetWindowAdapterInstance() - .NativeWindowHandleOpt(reinterpret_cast(window_), - OHOS::NWeb::WindowAdapter::SET_BUFFER_GEOMETRY, - width, height); - if (ret == OHOS::NWeb::GSErrorCode::GSERROR_OK) { - is_initialized_resize_ = true; - WVLOG_I("need to resize for emulator early firstly, result = %{public}d", ret); - } else { - WVLOG_W("resize for emulator early failed, result = %{public}d", ret); - } - } } } diff --git a/ohos_nweb/src/nweb_output_handler.h b/ohos_nweb/src/nweb_output_handler.h index 0820c26fff..a6f1a3b90e 100644 --- a/ohos_nweb/src/nweb_output_handler.h +++ b/ohos_nweb/src/nweb_output_handler.h @@ -90,7 +90,6 @@ class NWebOutputHandler int64_t frame_miss_count_ = 0L; uint32_t nweb_id_ = 0; - bool is_initialized_resize_ = false; }; } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_web_storage_delegate_interface.h b/ohos_nweb/src/nweb_web_storage_delegate_interface.h index 05214813dc..7e021cdbb4 100644 --- a/ohos_nweb/src/nweb_web_storage_delegate_interface.h +++ b/ohos_nweb/src/nweb_web_storage_delegate_interface.h @@ -19,8 +19,6 @@ #include #include #include -#include "build/build_config.h" -#include "capi/nweb_storage_extension_callback.h" #include "nweb_value_callback.h" #include "nweb_web_storage.h" @@ -39,24 +37,6 @@ class NWebWebStorageDelegateInterface { virtual void GetOriginUsage(const std::string& origin, std::shared_ptr> callback) = 0; virtual long GetOriginUsage(const std::string& origin) = 0; - -#if BUILDFLAG(IS_OHOS) - virtual void RegisterWebStorageExtensionCallback( - std::shared_ptr - web_storage_extension_callback) = 0; - virtual std::string GetPassword(const std::string& url, - const std::string& username, - int callback_id) = 0; - virtual void GetSavedPasswordsInfo(int callback_id) = 0; - virtual void ClearPassword() = 0; - virtual void RemovePassword(const std::string& url, - const std::string& username) = 0; - virtual void RemovePasswordByUrl(const std::string& url) = 0; - virtual void ModifyPassword(const std::string& url, - const std::string& old_username, - const std::string& new_username, - const std::string& new_password) = 0; -#endif }; } // namespace OHOS::NWeb #endif diff --git a/ohos_nweb/src/nweb_web_storage_impl.cc b/ohos_nweb/src/nweb_web_storage_impl.cc index 11942bf52b..452309e9e5 100644 --- a/ohos_nweb/src/nweb_web_storage_impl.cc +++ b/ohos_nweb/src/nweb_web_storage_impl.cc @@ -87,56 +87,4 @@ long NWebWebStorageImpl::GetOriginUsage(const std::string& origin) { return NWEB_ERR; } -#if BUILDFLAG(IS_OHOS) -void NWebWebStorageImpl::PutWebStorageCallback( - std::shared_ptr - web_storage_extension_callback) { - if (delegate_ != nullptr) { - delegate_->RegisterWebStorageExtensionCallback( - web_storage_extension_callback); - } -} - -std::string NWebWebStorageImpl::GetPassword(const std::string& url, - const std::string& username, - int callback_id) { - if (delegate_ != nullptr) { - return delegate_->GetPassword(url, username, callback_id); - } - return ""; -} - -void NWebWebStorageImpl::GetSavedPasswords(int callback_id) { - if (delegate_ != nullptr) { - return delegate_->GetSavedPasswordsInfo(callback_id); - } -} - -void NWebWebStorageImpl::ClearPassword() { - if (delegate_ != nullptr) { - delegate_->ClearPassword(); - } -} - -void NWebWebStorageImpl::RemovePassword(const std::string& url, - const std::string& username) { - if (delegate_ != nullptr) { - delegate_->RemovePassword(url, username); - } -} -void NWebWebStorageImpl::ModifyPassword(const std::string& url, - const std::string& old_username, - const std::string& new_username, - const std::string& new_password) { - if (delegate_ != nullptr) { - delegate_->ModifyPassword(url, old_username, new_username, new_password); - } -} - -void NWebWebStorageImpl::RemovePasswordByUrl(const std::string& url) { - if (delegate_ != nullptr) { - delegate_->RemovePasswordByUrl(url); - } -} -#endif } // namespace OHOS::NWeb diff --git a/ohos_nweb/src/nweb_web_storage_impl.h b/ohos_nweb/src/nweb_web_storage_impl.h index 39dd1a0ca8..a71df94faa 100644 --- a/ohos_nweb/src/nweb_web_storage_impl.h +++ b/ohos_nweb/src/nweb_web_storage_impl.h @@ -16,8 +16,6 @@ #ifndef NWEB_WEB_STORAGE_IMPL_H #define NWEB_WEB_STORAGE_IMPL_H -#include "build/build_config.h" -#include "capi/nweb_storage_extension_callback.h" #include "nweb_errors.h" #include "nweb_web_storage.h" #include "nweb_web_storage_delegate_interface.h" @@ -38,20 +36,6 @@ class NWebWebStorageImpl : public NWebWebStorage { void GetOriginUsage(const std::string& origin, std::shared_ptr> callback) override; long GetOriginUsage(const std::string& origin) override; - -#if BUILDFLAG(IS_OHOS) - void PutWebStorageCallback(std::shared_ptr - web_storage_extension_callback); - std::string GetPassword(const std::string& url, const std::string& username, int callback_id); - void GetSavedPasswords(int callback_id); - void ClearPassword(); - void RemovePassword(const std::string& url, const std::string& username); - void RemovePasswordByUrl(const std::string& url); - void ModifyPassword(const std::string& url, - const std::string& old_username, - const std::string& new_username, - const std::string& new_password); -#endif private: std::shared_ptr delegate_; }; diff --git a/services/device/geolocation/ohos/location_provider_ohos.cc b/services/device/geolocation/ohos/location_provider_ohos.cc index 4bbfba70e9..f081cbbf12 100755 --- a/services/device/geolocation/ohos/location_provider_ohos.cc +++ b/services/device/geolocation/ohos/location_provider_ohos.cc @@ -28,7 +28,6 @@ LocationProviderOhos::~LocationProviderOhos() { void LocationProviderOhos::SetUpdateCallback( const LocationProviderUpdateCallback& callback) { - LOG(DEBUG) << "LocationProviderOhos::SetUpdateCallback"; callback_ = callback; if (!locator_callback_) { @@ -46,13 +45,11 @@ void LocationProviderOhos::ProviderUpdateCallback( } void LocationProviderOhos::StartProvider(bool high_accuracy) { - LOG(DEBUG) << "LocationProviderOhos::StartProvider"; StopProvider(); RequestLocationUpdate(high_accuracy); } void LocationProviderOhos::StopProvider() { - LOG(DEBUG) << "LocationProviderOhos::StopProvider"; if (!is_running_) return; is_running_ = false; @@ -62,18 +59,15 @@ void LocationProviderOhos::StopProvider() { } const mojom::Geoposition& LocationProviderOhos::GetPosition() { - LOG(DEBUG) << "LocationProviderOhos::GetPosition"; return locator_callback_->GetPosition(); } void LocationProviderOhos::OnPermissionGranted() { - LOG(DEBUG) << "LocationProviderOhos::OnPermissionGranted"; // Nothing to do here. } void LocationProviderCallback::OnNewLocationAvailable( const std::unique_ptr& location) { - LOG(DEBUG) << "LocationProviderCallback::OnNewLocationAvailable"; if (!location) return; @@ -92,7 +86,6 @@ void LocationProviderCallback::OnNewLocationAvailable( } void LocationProviderCallback::OnNewErrorAvailable(std::string message) { - LOG(DEBUG) << "LocationProviderCallback::OnNewErrorAvailable"; mojom::Geoposition position_error; position_error.error_code = mojom::Geoposition::ErrorCode::POSITION_UNAVAILABLE; diff --git a/services/network/cookie_manager.cc b/services/network/cookie_manager.cc index 52d9610d73..4eb14790b8 100644 --- a/services/network/cookie_manager.cc +++ b/services/network/cookie_manager.cc @@ -130,34 +130,6 @@ void CookieManager::SetCanonicalCookie(const net::CanonicalCookie& cookie, std::move(on_got_first_party_set_key)); } -#if BUILDFLAG(IS_OHOS) -void CookieManager::SetCanonicalCookieSync( - const net::CanonicalCookie& cookie, - const GURL& source_url, - const net::CookieOptions& cookie_options, - SetCanonicalCookieCallback callback) { - SetCanonicalCookie(cookie, source_url, cookie_options, std::move(callback)); -} - -void CookieManager::GetCookieListSync( - const GURL& url, - const net::CookieOptions& cookie_options, - const net::CookiePartitionKeyCollection& cookie_partition_key_collection, - GetCookieListCallback callback) { - GetCookieList(url, cookie_options, cookie_partition_key_collection, - std::move(callback)); -} - -void CookieManager::GetAllCookiesSync(GetAllCookiesCallback callback) { - GetAllCookies(std::move(callback)); -} - -void CookieManager::DeleteCookiesSync(mojom::CookieDeletionFilterPtr filter, - DeleteCookiesCallback callback) { - DeleteCookies(std::move(filter), std::move(callback)); -} -#endif - void CookieManager::OnGotFirstPartySetPartitionKeyForSet( const GURL& source_url, const net::CookieOptions& cookie_options, diff --git a/services/network/cookie_manager.h b/services/network/cookie_manager.h index e6ad728121..903ea211a6 100644 --- a/services/network/cookie_manager.h +++ b/services/network/cookie_manager.h @@ -72,20 +72,6 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) CookieManager const GURL& source_url, const net::CookieOptions& cookie_options, SetCanonicalCookieCallback callback) override; -#if BUILDFLAG(IS_OHOS) - void SetCanonicalCookieSync(const net::CanonicalCookie& cookie, - const GURL& source_url, - const net::CookieOptions& cookie_options, - SetCanonicalCookieCallback callback) override; - void GetCookieListSync( - const GURL& url, - const net::CookieOptions& cookie_options, - const net::CookiePartitionKeyCollection& cookie_partition_key_collection, - GetCookieListCallback callback) override; - void GetAllCookiesSync(GetAllCookiesCallback callback) override; - void DeleteCookiesSync(mojom::CookieDeletionFilterPtr filter, - DeleteCookiesCallback callback) override; -#endif void DeleteCanonicalCookie(const net::CanonicalCookie& cookie, DeleteCanonicalCookieCallback callback) override; void SetContentSettings(const ContentSettingsForOneType& settings) override; diff --git a/services/network/network_context.cc b/services/network/network_context.cc index 2be0ae1cbc..552d8403fa 100644 --- a/services/network/network_context.cc +++ b/services/network/network_context.cc @@ -576,8 +576,6 @@ NetworkContext::NetworkContext( } NetworkContext::~NetworkContext() { - is_destructing_ = true; - // May be nullptr in tests. if (network_service_) network_service_->DeregisterNetworkContext(this); @@ -630,13 +628,6 @@ NetworkContext::~NetworkContext() { } } #endif - - - // Clear `url_loader_factories_` before deleting the contents, as it can - // result in re-entrant calls to DestroyURLLoaderFactory(). - std::set, - base::UniquePtrComparator> - url_loader_factories = std::move(url_loader_factories_); } // static @@ -809,9 +800,6 @@ void NetworkContext::DisableQuic() { void NetworkContext::DestroyURLLoaderFactory( cors::CorsURLLoaderFactory* url_loader_factory) { - if (is_destructing_) { - return; - } auto it = url_loader_factories_.find(url_loader_factory); DCHECK(it != url_loader_factories_.end()); url_loader_factories_.erase(it); diff --git a/services/network/network_context.h b/services/network/network_context.h index 1cd2ece539..b2be01061e 100644 --- a/services/network/network_context.h +++ b/services/network/network_context.h @@ -827,10 +827,6 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext // DCHECKs on APIs used by external callers. bool require_network_isolation_key_ = false; - // True once the destructor has been called. Used to guard against re-entrant - // calls to DestroyURLLoaderFactory(). - bool is_destructing_ = false; - // Indicating whether // https://fetch.spec.whatwg.org/#cors-non-wildcard-request-header-name is // supported. @@ -839,8 +835,13 @@ class COMPONENT_EXPORT(NETWORK_SERVICE) NetworkContext // CorsURLLoaderFactory assumes that fields owned by the NetworkContext always // live longer than the factory. Therefore we want the factories to be - // destroyed before other fields above. This is accomplished by explicitly - // clearing `url_loader_factories_` in the destructor. + // destroyed before other fields above. In particular: + // - This must be below |url_request_context_| so that the URLRequestContext + // outlives all the URLLoaderFactories and URLLoaders that depend on it; + // for the same reason, it must also be below |network_context_|. + // - This must be below |loader_count_per_process_| that is touched by + // CorsURLLoaderFactory::DestroyURLLoader (see also + // https://crbug.com/1174943). std::set, base::UniquePtrComparator> url_loader_factories_; diff --git a/services/network/public/mojom/cookie_manager.mojom b/services/network/public/mojom/cookie_manager.mojom index b4f8389801..2007032e64 100644 --- a/services/network/public/mojom/cookie_manager.mojom +++ b/services/network/public/mojom/cookie_manager.mojom @@ -445,21 +445,4 @@ interface CookieManager { // the caller with a callback when settings have been updated. SetStorageAccessGrantSettings( array settings) => (); - - [Enable_if=is_ohos, Sync] SetCanonicalCookieSync( - CanonicalCookie cookie, url.mojom.Url source_url, - CookieOptions cookie_options) - => (CookieAccessResult access_result); - - [Enable_if=is_ohos, Sync] GetCookieListSync(url.mojom.Url url, - CookieOptions cookie_options, - CookiePartitionKeyCollection cookie_partition_key_collection) - => (array cookies, - array excluded_cookies); - - [Enable_if=is_ohos, Sync] DeleteCookiesSync(CookieDeletionFilter filter) - => (uint32 num_deleted); - - [Enable_if=is_ohos, Sync] GetAllCookiesSync() - => (array cookies); }; diff --git a/services/viz/public/mojom/compositing/compositor_frame_sink.mojom b/services/viz/public/mojom/compositing/compositor_frame_sink.mojom index 74d06bf8b8..8a950134ef 100644 --- a/services/viz/public/mojom/compositing/compositor_frame_sink.mojom +++ b/services/viz/public/mojom/compositing/compositor_frame_sink.mojom @@ -99,11 +99,6 @@ interface CompositorFrameSink { // adjust performance to allow power saving. [EnableIf=is_android] SetThreadIds(array thread_ids); - - // Report the key threads in render process. This is used on OHOS to - // dynamic resource scheduling. - [EnableIf=is_ohos] - ReportKeyThreadIds(array thread_ids, int32 process_id, bool is_created); }; interface CompositorFrameSinkClient { diff --git a/ui/events/blink/blink_event_util.cc b/ui/events/blink/blink_event_util.cc index c8d09d3634..606e915934 100644 --- a/ui/events/blink/blink_event_util.cc +++ b/ui/events/blink/blink_event_util.cc @@ -374,7 +374,7 @@ WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details, gesture.data.long_press.height = IfNanUseMaxFloat(details.bounding_box_f().height()); break; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ET_GESTURE_DRAG_LONG_PRESS: gesture.SetType(WebInputEvent::Type::kGestureDragLongPress); gesture.data.long_press.width = @@ -576,7 +576,7 @@ std::unique_ptr TranslateAndScaleWebInputEvent( break; case blink::WebInputEvent::Type::kGestureLongPress: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case blink::WebInputEvent::Type::kGestureDragLongPress: #endif case blink::WebInputEvent::Type::kGestureLongTap: diff --git a/ui/events/devices/device_data_manager.cc b/ui/events/devices/device_data_manager.cc index 56d8f4a769..1ad55b3501 100644 --- a/ui/events/devices/device_data_manager.cc +++ b/ui/events/devices/device_data_manager.cc @@ -9,7 +9,6 @@ #include "base/at_exit.h" #include "base/bind.h" #include "base/check_op.h" -#include "base/location.h" #include "ui/display/types/display_constants.h" #include "ui/events/devices/input_device_event_observer.h" #include "ui/events/devices/touch_device_transform.h" @@ -18,15 +17,13 @@ #if BUILDFLAG(IS_OHOS) #include "base/logging.h" -#include "base/task/single_thread_task_runner.h" -#include "base/task/thread_pool.h" #endif // This macro provides the implementation for the observer notification methods. -#define NOTIFY_OBSERVERS(method_decl, observer_call) \ - void DeviceDataManager::method_decl { \ - for (InputDeviceEventObserver & observer : observers_) \ - observer.observer_call; \ +#define NOTIFY_OBSERVERS(method_decl, observer_call) \ + void DeviceDataManager::method_decl { \ + for (InputDeviceEventObserver& observer : observers_) \ + observer.observer_call; \ } namespace ui { @@ -44,69 +41,38 @@ constexpr uint32_t TAG_TOUCHPAD_TYPE = (1 << 3); const std::string CHANGED_TYPE = "change"; class MMIListenerAdapterImpl : public OHOS::NWeb::MMIListenerAdapter { - public: - MMIListenerAdapterImpl( - const scoped_refptr& sequenced_task_runner) - : mmi_adapter_( - OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateMMIAdapter()), - sequenced_task_runner_(sequenced_task_runner) {} - ~MMIListenerAdapterImpl() override = default; - - void OnDeviceAdded(int32_t deviceId, const std::string& type) override { +public: + MMIListenerAdapterImpl() = default; + ~MMIListenerAdapterImpl() = default; + + void OnDeviceAdded(int32_t deviceId, const std::string &type) override { if (!ui::DeviceDataManager::HasInstance()) { return; } - mmi_adapter_->GetDeviceInfo( - deviceId, [sequenced_task_runner = sequenced_task_runner_]( - const OHOS::NWeb::MMIDeviceInfoAdapter& info) { - if (!sequenced_task_runner) { - LOG(ERROR) << "OnDeviceAdded sequenced_task_runner is null"; - return; - } - sequenced_task_runner->PostTask( - FROM_HERE, - base::BindOnce( - [](const OHOS::NWeb::MMIDeviceInfoAdapter& info) { - ui::InputDevice device( - info.id, ui::InputDeviceType::INPUT_DEVICE_USB, - info.name); - if (info.type & TAG_MOUSE_TYPE) { - ui::DeviceDataManager::GetInstance()->AddMouseDevice( - device); - } - if (info.type & TAG_TOUCHPAD_TYPE) { - ui::DeviceDataManager::GetInstance()->AddTouchpadDevice( - device); - } - if (info.type & TAG_KEYBOARD_TYPE) { - ui::DeviceDataManager::GetInstance()->AddKeyboardDevice( - device); - } - }, - info)); - }); + mmi_adapter_->GetDeviceInfo(deviceId, [](const OHOS::NWeb::MMIDeviceInfoAdapter& info) { + if (info.type & TAG_MOUSE_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + ui::DeviceDataManager::GetInstance()->AddMouseDevice(device); + } + if (info.type & TAG_TOUCHPAD_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + ui::DeviceDataManager::GetInstance()->AddTouchpadDevice(device); + } + if (info.type & TAG_KEYBOARD_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + ui::DeviceDataManager::GetInstance()->AddKeyboardDevice(device); + } + }); } - void OnDeviceRemoved(int32_t deviceId, const std::string& type) override { + void OnDeviceRemoved(int32_t deviceId, const std::string &type) override { if (ui::DeviceDataManager::HasInstance()) { - if (!sequenced_task_runner_) { - LOG(ERROR) << "OnDeviceRemoved sequenced_task_runner is null"; - return; - } - sequenced_task_runner_->PostTask( - FROM_HERE, - base::BindOnce( - [](int32_t deviceId) { - ui::InputDevice device( - deviceId, ui::InputDeviceType::INPUT_DEVICE_USB, ""); - ui::DeviceDataManager::GetInstance()->DeleteDevice(device); - }, - deviceId)); + ui::InputDevice device(deviceId, ui::InputDeviceType::INPUT_DEVICE_USB, ""); + ui::DeviceDataManager::GetInstance()->DeleteDevice(device); } } - private: - std::unique_ptr mmi_adapter_; - scoped_refptr sequenced_task_runner_; +private: + std::unique_ptr mmi_adapter_ = OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateMMIAdapter(); }; #endif } // namespace @@ -114,53 +80,37 @@ class MMIListenerAdapterImpl : public OHOS::NWeb::MMIListenerAdapter { // static DeviceDataManager* DeviceDataManager::instance_ = nullptr; -DeviceDataManager::DeviceDataManager() - : sequenced_task_runner_(base::ThreadPool::CreateSequencedTaskRunner({})) { +DeviceDataManager::DeviceDataManager() { DCHECK(!instance_); instance_ = this; #if BUILDFLAG(IS_OHOS) - mmi_adapter_ = - OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateMMIAdapter(); + mmi_adapter_ = OHOS::NWeb::OhosAdapterHelper::GetInstance().CreateMMIAdapter(); if (mmi_adapter_ == nullptr) { LOG(ERROR) << "DeviceDataManager mmi_adapter_ is nullptr"; return; } - dev_listener_ = - std::make_shared(sequenced_task_runner_); + dev_listener_ = std::make_shared(); mmi_adapter_->RegisterDevListener(CHANGED_TYPE, dev_listener_); std::vector device_ids; - mmi_adapter_->GetDeviceIds( - [&device_ids](std::vector& ids) { device_ids = ids; }); + mmi_adapter_->GetDeviceIds([&device_ids](std::vector& ids) { + device_ids = ids; + }); for (auto id : device_ids) { - mmi_adapter_->GetDeviceInfo( - id, [this](const OHOS::NWeb::MMIDeviceInfoAdapter& info) { - if (!this->sequenced_task_runner_) { - LOG(ERROR) - << "DeviceDataManager ctor sequenced_task_runner is null"; - return; - } - - this->sequenced_task_runner_->PostTask( - FROM_HERE, base::BindOnce( - [](const OHOS::NWeb::MMIDeviceInfoAdapter& info, - DeviceDataManager* device_data_manager) { - ui::InputDevice device( - info.id, - ui::InputDeviceType::INPUT_DEVICE_USB, - info.name); - if (info.type & TAG_MOUSE_TYPE) { - device_data_manager->AddMouseDevice(device); - } - if (info.type & TAG_TOUCHPAD_TYPE) { - device_data_manager->AddTouchpadDevice(device); - } - if (info.type & TAG_KEYBOARD_TYPE) { - device_data_manager->AddKeyboardDevice(device); - } - }, - info, base::Unretained(this))); - }); + mmi_adapter_->GetDeviceInfo(id, [this](const OHOS::NWeb::MMIDeviceInfoAdapter& info) { + if (info.type & TAG_MOUSE_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + this->AddMouseDevice(device); + } + if (info.type & TAG_TOUCHPAD_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + this->AddTouchpadDevice(device); + } + if (info.type & TAG_KEYBOARD_TYPE) { + ui::InputDevice device(info.id, ui::InputDeviceType::INPUT_DEVICE_USB, info.name); + this->AddKeyboardDevice(device); + } + }); } #endif } @@ -309,7 +259,9 @@ int64_t DeviceDataManager::GetTargetDisplayForTouchDevice( void DeviceDataManager::OnTouchscreenDevicesUpdated( const std::vector& devices) { if (devices.size() == touchscreen_devices_.size() && - std::equal(devices.begin(), devices.end(), touchscreen_devices_.begin(), + std::equal(devices.begin(), + devices.end(), + touchscreen_devices_.begin(), InputDeviceEquals)) { return; } @@ -326,7 +278,9 @@ void DeviceDataManager::OnTouchscreenDevicesUpdated( void DeviceDataManager::OnKeyboardDevicesUpdated( const std::vector& devices) { if (devices.size() == keyboard_devices_.size() && - std::equal(devices.begin(), devices.end(), keyboard_devices_.begin(), + std::equal(devices.begin(), + devices.end(), + keyboard_devices_.begin(), InputDeviceEquals)) { return; } @@ -337,7 +291,9 @@ void DeviceDataManager::OnKeyboardDevicesUpdated( void DeviceDataManager::OnMouseDevicesUpdated( const std::vector& devices) { if (devices.size() == mouse_devices_.size() && - std::equal(devices.begin(), devices.end(), mouse_devices_.begin(), + std::equal(devices.begin(), + devices.end(), + mouse_devices_.begin(), InputDeviceEquals)) { return; } @@ -348,7 +304,9 @@ void DeviceDataManager::OnMouseDevicesUpdated( void DeviceDataManager::OnTouchpadDevicesUpdated( const std::vector& devices) { if (devices.size() == touchpad_devices_.size() && - std::equal(devices.begin(), devices.end(), touchpad_devices_.begin(), + std::equal(devices.begin(), + devices.end(), + touchpad_devices_.begin(), InputDeviceEquals)) { return; } @@ -358,8 +316,7 @@ void DeviceDataManager::OnTouchpadDevicesUpdated( #if BUILDFLAG(IS_OHOS) void DeviceDataManager::AddKeyboardDevice(const InputDevice& device) { - for (auto item = keyboard_devices_.begin(); item != keyboard_devices_.end(); - ++item) { + for (auto item = keyboard_devices_.begin(); item != keyboard_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { return; } @@ -370,8 +327,7 @@ void DeviceDataManager::AddKeyboardDevice(const InputDevice& device) { } void DeviceDataManager::AddMouseDevice(const InputDevice& device) { - for (auto item = mouse_devices_.begin(); item != mouse_devices_.end(); - ++item) { + for (auto item = mouse_devices_.begin(); item != mouse_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { return; } @@ -382,8 +338,7 @@ void DeviceDataManager::AddMouseDevice(const InputDevice& device) { } void DeviceDataManager::AddTouchpadDevice(const InputDevice& device) { - for (auto item = touchpad_devices_.begin(); item != touchpad_devices_.end(); - ++item) { + for (auto item = touchpad_devices_.begin(); item != touchpad_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { return; } @@ -394,8 +349,7 @@ void DeviceDataManager::AddTouchpadDevice(const InputDevice& device) { } void DeviceDataManager::DeleteDevice(const InputDevice& device) { - for (auto item = mouse_devices_.begin(); item != mouse_devices_.end(); - ++item) { + for (auto item = mouse_devices_.begin(); item != mouse_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { mouse_devices_.erase(item); LOG(DEBUG) << "DeviceDataManager remove mouse device id: " << device.id; @@ -403,22 +357,18 @@ void DeviceDataManager::DeleteDevice(const InputDevice& device) { break; } } - for (auto item = touchpad_devices_.begin(); item != touchpad_devices_.end(); - ++item) { + for (auto item = touchpad_devices_.begin(); item != touchpad_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { touchpad_devices_.erase(item); - LOG(DEBUG) << "DeviceDataManager remove touchpad device id: " - << device.id; + LOG(DEBUG) << "DeviceDataManager remove touchpad device id: " << device.id; NotifyObserversTouchpadDeviceConfigurationChanged(); break; } } - for (auto item = keyboard_devices_.begin(); item != keyboard_devices_.end(); - ++item) { + for (auto item = keyboard_devices_.begin(); item != keyboard_devices_.end(); ++item) { if (InputDeviceEquals(*item, device)) { keyboard_devices_.erase(item); - LOG(DEBUG) << "DeviceDataManager remove keyboard device id: " - << device.id; + LOG(DEBUG) << "DeviceDataManager remove keyboard device id: " << device.id; NotifyObserversKeyboardDeviceConfigurationChanged(); return; } diff --git a/ui/events/devices/device_data_manager.h b/ui/events/devices/device_data_manager.h index d19a51b7f2..136f3123cd 100644 --- a/ui/events/devices/device_data_manager.h +++ b/ui/events/devices/device_data_manager.h @@ -143,7 +143,6 @@ class EVENTS_DEVICES_EXPORT DeviceDataManager #if BUILDFLAG(IS_OHOS) std::unique_ptr mmi_adapter_ = nullptr; std::shared_ptr dev_listener_ = nullptr; - scoped_refptr sequenced_task_runner_; #endif }; diff --git a/ui/events/event.cc b/ui/events/event.cc index 64ed9da258..75b3ca857f 100644 --- a/ui/events/event.cc +++ b/ui/events/event.cc @@ -69,7 +69,7 @@ SourceEventType EventTypeToLatencySourceEventType(EventType type) { case ET_GESTURE_PINCH_END: case ET_GESTURE_PINCH_UPDATE: case ET_GESTURE_LONG_PRESS: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ET_GESTURE_DRAG_LONG_PRESS: #endif case ET_GESTURE_LONG_TAP: diff --git a/ui/events/event_utils.cc b/ui/events/event_utils.cc index 547b64c3d6..3ce4073586 100644 --- a/ui/events/event_utils.cc +++ b/ui/events/event_utils.cc @@ -255,7 +255,7 @@ base::StringPiece EventTypeName(EventType type) { CASE_TYPE(ET_GESTURE_PINCH_END); CASE_TYPE(ET_GESTURE_PINCH_UPDATE); CASE_TYPE(ET_GESTURE_LONG_PRESS); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP CASE_TYPE(ET_GESTURE_DRAG_LONG_PRESS); #endif CASE_TYPE(ET_GESTURE_LONG_TAP); diff --git a/ui/events/gesture_detection/filtered_gesture_provider.cc b/ui/events/gesture_detection/filtered_gesture_provider.cc index 63ecda4617..f80858b70d 100644 --- a/ui/events/gesture_detection/filtered_gesture_provider.cc +++ b/ui/events/gesture_detection/filtered_gesture_provider.cc @@ -73,7 +73,7 @@ void FilteredGestureProvider::SendSynthesizedEndEvents() { gesture_provider_->SendSynthesizedEndEvents(); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void FilteredGestureProvider::ResetDetection(bool is_lost_focus) { gesture_provider_->ResetDetection(is_lost_focus); } diff --git a/ui/events/gesture_detection/filtered_gesture_provider.h b/ui/events/gesture_detection/filtered_gesture_provider.h index 5e83156710..053c635d45 100644 --- a/ui/events/gesture_detection/filtered_gesture_provider.h +++ b/ui/events/gesture_detection/filtered_gesture_provider.h @@ -57,7 +57,7 @@ class GESTURE_DETECTION_EXPORT FilteredGestureProvider final // Synthesizes and propagates gesture end events. void SendSynthesizedEndEvents(); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void ResetDetection(bool is_lost_focus); #endif diff --git a/ui/events/gesture_detection/gesture_configuration.cc b/ui/events/gesture_detection/gesture_configuration.cc index 164c8cc8cc..d1dd8d667b 100644 --- a/ui/events/gesture_detection/gesture_configuration.cc +++ b/ui/events/gesture_detection/gesture_configuration.cc @@ -33,7 +33,7 @@ GestureConfiguration::GestureConfiguration() stylus_scale_enabled_(false), gesture_begin_end_types_enabled_(false), long_press_time_in_ms_(500), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP drag_long_press_time_in_ms_(1500), #endif max_distance_between_taps_for_double_tap_(20), diff --git a/ui/events/gesture_detection/gesture_configuration.h b/ui/events/gesture_detection/gesture_configuration.h index e55d223405..9d4b9c2ff1 100644 --- a/ui/events/gesture_detection/gesture_configuration.h +++ b/ui/events/gesture_detection/gesture_configuration.h @@ -63,7 +63,7 @@ class GESTURE_DETECTION_EXPORT GestureConfiguration { } int long_press_time_in_ms() const { return long_press_time_in_ms_; } void set_long_press_time_in_ms(int val) { long_press_time_in_ms_ = val; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP int drag_long_press_time_in_ms() const { return drag_long_press_time_in_ms_; } void set_drag_long_press_time_in_ms(int val) { drag_long_press_time_in_ms_ = val; @@ -230,7 +230,7 @@ class GESTURE_DETECTION_EXPORT GestureConfiguration { bool stylus_scale_enabled_; bool gesture_begin_end_types_enabled_; int long_press_time_in_ms_; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP int drag_long_press_time_in_ms_; #endif float max_distance_between_taps_for_double_tap_; diff --git a/ui/events/gesture_detection/gesture_configuration_android.cc b/ui/events/gesture_detection/gesture_configuration_android.cc index f886453f61..4f7089a3c2 100644 --- a/ui/events/gesture_detection/gesture_configuration_android.cc +++ b/ui/events/gesture_detection/gesture_configuration_android.cc @@ -47,7 +47,7 @@ class GestureConfigurationAndroid : public GestureConfiguration { set_gesture_begin_end_types_enabled(false); #endif set_long_press_time_in_ms(ViewConfiguration::GetLongPressTimeoutInMs()); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP set_drag_long_press_time_in_ms( ViewConfiguration::GetLongPressTimeoutInMs() + 600); #endif diff --git a/ui/events/gesture_detection/gesture_detector.cc b/ui/events/gesture_detection/gesture_detector.cc index c55862a8db..61aaaac109 100644 --- a/ui/events/gesture_detection/gesture_detector.cc +++ b/ui/events/gesture_detection/gesture_detector.cc @@ -31,7 +31,7 @@ enum TimeoutEvent { SHOW_PRESS = 0, LONG_PRESS, TAP, -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP DRAG_LONG_PRESS, #endif TIMEOUT_EVENT_COUNT @@ -44,7 +44,7 @@ enum TimeoutEvent { // values without explicitly consulting an OWNER. GestureDetector::Config::Config() : longpress_timeout(base::Milliseconds(500)), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP draglongpress_timeout(base::Milliseconds(1500)), #endif showpress_timeout(base::Milliseconds(180)), @@ -93,7 +93,7 @@ class GestureDetector::TimeoutGestureHandler { timeout_callbacks_[TAP] = &GestureDetector::OnTapTimeout; timeout_delays_[TAP] = config.double_tap_timeout; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP timeout_callbacks_[DRAG_LONG_PRESS] = &GestureDetector::OnDragLongPressTimeout; timeout_delays_[DRAG_LONG_PRESS] = @@ -103,7 +103,7 @@ class GestureDetector::TimeoutGestureHandler { timeout_timers_[SHOW_PRESS].SetTaskRunner(config.task_runner); timeout_timers_[LONG_PRESS].SetTaskRunner(config.task_runner); timeout_timers_[TAP].SetTaskRunner(config.task_runner); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP timeout_timers_[DRAG_LONG_PRESS].SetTaskRunner(config.task_runner); #endif } @@ -121,7 +121,7 @@ class GestureDetector::TimeoutGestureHandler { void StopTimeout(TimeoutEvent event) { timeout_timers_[event].Stop(); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void Stop(bool is_lost_focus) { for (size_t i = SHOW_PRESS; i < TIMEOUT_EVENT_COUNT; ++i) { // The longpress show contextmeu on UI will trigger focus changed and @@ -186,7 +186,7 @@ GestureDetector::GestureDetector( stylus_button_accelerated_longpress_enabled_(false), deep_press_accelerated_longpress_enabled_(false), longpress_enabled_(true), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP draglongpress_enabled_(true), #endif showpress_enabled_(true), @@ -238,7 +238,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, down_focus_y_ = last_focus_y_ = focus_y; // Cancel long press and taps. CancelTaps(); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP timeout_handler_->StopTimeout(DRAG_LONG_PRESS); #endif maximum_pointer_count_ = std::max(maximum_pointer_count_, @@ -348,7 +348,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, timeout_handler_->StartTimeout(SHOW_PRESS); if (longpress_enabled_) timeout_handler_->StartTimeout(LONG_PRESS); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP if (draglongpress_enabled_) timeout_handler_->StartTimeout(DRAG_LONG_PRESS); #endif @@ -404,7 +404,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, // feature is enabled, because MetalayerMode is also activated by a // stylus button press and has precedence over this press acceleration // feature. -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP ActivateLongPressKeepDragTimeout(ev); #else ActivateLongPressGesture(ev); @@ -478,7 +478,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, defer_confirm_single_tap_ = false; timeout_handler_->StopTimeout(SHOW_PRESS); timeout_handler_->StopTimeout(LONG_PRESS); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP timeout_handler_->StopTimeout(DRAG_LONG_PRESS); #endif } @@ -486,7 +486,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, break; case MotionEvent::Action::CANCEL: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP Cancel(ev.IsCancelByLostFocus()); #else Cancel(); @@ -496,7 +496,7 @@ bool GestureDetector::OnTouchEvent(const MotionEvent& ev, return handled; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void GestureDetector::Cancel(bool is_lost_focus) { // Stop waiting for a second tap and send a GESTURE_TAP_CANCEL to keep the // gesture stream valid. @@ -584,14 +584,14 @@ void GestureDetector::OnShowPressTimeout() { } void GestureDetector::OnLongPressTimeout() { -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP ActivateLongPressKeepDragTimeout(*current_down_event_); #else ActivateLongPressGesture(*current_down_event_); #endif } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void GestureDetector::OnDragLongPressTimeout() { LOG(ERROR) << "DragDrop GestureDetector::OnDragLongPressTimeout"; listener_->OnDragLongPress(*current_down_event_); @@ -614,7 +614,7 @@ void GestureDetector::ActivateLongPressGesture(const MotionEvent& ev) { defer_confirm_single_tap_ = false; listener_->OnLongPress(ev); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void GestureDetector::ActivateLongPressKeepDragTimeout(const MotionEvent& ev) { timeout_handler_->Stop(true); defer_confirm_single_tap_ = false; @@ -633,7 +633,7 @@ void GestureDetector::Cancel() { still_down_ = false; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void GestureDetector::StopDragLongPressGesture() { timeout_handler_->StopTimeout(DRAG_LONG_PRESS); } diff --git a/ui/events/gesture_detection/gesture_detector.h b/ui/events/gesture_detection/gesture_detector.h index ef5d18c4b3..deafa939d4 100644 --- a/ui/events/gesture_detection/gesture_detector.h +++ b/ui/events/gesture_detection/gesture_detector.h @@ -30,7 +30,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector { ~Config(); base::TimeDelta longpress_timeout; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP base::TimeDelta draglongpress_timeout; #endif base::TimeDelta showpress_timeout; @@ -119,7 +119,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector { void set_longpress_enabled(bool enabled) { longpress_enabled_ = enabled; } void set_showpress_enabled(bool enabled) { showpress_enabled_ = enabled; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void set_draglongpress_enabled(bool enabled) { draglongpress_enabled_ = enabled; } @@ -138,7 +138,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector { void Init(const Config& config); void OnShowPressTimeout(); void OnLongPressTimeout(); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void OnDragLongPressTimeout(); void Cancel(bool is_lost_focus); void CancelTaps(bool is_lost_focus); @@ -209,7 +209,7 @@ class GESTURE_DETECTION_EXPORT GestureDetector { bool stylus_button_accelerated_longpress_enabled_; bool deep_press_accelerated_longpress_enabled_; bool longpress_enabled_; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP bool draglongpress_enabled_; #endif bool showpress_enabled_; diff --git a/ui/events/gesture_detection/gesture_listeners.cc b/ui/events/gesture_detection/gesture_listeners.cc index e5114296f6..1705e48cd5 100644 --- a/ui/events/gesture_detection/gesture_listeners.cc +++ b/ui/events/gesture_detection/gesture_listeners.cc @@ -21,7 +21,7 @@ bool SimpleGestureListener::OnSingleTapUp(const MotionEvent& e, void SimpleGestureListener::OnLongPress(const MotionEvent& e) { } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void SimpleGestureListener::OnDragLongPress(const MotionEvent& e) { } #endif diff --git a/ui/events/gesture_detection/gesture_listeners.h b/ui/events/gesture_detection/gesture_listeners.h index 444e0295c4..7be9e9a11a 100644 --- a/ui/events/gesture_detection/gesture_listeners.h +++ b/ui/events/gesture_detection/gesture_listeners.h @@ -7,8 +7,6 @@ #include "ui/events/gesture_detection/gesture_detection_export.h" -#include "build/build_config.h" - namespace ui { class MotionEvent; @@ -21,7 +19,7 @@ class GESTURE_DETECTION_EXPORT GestureListener { virtual void OnShowPress(const MotionEvent& e) = 0; virtual bool OnSingleTapUp(const MotionEvent& e, int tap_count) = 0; virtual void OnLongPress(const MotionEvent& e) = 0; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP virtual void OnDragLongPress(const MotionEvent& e) = 0; #endif virtual bool OnScroll(const MotionEvent& e1, @@ -64,7 +62,7 @@ class GESTURE_DETECTION_EXPORT SimpleGestureListener void OnShowPress(const MotionEvent& e) override; bool OnSingleTapUp(const MotionEvent& e, int tap_count) override; void OnLongPress(const MotionEvent& e) override; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void OnDragLongPress(const MotionEvent& e) override; #endif bool OnScroll(const MotionEvent& e1, diff --git a/ui/events/gesture_detection/gesture_provider.cc b/ui/events/gesture_detection/gesture_provider.cc index 48906acaca..0fd2c2321b 100644 --- a/ui/events/gesture_detection/gesture_provider.cc +++ b/ui/events/gesture_detection/gesture_provider.cc @@ -22,7 +22,7 @@ #include "ui/events/types/event_type.h" #include "ui/gfx/geometry/point_f.h" #include "ui/gfx/geometry/vector2d_f.h" -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP #include "base/logging.h" #endif @@ -182,7 +182,7 @@ class GestureProvider::GestureListenerImpl : public ScaleGestureListener, DCHECK(!IsScaleGestureDetectionInProgress()); current_longpress_time_ = gesture.time; break; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ET_GESTURE_DRAG_LONG_PRESS: DCHECK(!IsScaleGestureDetectionInProgress()); current_longpress_time_ = gesture.time; @@ -236,7 +236,7 @@ class GestureProvider::GestureListenerImpl : public ScaleGestureListener, gesture.type() == ET_GESTURE_SHOW_PRESS || gesture.type() == ET_GESTURE_TAP_CANCEL || gesture.type() == ET_GESTURE_BEGIN || - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP gesture.type() == ET_GESTURE_DRAG_LONG_PRESS || #endif gesture.type() == ET_GESTURE_END); @@ -623,7 +623,7 @@ class GestureProvider::GestureListenerImpl : public ScaleGestureListener, Send(CreateGesture(long_press_details, e)); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void OnDragLongPress(const MotionEvent& e) override { LOG(INFO) << "DragDrop GestureDetector::OnDragLongPress "; DCHECK(!IsDoubleTapInProgress()); @@ -910,7 +910,7 @@ bool GestureProvider::OnTouchEvent(const MotionEvent& event) { // gesture where the UP is not dispatched to content. uma_histogram_.RecordTouchEvent(event); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP if (event.GetAction() == MotionEvent::Action::UP) { gesture_listener_->StopDragLongPressGesture(); } @@ -923,7 +923,7 @@ bool GestureProvider::OnTouchEvent(const MotionEvent& event) { OnTouchEventHandlingEnd(event); return true; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void GestureProvider::ResetDetection(bool is_lost_focus) { MotionEventGeneric generic_cancel_event( MotionEvent::Action::CANCEL, base::TimeTicks::Now(), PointerProperties(), diff --git a/ui/events/gesture_detection/gesture_provider.h b/ui/events/gesture_detection/gesture_provider.h index 614eae189a..04ad24c9b6 100644 --- a/ui/events/gesture_detection/gesture_provider.h +++ b/ui/events/gesture_detection/gesture_provider.h @@ -69,7 +69,7 @@ class GESTURE_DETECTION_EXPORT GestureProvider { // be handled. bool OnTouchEvent(const MotionEvent& event); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void ResetDetection(bool is_lost_focus); #endif diff --git a/ui/events/gesture_detection/gesture_provider_config_helper.cc b/ui/events/gesture_detection/gesture_provider_config_helper.cc index 08fe8353a5..b434dd9159 100644 --- a/ui/events/gesture_detection/gesture_provider_config_helper.cc +++ b/ui/events/gesture_detection/gesture_provider_config_helper.cc @@ -26,7 +26,7 @@ GestureDetector::Config BuildGestureDetectorConfig( GestureDetector::Config config; config.longpress_timeout = base::Milliseconds(gesture_config.long_press_time_in_ms()); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP config.draglongpress_timeout = base::Milliseconds( gesture_config.drag_long_press_time_in_ms()); #endif diff --git a/ui/events/gesture_detection/gesture_provider_unittest.cc b/ui/events/gesture_detection/gesture_provider_unittest.cc index a6ac6ccf44..04f98a96e5 100644 --- a/ui/events/gesture_detection/gesture_provider_unittest.cc +++ b/ui/events/gesture_detection/gesture_provider_unittest.cc @@ -55,9 +55,9 @@ GestureProvider::Config CreateDefaultConfig() { sConfig.gesture_detector_config.double_tap_timeout = kOneMicrosecond * 4; sConfig.gesture_detector_config.double_tap_min_time = kOneMicrosecond * 2; - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP sConfig.gesture_detector_config.draglongpress_timeout = kOneSecond; - #endif //BUILDFLAG(IS_OHOS) + #endif //OHOS_ENABLE_DRAG_DROP return sConfig; } @@ -169,7 +169,7 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient { gestures_.clear(); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void ResetGestureDetection(bool is_lost_focus) { gesture_provider_->ResetDetection(is_lost_focus); gestures_.clear(); @@ -241,11 +241,11 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient { return GetDefaultConfig().gesture_detector_config.longpress_timeout; } - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP base::TimeDelta GetDragLongpressTimeout() const { return GetDefaultConfig().gesture_detector_config.draglongpress_timeout; } - #endif //BUILDFLAG(IS_OHOS) + #endif //OHOS_ENABLE_DRAG_DROP base::TimeDelta GetShowPressTimeout() const { return GetDefaultConfig().gesture_detector_config.showpress_timeout; @@ -309,13 +309,13 @@ class GestureProviderTest : public testing::Test, public GestureProviderClient { SetUpWithConfig(config); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP void SetDragLongPressTimeout(base::TimeDelta draglongpress_timeout) { GestureProvider::Config config = GetDefaultConfig(); config.gesture_detector_config.longpress_timeout = draglongpress_timeout; SetUpWithConfig(config); } -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP void SetSingleTapRepeatInterval(int repeat_interval) { GestureProvider::Config config = GetDefaultConfig(); @@ -3492,7 +3492,7 @@ TEST_F(GestureProviderTest, MaxDragDistanceHistogramsWithDrag) { histograms_tester.ExpectTotalCount("Event.MaxDragDistance.STYLUS", 0); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP //Verify that DRAGLONGPRES is triggered after LONG_PRESS event. TEST_F(GestureProviderTest, GestureDragLongpressCreateDetection) { base::TimeTicks event_time = base::TimeTicks::Now(); @@ -3555,6 +3555,6 @@ TEST_F(GestureProviderTest, GesutreDragLongpressCancelAndReset) { RunTasksAndWait(drag_long_press_timeout); EXPECT_FALSE(HasReceivedGesture(ET_GESTURE_DRAG_LONG_PRESS)); } -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP } // namespace ui \ No newline at end of file diff --git a/ui/events/gesture_detection/gesture_touch_uma_histogram.cc b/ui/events/gesture_detection/gesture_touch_uma_histogram.cc index 3005310691..73e06750bc 100644 --- a/ui/events/gesture_detection/gesture_touch_uma_histogram.cc +++ b/ui/events/gesture_detection/gesture_touch_uma_histogram.cc @@ -119,10 +119,10 @@ UMAEventType GestureTouchUMAHistogram::UMAEventTypeFromEvent( } case ET_GESTURE_LONG_PRESS: return UMA_ET_GESTURE_LONG_PRESS; -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ET_GESTURE_DRAG_LONG_PRESS: return UMA_ET_GESTURE_DRAG_LONG_PRESS; -#endif //BUILDFLAG(IS_OHOS) +#endif //OHOS_ENABLE_DRAG_DROP case ET_GESTURE_LONG_TAP: return UMA_ET_GESTURE_LONG_TAP; case ET_GESTURE_SWIPE: { diff --git a/ui/events/gesture_detection/gesture_touch_uma_histogram.h b/ui/events/gesture_detection/gesture_touch_uma_histogram.h index bc03e7cf1b..f614ea079d 100644 --- a/ui/events/gesture_detection/gesture_touch_uma_histogram.h +++ b/ui/events/gesture_detection/gesture_touch_uma_histogram.h @@ -55,7 +55,9 @@ enum UMAEventType { // update the UIEventType enum in tools/metrics/histograms/histograms.xml // accordingly. + //#ifdef OHOS_ENABLE_DRAG_DROP UMA_ET_GESTURE_DRAG_LONG_PRESS = 37, + //#endif UMA_ET_COUNT }; diff --git a/ui/events/gesture_detection/motion_event.cc b/ui/events/gesture_detection/motion_event.cc index 7e62bfbdd2..f1812fc599 100644 --- a/ui/events/gesture_detection/motion_event.cc +++ b/ui/events/gesture_detection/motion_event.cc @@ -75,7 +75,7 @@ std::ostream& operator<<(std::ostream& stream, return stream << static_cast(tool_type); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP bool MotionEvent::IsCancelByLostFocus() const { return false; } diff --git a/ui/events/gesture_detection/motion_event.h b/ui/events/gesture_detection/motion_event.h index cdccf57486..1544a63575 100644 --- a/ui/events/gesture_detection/motion_event.h +++ b/ui/events/gesture_detection/motion_event.h @@ -115,7 +115,7 @@ class GESTURE_DETECTION_EXPORT MotionEvent { float GetTouchMajor() const { return GetTouchMajor(0); } float GetTouchMinor() const { return GetTouchMinor(0); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP virtual bool IsCancelByLostFocus() const; virtual void SetCancelByLostFocus(bool is_lost_focus); #endif diff --git a/ui/events/gesture_detection/motion_event_generic.cc b/ui/events/gesture_detection/motion_event_generic.cc index ea1b247977..e89b40c9c9 100644 --- a/ui/events/gesture_detection/motion_event_generic.cc +++ b/ui/events/gesture_detection/motion_event_generic.cc @@ -90,7 +90,7 @@ void PointerProperties::SetAxesAndOrientation(float radius_x, } } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP MotionEventGeneric::MotionEventGeneric(Action action, base::TimeTicks event_time, const PointerProperties& pointer, @@ -114,7 +114,7 @@ MotionEventGeneric::MotionEventGeneric(Action action, unique_event_id_(ui::GetNextTouchEventId()), action_index_(0), button_state_(0), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP flags_(0), cancel_by_lost_focus_(false) { #else @@ -130,7 +130,7 @@ MotionEventGeneric::MotionEventGeneric(const MotionEventGeneric& other) action_index_(other.action_index_), button_state_(other.button_state_), flags_(other.flags_), -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP pointers_(other.pointers_), cancel_by_lost_focus_(false) { #else @@ -375,7 +375,7 @@ void MotionEventGeneric::PopPointer() { pointers_->pop_back(); } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP bool MotionEventGeneric::IsCancelByLostFocus() const { return cancel_by_lost_focus_; } diff --git a/ui/events/gesture_detection/motion_event_generic.h b/ui/events/gesture_detection/motion_event_generic.h index 93de179240..7eecb713cb 100644 --- a/ui/events/gesture_detection/motion_event_generic.h +++ b/ui/events/gesture_detection/motion_event_generic.h @@ -48,7 +48,7 @@ struct GESTURE_DETECTION_EXPORT PointerProperties { // A generic MotionEvent implementation. class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent { public: - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP MotionEventGeneric(Action action, base::TimeTicks event_time, const PointerProperties& pointer, @@ -121,7 +121,7 @@ class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent { const MotionEvent& event); static std::unique_ptr CancelEvent( const MotionEvent& event); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP bool IsCancelByLostFocus() const override; void SetCancelByLostFocus(bool is_lost_focus) override; #endif @@ -144,7 +144,7 @@ class GESTURE_DETECTION_EXPORT MotionEventGeneric : public MotionEvent { int flags_; base::StackVector pointers_; std::vector> historical_events_; - #ifdef BUILDFLAG(IS_OHOS) + #ifdef OHOS_ENABLE_DRAG_DROP bool cancel_by_lost_focus_; #endif diff --git a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc index 695908fdbb..3d7990f3dc 100644 --- a/ui/events/gesture_detection/touch_disposition_gesture_filter.cc +++ b/ui/events/gesture_detection/touch_disposition_gesture_filter.cc @@ -80,7 +80,7 @@ DispositionHandlingInfo GetDispositionHandlingInfo(EventType type) { return Info(RT_START); case ET_GESTURE_LONG_PRESS: return Info(RT_START); -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ET_GESTURE_DRAG_LONG_PRESS: return Info(RT_START); #endif diff --git a/ui/events/types/event_type.h b/ui/events/types/event_type.h index 90ba8f8659..e19aa15f17 100644 --- a/ui/events/types/event_type.h +++ b/ui/events/types/event_type.h @@ -46,7 +46,7 @@ enum EventType { ET_GESTURE_PINCH_END, ET_GESTURE_PINCH_UPDATE, ET_GESTURE_LONG_PRESS, -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP ET_GESTURE_DRAG_LONG_PRESS, #endif ET_GESTURE_LONG_TAP, diff --git a/ui/views/animation/ink_drop_event_handler.cc b/ui/views/animation/ink_drop_event_handler.cc index 032adb0b11..1165dba47f 100644 --- a/ui/views/animation/ink_drop_event_handler.cc +++ b/ui/views/animation/ink_drop_event_handler.cc @@ -80,7 +80,7 @@ void InkDropEventHandler::OnGestureEvent(ui::GestureEvent* event) { event->SetHandled(); break; case ui::ET_GESTURE_LONG_PRESS: -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP case ui::ET_GESTURE_DRAG_LONG_PRESS: #endif if (current_ink_drop_state == InkDropState::ACTIVATED) diff --git a/ui/views/controls/scrollbar/scroll_bar.cc b/ui/views/controls/scrollbar/scroll_bar.cc index fb9b50e9f1..d49772ea70 100644 --- a/ui/views/controls/scrollbar/scroll_bar.cc +++ b/ui/views/controls/scrollbar/scroll_bar.cc @@ -139,7 +139,7 @@ void ScrollBar::OnGestureEvent(ui::GestureEvent* event) { return; } -#ifdef BUILDFLAG(IS_OHOS) +#ifdef OHOS_ENABLE_DRAG_DROP if (event->type() == ui::ET_GESTURE_DRAG_LONG_PRESS) { // For a long-press, the repeater started in tap-down should continue. So // return early. -- Gitee From f1d6d73c98fcb6bda241e85f65d79e7f911f574e Mon Sep 17 00:00:00 2001 From: zourongchun Date: Thu, 14 Sep 2023 20:10:44 +0800 Subject: [PATCH 2/2] fix patch Signed-off-by: zourongchun Change-Id: I74aff94b41da30f4de15bf780f846b113f6ec681 --- .../browsing_data/browsing_data_remover_impl_unittest.cc | 2 +- content/browser/storage_partition_impl_unittest.cc | 2 +- ui/display/win/screen_win_unittest.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/content/browser/browsing_data/browsing_data_remover_impl_unittest.cc b/content/browser/browsing_data/browsing_data_remover_impl_unittest.cc index 75f9309e65..132c5742c7 100644 --- a/content/browser/browsing_data/browsing_data_remover_impl_unittest.cc +++ b/content/browser/browsing_data/browsing_data_remover_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright 2017 The Chromium Authors. All rights reserved. +// Copyright 2017 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. diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc index eac7f4d453..fedf2cd7c8 100644 --- a/content/browser/storage_partition_impl_unittest.cc +++ b/content/browser/storage_partition_impl_unittest.cc @@ -1,4 +1,4 @@ -// Copyright 2013 The Chromium Authors. All rights reserved. +// Copyright 2013 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. diff --git a/ui/display/win/screen_win_unittest.cc b/ui/display/win/screen_win_unittest.cc index ea12f4a4c5..c000b43f41 100644 --- a/ui/display/win/screen_win_unittest.cc +++ b/ui/display/win/screen_win_unittest.cc @@ -1,4 +1,4 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. +// 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. -- Gitee