[M108 Migration][API] Bring up autofill 23/287123/11
authorv-saha <v.saha@samsung.com>
Fri, 20 Jan 2023 06:28:15 +0000 (11:58 +0530)
committerBot Blink <blinkbot@samsung.com>
Mon, 30 Jan 2023 15:51:22 +0000 (15:51 +0000)
This patch migrates Autofill feature base code.

References:
https://review.tizen.org/gerrit/273586
https://review.tizen.org/gerrit/282263

Change-Id: Ie0dd8d81050e78dc812a8b6059aa2f6d795f8173
Signed-off-by: v-saha <v.saha@samsung.com>
Signed-off-by: Ayush Kumar <ayush.k123@samsung.com>
59 files changed:
components/autofill/core/browser/BUILD.gn
components/autofill/core/browser/personal_data_manager.cc
components/autofill/core/common/autofill_switches.cc
components/autofill/core/common/autofill_switches.h
components/password_manager/core/browser/BUILD.gn
content/browser/renderer_host/render_process_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.cc
content/browser/renderer_host/render_widget_host_impl.h
content/browser/renderer_host/render_widget_host_view_aura.cc
content/browser/renderer_host/render_widget_host_view_aura.h
content/browser/renderer_host/render_widget_host_view_base.h
content/public/browser/content_browser_client.h
content/public/browser/web_contents_delegate.h
third_party/blink/public/mojom/widget/platform_widget.mojom
third_party/blink/renderer/core/frame/web_frame_widget_impl.cc
third_party/blink/renderer/core/frame/web_frame_widget_impl.h
third_party/blink/renderer/platform/widget/widget_base.cc
third_party/blink/renderer/platform/widget/widget_base.h
third_party/blink/renderer/platform/widget/widget_base_client.h
tizen_src/build/config/BUILD.gn
tizen_src/build/config/tizen_features.gni
tizen_src/chromium_impl/content/browser/browser_efl.gni
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.cc
tizen_src/chromium_impl/content/browser/renderer_host/rwhv_aura_offscreen_helper_efl.h
tizen_src/ewk/efl_integration/BUILD.gn
tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.h [new file with mode: 0644]
tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.cc
tizen_src/ewk/efl_integration/browser/autofill/autofill_client_efl.h
tizen_src/ewk/efl_integration/browser/autofill/personal_data_manager_factory.cc
tizen_src/ewk/efl_integration/browser/autofill/personal_data_manager_factory.h
tizen_src/ewk/efl_integration/browser/autofill_popup_view_efl.cc
tizen_src/ewk/efl_integration/browser/autofill_popup_view_efl.h
tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.cc [new file with mode: 0644]
tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.h [new file with mode: 0644]
tizen_src/ewk/efl_integration/browser/password_manager/password_manager_client_efl.cc
tizen_src/ewk/efl_integration/browser/password_manager/password_manager_client_efl.h
tizen_src/ewk/efl_integration/browser/password_manager/password_store_factory.cc
tizen_src/ewk/efl_integration/browser/password_manager/password_store_factory.h
tizen_src/ewk/efl_integration/browser/webdata/web_data_service.cc
tizen_src/ewk/efl_integration/browser/webdata/web_data_service.h
tizen_src/ewk/efl_integration/browser/webdata/web_data_service_factory.cc
tizen_src/ewk/efl_integration/browser/webdata/web_data_service_factory.h
tizen_src/ewk/efl_integration/browser_context_efl.cc
tizen_src/ewk/efl_integration/command_line_efl.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.cc
tizen_src/ewk/efl_integration/content_browser_client_efl.h
tizen_src/ewk/efl_integration/eweb_context.cc
tizen_src/ewk/efl_integration/eweb_context.h
tizen_src/ewk/efl_integration/private/ewk_context_form_autofill_profile_private.cc
tizen_src/ewk/efl_integration/private/ewk_context_private.cc
tizen_src/ewk/efl_integration/private/ewk_context_private.h
tizen_src/ewk/efl_integration/public/ewk_context.cc
tizen_src/ewk/efl_integration/renderer/content_renderer_client_efl.cc
tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.cc
tizen_src/ewk/efl_integration/renderer/render_frame_observer_efl.h
tizen_src/ewk/efl_integration/web_contents_delegate_efl.cc
tizen_src/ewk/efl_integration/web_contents_delegate_efl.h
ui/base/resource/resource_bundle.cc

index 3181e98..444cae5 100644 (file)
@@ -595,6 +595,13 @@ static_library("browser") {
       "//ui/native_theme:native_theme_browser",
     ]
   }
+
+  if (use_efl) {
+    sources += [
+      "logging/stub_log_manager.cc",
+      "logging/stub_log_manager.h",
+    ]
+  }
 }
 
 if (is_android) {
index 2482bb5..b056cd0 100644 (file)
@@ -1033,7 +1033,13 @@ void PersonalDataManager::AddOfferDataForTest(
 void PersonalDataManager::
     RemoveAutofillProfileByGUIDAndBlankCreditCardReference(
         const std::string& guid) {
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  // TODO(djmix.kim) : This is a temporary solution for tct.
+  // It will be removed after integrating autofill_profile_validator_factory.
+  database_helper_->GetLocalDatabase()->RemoveAutofillProfile(guid);
+#else
   RemoveProfileFromDB(guid);
+#endif
 
   // Reset the billing_address_id of any card that refered to this profile.
   for (CreditCard* credit_card : GetCreditCards()) {
index e0558df..7c76ec8 100644 (file)
@@ -35,5 +35,9 @@ const char kShowAutofillSignatures[] = "show-autofill-signatures";
 // Use the sandbox Online Wallet service URL (for developer testing).
 const char kWalletServiceUseSandbox[] = "wallet-service-use-sandbox";
 
+#if BUILDFLAG(IS_EFL)
+const char kDisableAutofill[] = "disable-autofill";
+#endif
+
 }  // namespace switches
 }  // namespace autofill
index cdcea30..2e5cf7c 100644 (file)
@@ -20,6 +20,13 @@ extern const char kShowAutofillTypePredictions[];
 extern const char kShowAutofillSignatures[];
 extern const char kWalletServiceUseSandbox[];
 
+// As of today TIZEN_AUTOFILL_SUPPORT is restricted to
+// tizen_src/ewk/efl_integration only. Move this switch under
+// TIZEN_AUTOFILL_SUPPORT when possible.
+#if BUILDFLAG(IS_EFL)
+extern const char kDisableAutofill[];
+#endif
+
 }  // namespace switches
 }  // namespace autofill
 
index d1d8246..a5ebbf8 100644 (file)
@@ -12,7 +12,7 @@ if (is_android) {
 
 config("password_reuse_detection_config") {
   defines = []
-  if (!is_ios) {
+  if (!is_ios && !use_efl) {
     defines += [ "ON_FOCUS_PING_ENABLED" ]
   }
 }
@@ -399,6 +399,12 @@ static_library("browser") {
       "password_store_signin_notifier_impl.h",
     ]
   }
+  if (use_efl) {
+    sources += [
+      "stub_credentials_filter.cc",
+      "stub_credentials_filter.h",
+    ]
+  }
 }
 
 source_set("capabilities") {
index 8fa72fe..e2ff206 100644 (file)
 #include "url/gurl.h"
 #include "url/origin.h"
 
+#if BUILDFLAG(IS_EFL)
+#include "components/autofill/core/common/autofill_switches.h"
+#endif
+
 #if BUILDFLAG(IS_ANDROID)
 #include "base/android/child_process_binding_types.h"
 #include "content/browser/android/java_interfaces_impl.h"
@@ -3432,6 +3436,9 @@ void RenderProcessHostImpl::PropagateBrowserCommandLineToRenderer(
     switches::kLacrosUseChromeosProtectedMedia,
     switches::kLacrosUseChromeosProtectedAv1,
 #endif
+#if BUILDFLAG(IS_EFL)
+    autofill::switches::kDisableAutofill,
+#endif
   };
   renderer_cmd->CopySwitchesFrom(browser_cmd, kSwitchNames,
                                  std::size(kSwitchNames));
index e12f71f..bb004e7 100644 (file)
@@ -988,6 +988,18 @@ void RenderWidgetHostImpl::OnGetContentSnapshot(int request_id,
     return;
   view_->DidGetContentSnapshot(bitmap, request_id);
 }
+
+void RenderWidgetHostImpl::UpdateFocusedNodeBounds() {
+  blink_widget_->UpdateFocusedNodeBounds(
+      base::BindOnce(&RenderWidgetHostImpl::OnGetFocusedNodeBounds,
+                     weak_factory_.GetWeakPtr()));
+}
+
+void RenderWidgetHostImpl::OnGetFocusedNodeBounds(const gfx::RectF& rect) {
+  if (!view_)
+    return;
+  view_->OnGetFocusedNodeBounds(rect);
+}
 #endif
 
 blink::VisualProperties RenderWidgetHostImpl::GetInitialVisualProperties() {
index aa77594..9e17ce7 100644 (file)
@@ -444,6 +444,8 @@ class CONTENT_EXPORT RenderWidgetHostImpl
                               float page_scale_factor,
                               int request_id);
   void OnGetContentSnapshot(int request_id, const SkBitmap& bitmap);
+  void UpdateFocusedNodeBounds();
+  void OnGetFocusedNodeBounds(const gfx::RectF& rect);
 #endif
 
   // Returns true if the RenderWidget is hidden.
index 366c8a7..ff3614d 100644 (file)
@@ -817,6 +817,13 @@ bool RenderWidgetHostViewAura::IsMouseLocked() {
 }
 
 gfx::Size RenderWidgetHostViewAura::GetVisibleViewportSize() {
+#if BUILDFLAG(IS_EFL)
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          switches::kEnableOffscreenRendering) &&
+      offscreen_helper_) {
+    return offscreen_helper_->GetVisibleViewportSize();
+  }
+#endif
   gfx::Rect requested_rect(GetRequestedRendererSize());
   requested_rect.Inset(insets_);
   return requested_rect.size();
@@ -2244,6 +2251,13 @@ void RenderWidgetHostViewAura::OnRenderFrameMetadataChangedAfterActivation(
   }
 }
 
+#if BUILDFLAG(IS_EFL)
+void RenderWidgetHostViewAura::OnGetFocusedNodeBounds(const gfx::RectF& rect) {
+  if (offscreen_helper_)
+    offscreen_helper_->OnGetFocusedNodeBounds(rect);
+}
+#endif
+
 ////////////////////////////////////////////////////////////////////////////////
 // RenderWidgetHostViewAura, private:
 
index cacda97..ddf75f1 100644 (file)
@@ -425,6 +425,7 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
                         size_t offset,
                         const gfx::Range& range) override;
   void TextInputStateChanged(const ui::mojom::TextInputState& params) override;
+  void OnGetFocusedNodeBounds(const gfx::RectF& rect) override;
 #endif
 
  protected:
index 0207afa..5de160f 100644 (file)
@@ -280,6 +280,7 @@ class CONTENT_EXPORT RenderWidgetHostViewBase : public RenderWidgetHostView {
   virtual void DidHandleKeyEvent(blink::WebInputEvent::Type input_event,
                                  bool processed) {}
   virtual void DidGetContentSnapshot(const SkBitmap& bitmap, int request_id) {}
+  virtual void OnGetFocusedNodeBounds(const gfx::RectF&) {}
 #endif
 
   // This method will reset the fallback to the first surface after navigation.
index 9b6c2b8..26d9551 100644 (file)
@@ -1242,6 +1242,16 @@ class CONTENT_EXPORT ContentBrowserClient {
       RenderFrameHost& render_frame_host,
       blink::AssociatedInterfaceRegistry& associated_registry);
 
+#if BUILDFLAG(IS_EFL)
+  // Content was unable to bind a receiver for this associated interface, so the
+  // embedder should try. Returns true if the |handle| was actually taken and
+  // bound; false otherwise.
+  virtual bool BindAssociatedReceiverFromFrame(
+      RenderFrameHost* render_frame_host,
+      const std::string& interface_name,
+      mojo::ScopedInterfaceEndpointHandle* handle);
+#endif
+
   // Handles an unhandled incoming interface binding request from the GPU
   // process. Called on the IO thread.
   virtual void BindGpuHostReceiver(mojo::GenericPendingReceiver receiver) {}
index d31f0a8..71eb7b4 100644 (file)
@@ -512,6 +512,8 @@ class CONTENT_EXPORT WebContentsDelegate {
 
 #if BUILDFLAG(IS_EFL)
   virtual void DidRenderFrame() {}
+  virtual void OnDidChangeFocusedNodeBounds(
+      const gfx::RectF& focused_node_bounds) {}
 #endif
 
 #if BUILDFLAG(IS_ANDROID)
index 4dfb64b..428275c 100644 (file)
@@ -114,6 +114,9 @@ interface Widget {
   GetContentSnapshot(gfx.mojom.Rect snapshot_rect, float page_scale_factor)
       => (skia.mojom.BitmapN32? bitmap);
 
+  [EnableIf=is_efl]
+  UpdateFocusedNodeBounds() => (gfx.mojom.RectF rect);
+
   // Informs the widget that it was hidden. This allows it to reduce its
   // resource utilization, and will cancel any pending
   // RecordContentToVisibleTimeRequest that was set with WasShown or
index db9d088..9737478 100644 (file)
@@ -4153,6 +4153,21 @@ void WebFrameWidgetImpl::GetContentSnapshot(const gfx::Rect& snapshot_rect,
       page_scale_factor * snapshot->width(),
       page_scale_factor * snapshot->height());
 }
+
+gfx::RectF WebFrameWidgetImpl::UpdateFocusedNodeBounds() {
+  Element* element = FocusedElement();
+  if (!element)
+    return gfx::RectF();
+
+  WebElement web_element = WebElement(element);
+
+  if (!web_element.IsNull() && web_element.IsElementNode()) {
+    gfx::RectF focused_node_bounds_scaled = gfx::ScaleRect(
+        gfx::RectF(web_element.BoundsInWidget()), View()->PageScaleFactor());
+    return focused_node_bounds_scaled;
+  }
+  return gfx::RectF();
+}
 #endif
 
 void WebFrameWidgetImpl::OrientationChanged() {
index 57c0357..cffaa63 100644 (file)
@@ -706,6 +706,8 @@ class CORE_EXPORT WebFrameWidgetImpl
   void GetContentSnapshot(const gfx::Rect& snapshot_rect,
                           float page_scale_factor,
                           SkBitmap* snapshot) override;
+
+  gfx::RectF UpdateFocusedNodeBounds() override;
 #endif
   void OrientationChanged() override;
   void DidUpdateSurfaceAndScreen(
index d2fca1a..59a7ed3 100644 (file)
@@ -463,6 +463,11 @@ void WidgetBase::GetContentSnapshot(const gfx::Rect& snapshot_rect,
                               &content_snapshot);
   std::move(callback).Run(content_snapshot);
 }
+
+void WidgetBase::UpdateFocusedNodeBounds(
+    UpdateFocusedNodeBoundsCallback callback) {
+  std::move(callback).Run(client_->UpdateFocusedNodeBounds());
+}
 #endif
 
 void WidgetBase::WasHidden() {
index 1ba4b68..e175340 100644 (file)
@@ -140,6 +140,9 @@ class PLATFORM_EXPORT WidgetBase : public mojom::blink::Widget,
   void GetContentSnapshot(const gfx::Rect& snapshot_rect,
                           float page_scale_factor,
                           GetContentSnapshotCallback callback) override;
+
+  void UpdateFocusedNodeBounds(
+      UpdateFocusedNodeBoundsCallback callback) override;
 #endif
   void WasHidden() override;
   void WasShown(bool was_evicted,
index d952389..7fc0466 100644 (file)
@@ -173,6 +173,8 @@ class WidgetBaseClient {
   virtual void GetContentSnapshot(const gfx::Rect& snapshot_rect,
                                   float page_scale_factor,
                                   SkBitmap* snapshot) {}
+
+  virtual gfx::RectF UpdateFocusedNodeBounds() { return gfx::RectF(); }
 #endif
 
   // Convert screen coordinates to device emulated coordinates (scaled
index c8ad9c5..fd06c45 100644 (file)
@@ -54,6 +54,9 @@ config("tizen_feature_flags") {
     if (tizen_multimedia) {
       defines += [ "TIZEN_MULTIMEDIA" ]
     }
+    if (tizen_autofill_support) {
+      defines += [ "TIZEN_AUTOFILL_SUPPORT" ]
+    }
     if (use_ttrace) {
       defines += [ "USE_TTRACE" ]
       if (use_ttrace_chrome_trace) {
index de32d58..f8df89b 100644 (file)
@@ -50,6 +50,14 @@ declare_args() {
   tizen_multimedia = false
   tizen_tbm_support = false
   tizen_web_speech_recognition = false
+
+  tizen_autofill_support = false
+}
+
+if (tizen_product_tv) {
+  tizen_autofill_support = false
+} else {
+  tizen_autofill_support = true
 }
 
 if (use_ttrace) {
index 260330f..5338162 100644 (file)
@@ -70,6 +70,7 @@ if (tizen_web_speech_recognition) {
 ##############################################################################
 
 external_content_browser_efl_deps = [
+  "//components/autofill/core/common",
   "//tizen_src/chromium_impl/edje_resources:edje_resources_efl",
   "//tizen_src/chromium_impl/efl:window-factory",
   "//ui/gl:gl",
index edf0ed4..97a72d5 100644 (file)
@@ -1095,9 +1095,10 @@ const gfx::Size RWHVAuraOffscreenHelperEfl::GetScrollableSize() const {
   if (scaled_contents_size_.width() > viewport_size.width()) {
     width = scaled_contents_size_.width() - viewport_size.width();
     // When device scale factor is larger than 1.0, content size is ceiled up
-    // during converting pixel to dip in RenderWidgetHostViewEfl::GetViewBounds.
-    // So we ignore when scroll size is 1. It is also same for height.
-    // Please refer to https://review.tizen.org/gerrit/#/c/74044/.
+    // during converting pixel to dip in
+    // RWHVAuraOffscreenHelperEfl::GetViewBounds. So we ignore when
+    // scroll size is 1. It is also same for height. Please refer to
+    // https://review.tizen.org/gerrit/#/c/74044/.
     if (device_scale_factor_ > 1.0f && width == 1)
       width = 0;
   }
@@ -1110,4 +1111,9 @@ const gfx::Size RWHVAuraOffscreenHelperEfl::GetScrollableSize() const {
   return gfx::Size(width, height);
 }
 
+void RWHVAuraOffscreenHelperEfl::OnGetFocusedNodeBounds(
+    const gfx::RectF& rect) {
+  web_contents_->GetDelegate()->OnDidChangeFocusedNodeBounds(rect);
+}
+
 }  // namespace content
index 1f24974..5bba8fb 100644 (file)
@@ -66,6 +66,8 @@ class CONTENT_EXPORT RWHVAuraOffscreenHelperEfl {
   gfx::Rect GetViewBounds();
   void SetCustomViewportSize(const gfx::Size& size);
   gfx::Size GetPhysicalBackingSize() const;
+  void OnGetFocusedNodeBounds(const gfx::RectF& rect);
+
   gfx::Rect GetViewBoundsInPix() const;
   const gfx::Size GetScrollableSize() const;
   void SetScaledContentSize(const gfx::SizeF& size) {
index feee814..d5e87fb 100755 (executable)
@@ -6,10 +6,6 @@ import("//base/allocator/allocator.gni")
 import("//build/config/features.gni")
 import("//printing/buildflags/buildflags.gni")
 
-# [M48_2564] Temporary disabling the flag for switching to new chromium
-#            FIXME: http://web.sec.samsung.net/bugzilla/show_bug.cgi?id=15382
-tizen_autofill_support = false
-
 # Components used to auto generate CHROMIUM_VERSION preprocessor define.
 version_file = "//chrome/VERSION"
 version_script = "//build/util/version.py"
@@ -155,10 +151,6 @@ shared_library("chromium-ewk") {
     public_configs += [ "../../build:capi-system-device-public" ]
   }
 
-  if (tizen_autofill_support) {
-    defines = [ "TIZEN_AUTOFILL_SUPPORT=true" ]
-  }
-
   if (use_allocator == "tcmalloc") {
     deps += [ "//base/allocator" ]
   }
@@ -293,6 +285,8 @@ shared_library("chromium-ewk") {
     "web_contents_view_delegate_ewk.h",
 
     # Make use of Android webview"s simplified pref class.
+    "browser/autofill/autocomplete_history_manager_factory.cc",
+    "browser/autofill/autocomplete_history_manager_factory.h",
     "browser/autofill/autofill_client_efl.cc",
     "browser/autofill/autofill_client_efl.h",
     "browser/autofill/personal_data_manager_factory.cc",
@@ -325,6 +319,8 @@ shared_library("chromium-ewk") {
     "browser/notification/notification_controller_efl.h",
     "browser/notification/notification_helper.cc",
     "browser/notification/notification_helper.h",
+    "browser/password_manager/password_helper_efl.cc",
+    "browser/password_manager/password_helper_efl.h",
     "browser/password_manager/password_manager_client_efl.cc",
     "browser/password_manager/password_manager_client_efl.h",
     "browser/password_manager/password_store_factory.cc",
diff --git a/tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.cc b/tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.cc
new file mode 100644 (file)
index 0000000..692b5d1
--- /dev/null
@@ -0,0 +1,66 @@
+// Copyright 2020 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+
+#include "browser/autofill/autocomplete_history_manager_factory.h"
+
+#include "browser/webdata/web_data_service_factory.h"
+#include "components/autofill/core/browser/autocomplete_history_manager.h"
+#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
+#include "components/user_prefs/user_prefs.h"
+#include "content/public/browser/browser_context.h"
+
+namespace autofill {
+
+// static
+AutocompleteHistoryManagerFactoryEfl*
+AutocompleteHistoryManagerFactoryEfl::GetInstance() {
+  return base::Singleton<AutocompleteHistoryManagerFactoryEfl>::get();
+}
+
+void AutocompleteHistoryManagerFactoryEfl::AutocompleteHistoryManagerAdd(
+    content::BrowserContext* ctx) {
+  DCHECK(ctx);
+
+  if (!ctx)
+    return;
+
+  uint64_t uniqueId = reinterpret_cast<uint64_t>(ctx);
+  auto* mgr = autocomplete_history_manager_id_map_.Lookup(uniqueId);
+  if (!mgr) {
+    mgr = new AutocompleteHistoryManager();
+    scoped_refptr<AutofillWebDataService> autofill_webdata_service =
+        WebDataServiceFactoryEfl::GetInstance()->GetAutofillWebDataForProfile();
+    mgr->Init(autofill_webdata_service, user_prefs::UserPrefs::Get(ctx),
+              ctx->IsOffTheRecord());
+
+    autocomplete_history_manager_id_map_.AddWithID(mgr, uniqueId);
+  }
+}
+
+void AutocompleteHistoryManagerFactoryEfl::AutocompleteHistoryManagerRemove(
+    content::BrowserContext* ctx) {
+  uint64_t uniqueId = reinterpret_cast<uint64_t>(ctx);
+  autocomplete_history_manager_id_map_.Remove(uniqueId);
+}
+
+AutocompleteHistoryManager*
+AutocompleteHistoryManagerFactoryEfl::AutocompleteHistoryManagerForContext(
+    content::BrowserContext* ctx) {
+  uint64_t uniqueId = reinterpret_cast<uint64_t>(ctx);
+  return autocomplete_history_manager_id_map_.Lookup(uniqueId);
+}
+
+AutocompleteHistoryManagerFactoryEfl::AutocompleteHistoryManagerFactoryEfl() {}
+
+AutocompleteHistoryManagerFactoryEfl::~AutocompleteHistoryManagerFactoryEfl() {
+  if (!autocomplete_history_manager_id_map_.IsEmpty())
+    LOG(ERROR) << "Client didn't destroy all WebView objects"
+               << " before calling ewk_shutdown";
+}
+
+}  // namespace autofill
+
+#endif  // TIZEN_AUTOFILL_SUPPORT
diff --git a/tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.h b/tizen_src/ewk/efl_integration/browser/autofill/autocomplete_history_manager_factory.h
new file mode 100644 (file)
index 0000000..e9c381b
--- /dev/null
@@ -0,0 +1,53 @@
+// Copyright 2020 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_FACTORY_H_
+#define AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_FACTORY_H_
+
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+#include "base/compiler_specific.h"
+#include "base/containers/id_map.h"
+#include "base/memory/ref_counted.h"
+#include "base/memory/singleton.h"
+
+namespace base {
+template <typename T>
+struct DefaultSingletonTraits;
+}
+
+namespace content {
+class BrowserContext;
+}
+
+namespace autofill {
+
+class AutocompleteHistoryManager;
+
+class AutocompleteHistoryManagerFactoryEfl {
+ public:
+  static AutocompleteHistoryManagerFactoryEfl* GetInstance();
+
+  void AutocompleteHistoryManagerAdd(content::BrowserContext* ctx);
+  void AutocompleteHistoryManagerRemove(content::BrowserContext* ctx);
+  AutocompleteHistoryManager* AutocompleteHistoryManagerForContext(
+      content::BrowserContext* ctx);
+
+ private:
+  friend struct base::DefaultSingletonTraits<
+      AutocompleteHistoryManagerFactoryEfl>;
+
+  AutocompleteHistoryManagerFactoryEfl();
+  ~AutocompleteHistoryManagerFactoryEfl();
+
+  AutocompleteHistoryManagerFactoryEfl(
+      const AutocompleteHistoryManagerFactoryEfl&) = delete;
+  AutocompleteHistoryManagerFactoryEfl& operator=(
+      const AutocompleteHistoryManagerFactoryEfl&) = delete;
+
+  base::IDMap<AutocompleteHistoryManager*> autocomplete_history_manager_id_map_;
+};
+
+}  // namespace autofill
+#endif  // TIZEN_AUTOFILL_SUPPORT
+#endif  // AUTOFILL_AUTOCOMPLETE_HISTORY_MANAGER_FACTORY_H_
index 63fc5a8..5252edf 100644 (file)
@@ -7,34 +7,35 @@
 #include "browser/autofill/autofill_client_efl.h"
 
 #include "base/logging.h"
-#include "base/prefs/pref_service.h"
 #include "base/strings/utf_string_conversions.h"
+#include "browser/autofill/autocomplete_history_manager_factory.h"
 #include "browser/autofill/personal_data_manager_factory.h"
-#include "browser/webdata/web_data_service_factory.h"
 #include "browser/password_manager/password_manager_client_efl.h"
-#include "components/autofill/content/common/autofill_messages.h"
-#include "components/autofill/core/common/autofill_pref_names.h"
+#include "browser_context_efl.h"
+#include "common/render_messages_ewk.h"
+#include "components/autofill/content/browser/content_autofill_driver.h"
+#include "components/autofill/content/browser/content_autofill_driver_factory.h"
 #include "components/autofill/core/browser/autofill_client.h"
-#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
-#include "components/password_manager/core/browser/password_generation_manager.h"
+#include "components/autofill/core/common/autofill_prefs.h"
+#include "components/prefs/pref_service.h"
 #include "components/user_prefs/user_prefs.h"
-#include "content/public/browser/render_view_host.h"
+#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
 #include "content/public/browser/browser_thread.h"
+#include "content/public/browser/render_view_host.h"
+#include "content/public/browser/ssl_status.h"
+#include "private/ewk_context_private.h"
 #include "tizen/system_info.h"
+#include "ui/display/screen.h"
+#include "ui/gfx/geometry/dip_util.h"
 #include "ui/gfx/geometry/rect.h"
-#include "private/ewk_context_private.h"
-
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::AutofillClientEfl);
-
 
 namespace autofill {
 
 AutofillClientEfl::AutofillClientEfl(content::WebContents* web_contents)
-    : content::WebContentsObserver(web_contents)
-    , web_contents_(web_contents)
-    , webview_(NULL)
-    , database_(WebDataServiceFactory::GetInstance()->GetAutofillWebDataForProfile())
-    , popup_controller_(NULL) {
+    : content::WebContentsObserver(web_contents),
+      content::WebContentsUserData<AutofillClientEfl>(*web_contents),
+      web_contents_(web_contents) {
   DCHECK(web_contents);
 }
 
@@ -44,17 +45,13 @@ AutofillClientEfl::~AutofillClientEfl() {
   popup_controller_ = NULL;
 }
 
-void AutofillClientEfl::TabActivated() {
-  NOTIMPLEMENTED();
-}
-
 PersonalDataManager* AutofillClientEfl::GetPersonalDataManager() {
   if (webview_ && webview_->context()) {
     content::BrowserContextEfl* ctx =
         webview_->context()->GetImpl()->browser_context();
 
-    PersonalDataManagerFactory* factory =
-        PersonalDataManagerFactory::GetInstance();
+    PersonalDataManagerFactoryEfl* factory =
+        PersonalDataManagerFactoryEfl::GetInstance();
 
     return factory->PersonalDataManagerForContext(ctx);
   }
@@ -62,11 +59,17 @@ PersonalDataManager* AutofillClientEfl::GetPersonalDataManager() {
   return NULL;
 }
 
-scoped_refptr<AutofillWebDataService> AutofillClientEfl::GetDatabase() {
-  return database_;
+PrefService* AutofillClientEfl::GetPrefs() {
+  if (webview_ && webview_->context()) {
+    content::BrowserContextEfl* ctx =
+        webview_->context()->GetImpl()->browser_context();
+    return user_prefs::UserPrefs::Get(ctx);
+  }
+
+  return NULL;
 }
 
-PrefService* AutofillClientEfl::GetPrefs() {
+const PrefService* AutofillClientEfl::GetPrefs() const {
   if (webview_ && webview_->context()) {
     content::BrowserContextEfl* ctx =
         webview_->context()->GetImpl()->browser_context();
@@ -76,74 +79,60 @@ PrefService* AutofillClientEfl::GetPrefs() {
   return NULL;
 }
 
-void AutofillClientEfl::ShowAutofillSettings() {
+syncer::SyncService* AutofillClientEfl::GetSyncService() {
   NOTIMPLEMENTED();
+  return nullptr;
 }
 
-void AutofillClientEfl::ConfirmSaveCreditCardLocally(
-    const base::Closure& callback) {
+void AutofillClientEfl::ShowAutofillSettings(bool show_credit_card_settings) {
   NOTIMPLEMENTED();
 }
 
-void AutofillClientEfl::ConfirmSaveCreditCardToCloud(
-    const base::Closure& callback,
-    scoped_ptr<base::DictionaryValue> legal_message) {
+void AutofillClientEfl::ConfirmSaveCreditCardLocally(
+    const CreditCard& card,
+    SaveCreditCardOptions options,
+    LocalSaveCardPromptCallback callback) {
   NOTIMPLEMENTED();
 }
 
-void AutofillClientEfl::LoadRiskData(
-    const base::OnceCallback<void(const std::string&)>& callback) {
+void AutofillClientEfl::ConfirmSaveCreditCardToCloud(
+    const CreditCard& card,
+    const LegalMessageLines& legal_message_lines,
+    SaveCreditCardOptions options,
+    UploadSaveCardPromptCallback callback) {
   NOTIMPLEMENTED();
 }
 
-void AutofillClientEfl::ShowRequestAutocompleteDialog(
-    const autofill::FormData& form,
-    content::RenderFrameHost* rfh,
-    const ResultCallback& callback) {
-  HideRequestAutocompleteDialog();
+void AutofillClientEfl::ConfirmCreditCardFillAssist(
+    const CreditCard& card,
+    base::OnceClosure callback) {
   NOTIMPLEMENTED();
 }
 
 void AutofillClientEfl::ShowAutofillPopup(
-    const gfx::RectF& element_bounds,
-    base::i18n::TextDirection text_direction,
-    const std::vector<autofill::Suggestion>& suggestions,
+    const PopupOpenArgs& open_args,
     base::WeakPtr<autofill::AutofillPopupDelegate> delegate) {
   DCHECK(web_contents_);
   // Do not show sugestions when Remember form data is disabled
   if (!IsAutocompleteSavingEnabled())
     return;
-  int x, y;
-  double scale_factor = 1.0;
-
-  if (IsMobileProfile() || IsWearableProfile()) {
-    scale_factor = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().
-        device_scale_factor();
-  } else if (IsTvProfile()) {
-    scale_factor = webview_->GetScale();
-  }
-
-#if BUILDFLAG(IS_TIZEN)
-  evas_object_geometry_get(webview_->evas_object(), &x, &y, 0, 0);
-  gfx::Rect client_area = web_contents_->GetContainerBounds();
-  gfx::RectF element_bounds_in_screen_space = element_bounds +
-      client_area.OffsetFromOrigin() + gfx::Vector2d(x/scale_factor, y/scale_factor);
-#endif
 
   if (GetOrCreatePopupController()) {
-    popup_controller_->InitFormData(suggestions, delegate);
+    popup_controller_->InitFormData(open_args.suggestions, delegate);
 #if BUILDFLAG(IS_TIZEN)
-    popup_controller_->UpdateFormDataPopup(element_bounds_in_screen_space);
+    popup_controller_->UpdateFormDataPopup(
+        GetElementBoundsInScreen(open_args.element_bounds));
 #else
-    popup_controller_->UpdateFormDataPopup(element_bounds);
+    popup_controller_->UpdateFormDataPopup(open_args.element_bounds);
 #endif
     popup_controller_->Show();
   }
 }
 
 void AutofillClientEfl::ShowUnmaskPrompt(
-    const autofill::CreditCard& card,
-    base::WeakPtr<autofill::CardUnmaskDelegate> delegate) {
+    const CreditCard& card,
+    AutofillClient::UnmaskCardReason reason,
+    base::WeakPtr<CardUnmaskDelegate> delegate) {
   NOTIMPLEMENTED();
 }
 
@@ -161,40 +150,63 @@ bool AutofillClientEfl::HasCreditCardScanFeature() {
   return false;
 }
 
-void AutofillClientEfl::ScanCreditCard(
-    const CreditCardScanCallback& callback) {
+void AutofillClientEfl::ScanCreditCard(CreditCardScanCallback callback) {
   NOTIMPLEMENTED();
 }
 
-void AutofillClientEfl::OnFirstUserGestureObserved() {
-  web_contents_->SendToAllFrames(
-      new AutofillMsg_FirstUserGestureObservedInTab(routing_id()));
-}
-
-bool AutofillClientEfl::IsContextSecure(const GURL& form_origin) {
+bool AutofillClientEfl::IsContextSecure() const {
+  content::SSLStatus ssl_status;
   content::NavigationEntry* navigation_entry =
       web_contents_->GetController().GetLastCommittedEntry();
   if (!navigation_entry)
      return false;
 
-  content::SSLStatus ssl_status = navigation_entry->GetSSL();
+  ssl_status = navigation_entry->GetSSL();
   // Note: If changing the implementation below, also change
   // AwAutofillClient::IsContextSecure. See crbug.com/505388
-  return
-      ssl_status.security_style == content::SECURITY_STYLE_AUTHENTICATED &&
-      ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT;
+  return navigation_entry->GetURL().SchemeIsCryptographic() &&
+         ssl_status.certificate &&
+         (!net::IsCertStatusError(ssl_status.cert_status)) &&
+         !(ssl_status.content_status &
+           content::SSLStatus::RAN_INSECURE_CONTENT);
 }
 
-IdentityProvider* AutofillClientEfl::GetIdentityProvider() {
+signin::IdentityManager* AutofillClientEfl::GetIdentityManager() {
+  NOTIMPLEMENTED();
   return nullptr;
 }
 
-rappor::RapporService* AutofillClientEfl::GetRapporService() {
+ukm::UkmRecorder* AutofillClientEfl::GetUkmRecorder() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+ukm::SourceId AutofillClientEfl::GetUkmSourceId() {
+  NOTIMPLEMENTED();
+  return ukm::kInvalidSourceId;
+}
+
+AddressNormalizer* AutofillClientEfl::GetAddressNormalizer() {
   NOTIMPLEMENTED();
   return nullptr;
 }
 
-void AutofillClientEfl::HideAutofillPopup() {
+security_state::SecurityLevel
+AutofillClientEfl::GetSecurityLevelForUmaHistograms() {
+  NOTIMPLEMENTED();
+  return security_state::SecurityLevel::SECURITY_LEVEL_COUNT;
+}
+
+bool AutofillClientEfl::AreServerCardsSupported() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void AutofillClientEfl::ExecuteCommand(int id) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::HideAutofillPopup(PopupHidingReason reason) {
   if (popup_controller_) {
     popup_controller_->Hide();
   }
@@ -207,8 +219,8 @@ bool AutofillClientEfl::IsAutocompleteEnabled() {
 }
 
 void AutofillClientEfl::PropagateAutofillPredictions(
-    content::RenderFrameHost* rfh,
-    const std::vector<autofill::FormStructure*>& forms) {
+    autofill::AutofillDriver* autofill_driver,
+    const std::vector<FormStructure*>& forms) {
   NOTIMPLEMENTED();
 }
 
@@ -218,24 +230,68 @@ bool AutofillClientEfl::IsAutocompleteSavingEnabled() {
   return false;
 }
 
-void AutofillClientEfl::HideRequestAutocompleteDialog() {
-  if (popup_controller_) {
-    popup_controller_->Hide();
-  }
+FormDataImporter* AutofillClientEfl::GetFormDataImporter() {
+  NOTIMPLEMENTED();
+  return nullptr;
 }
 
-void AutofillClientEfl::DidNavigateMainFrame(const content::LoadCommittedDetails& details, const content::FrameNavigateParams& params) {
-  HideRequestAutocompleteDialog();
+StrikeDatabase* AutofillClientEfl::GetStrikeDatabase() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+void AutofillClientEfl::ShowLocalCardMigrationDialog(
+    base::OnceClosure show_migration_dialog_closure) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::ConfirmMigrateLocalCardToCloud(
+    std::unique_ptr<base::DictionaryValue> legal_message,
+    const std::string& user_email,
+    const std::vector<MigratableCreditCard>& migratable_credit_cards,
+    LocalCardMigrationCallback start_migrating_cards_callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::ShowLocalCardMigrationResults(
+    const bool has_server_error,
+    const std::u16string& tip_message,
+    const std::vector<MigratableCreditCard>& migratable_credit_cards,
+    MigrationDeleteCardCallback delete_local_card_callback) {
+  NOTIMPLEMENTED();
+}
+
+AutocompleteHistoryManager* AutofillClientEfl::GetAutocompleteHistoryManager() {
+  if (!webview_)
+    return nullptr;
+
+  content::BrowserContextEfl* ctx =
+      webview_->context()->GetImpl()->browser_context();
+  auto* factory = AutocompleteHistoryManagerFactoryEfl::GetInstance();
+  return factory->AutocompleteHistoryManagerForContext(ctx);
+}
+
+payments::PaymentsClient* AutofillClientEfl::GetPaymentsClient() {
+  NOTIMPLEMENTED();
+  return nullptr;
 }
 
 void AutofillClientEfl::ShowSavePasswordPopup(
-    scoped_ptr<password_manager::PasswordFormManager> form_to_save) {
+    std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save) {
   if (GetOrCreatePopupController())
-    popup_controller_->ShowSavePasswordPopup(form_to_save.Pass());
+    popup_controller_->ShowSavePasswordPopup(std::move(form_to_save));
+}
+
+void AutofillClientEfl::PrimaryMainFrameWasResized(bool width_changed) {
+  // Ignore virtual keyboard showing and hiding a strip of suggestions.
+  if (!width_changed)
+    return;
+
+  HideAutofillPopup(PopupHidingReason::kNavigation);
 }
 
 void AutofillClientEfl::WebContentsDestroyed() {
-  HideAutofillPopup();
+  HideAutofillPopup(PopupHidingReason::kViewDestroyed);
 }
 
 AutofillPopupViewEfl * AutofillClientEfl::GetOrCreatePopupController() {
@@ -250,6 +306,154 @@ void AutofillClientEfl::DidFillOrPreviewField(
   NOTIMPLEMENTED();
 }
 
+bool AutofillClientEfl::ShouldShowSigninPromo() {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void AutofillClientEfl::UpdateAutofillIfRequired() {
+  if (popup_controller_ && popup_controller_->IsVisible()) {
+    auto* rwhva = static_cast<content::RenderWidgetHostViewAura*>(
+        web_contents_->GetRenderWidgetHostView());
+    if (rwhva)
+      rwhva->host()->UpdateFocusedNodeBounds();
+  }
+}
+
+void AutofillClientEfl::DidChangeFocusedNodeBounds(
+    const gfx::RectF& node_bounds) {
+  if (popup_controller_)
+    popup_controller_->UpdateLocation(GetElementBoundsInScreen(node_bounds));
+}
+
+gfx::RectF AutofillClientEfl::GetElementBoundsInScreen(
+    const gfx::RectF& element_bounds) {
+  auto* rwhva = static_cast<content::RenderWidgetHostViewAura*>(
+      web_contents_->GetRenderWidgetHostView());
+  if (!rwhva)
+    return gfx::RectF();
+
+  double scale_factor = 1.0;
+  if (IsTvProfile()) {
+    scale_factor = webview_->GetScale();
+  } else {
+    scale_factor =
+        display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+  }
+
+  gfx::Vector2d view_offset =
+      gfx::ToEnclosingRect(
+          gfx::ConvertRectToDips(
+              rwhva->offscreen_helper()->GetViewBoundsInPix(), scale_factor))
+          .OffsetFromOrigin();
+  return element_bounds + view_offset;
+}
+
+void AutofillClientEfl::ConfirmMigrateLocalCardToCloud(
+    const LegalMessageLines& legal_message_lines,
+    const std::string& user_email,
+    const std::vector<MigratableCreditCard>& migratable_credit_cards,
+    LocalCardMigrationCallback start_migrating_cards_callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::ShowWebauthnOfferDialog(
+    WebauthnDialogCallback offer_dialog_callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::ShowWebauthnVerifyPendingDialog(
+    WebauthnDialogCallback verify_pending_dialog_callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::UpdateWebauthnOfferDialogWithError() {
+  NOTIMPLEMENTED();
+}
+
+bool AutofillClientEfl::CloseWebauthnDialog() {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::ConfirmSaveUpiIdLocally(
+    const std::string& upi_id,
+    base::OnceCallback<void(bool user_decision)> callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::OfferVirtualCardOptions(
+    const std::vector<CreditCard*>& candidates,
+    base::OnceCallback<void(const std::string&)> callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::CreditCardUploadCompleted(bool card_saved) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::PinPopupView() {
+  NOTIMPLEMENTED();
+}
+
+AutofillClient::PopupOpenArgs AutofillClientEfl::GetReopenPopupArgs() const {
+  NOTIMPLEMENTED();
+  return {};
+}
+
+base::span<const Suggestion> AutofillClientEfl::GetPopupSuggestions() const {
+  NOTIMPLEMENTED();
+  return base::span<const Suggestion>();
+}
+
+void AutofillClientEfl::UpdatePopup(const std::vector<Suggestion>& suggestions,
+                                    PopupType popup_type) {
+  NOTIMPLEMENTED();
+}
+
+const GURL& AutofillClientEfl::GetLastCommittedPrimaryMainFrameURL() const {
+  DCHECK(web_contents_);
+  content::NavigationEntry* entry =
+      web_contents_->GetController().GetLastCommittedEntry();
+  if (!entry)
+    return GURL::EmptyGURL();
+
+  return entry->GetURL();
+}
+
+std::vector<std::string>
+AutofillClientEfl::GetAllowedMerchantsForVirtualCards() {
+  NOTIMPLEMENTED();
+  return std::vector<std::string>();
+}
+
+std::vector<std::string>
+AutofillClientEfl::GetAllowedBinRangesForVirtualCards() {
+  NOTIMPLEMENTED();
+  return std::vector<std::string>();
+}
+
+const translate::LanguageState* AutofillClientEfl::GetLanguageState() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+translate::TranslateDriver* AutofillClientEfl::GetTranslateDriver() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+void AutofillClientEfl::ConfirmSaveAddressProfile(
+    const AutofillProfile& profile,
+    const AutofillProfile* original_profile,
+    AutofillClient::SaveAddressProfilePromptOptions options,
+    AddressProfileSavePromptCallback callback) {
+  NOTIMPLEMENTED();
+}
+
+void AutofillClientEfl::LoadRiskData(
+    base::OnceCallback<void(const std::string&)> callback) {
+  NOTIMPLEMENTED();
+}
+
+WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillClientEfl);
 }  // namespace autofill
 
 #endif // TIZEN_AUTOFILL_SUPPORT
index 0a270e9..fc70981 100644 (file)
@@ -6,17 +6,17 @@
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 
-#include "eweb_view.h"
 #include "base/callback.h"
 #include "base/compiler_specific.h"
 #include "base/i18n/rtl.h"
 #include "base/memory/weak_ptr.h"
+#include "browser/autofill_popup_view_efl.h"
 #include "components/autofill/core/browser/autofill_client.h"
-#include "components/autofill/core/browser/autofill_metrics.h"
+#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
 #include "components/password_manager/core/browser/password_form_manager.h"
 #include "content/public/browser/web_contents_observer.h"
 #include "content/public/browser/web_contents_user_data.h"
-#include "autofill_popup_view_efl.h"
+#include "eweb_view.h"
 
 namespace content {
 struct FrameNavigateParams;
@@ -26,80 +26,153 @@ class WebContents;
 
 namespace autofill {
 
-struct FormData;
-
-// Chrome implementation of AutofillManagerDelegate.
 class AutofillClientEfl
-    : public content::WebContentsUserData<AutofillClientEfl>,
-      public autofill::AutofillClient,
+    : public AutofillClient,
+      public content::WebContentsUserData<AutofillClientEfl>,
       public content::WebContentsObserver {
  public:
-  virtual ~AutofillClientEfl();
+  ~AutofillClientEfl() override;
 
   AutofillClientEfl(const AutofillClientEfl&) = delete;
   AutofillClientEfl& operator=(const AutofillClientEfl&) = delete;
 
-  // Called when the tab corresponding to |this| instance is activated.
-  void TabActivated();
-  // AutofillManagerDelegate implementation.
+  // AutofillClient implementation.
   PersonalDataManager* GetPersonalDataManager() override;
-  scoped_refptr<AutofillWebDataService> GetDatabase() override;
   PrefService* GetPrefs() override;
-  void HideRequestAutocompleteDialog() override;
-  void ShowAutofillSettings() override;
-  void ConfirmSaveCreditCardLocally(const base::Closure& callback) override;
+  virtual const PrefService* GetPrefs() const override;
+  syncer::SyncService* GetSyncService() override;
+  void ShowAutofillSettings(bool show_credit_card_settings) override;
+  void ConfirmSaveCreditCardLocally(
+      const CreditCard& card,
+      SaveCreditCardOptions options,
+      LocalSaveCardPromptCallback callback) override;
   void ConfirmSaveCreditCardToCloud(
-      const base::Closure& callback,
-      scoped_ptr<base::DictionaryValue> legal_message) override;
-  void LoadRiskData(
-      const base::OnceCallback<void(const std::string&)>& callback) override;
-  void ShowRequestAutocompleteDialog(
-      const autofill::FormData& form,
-      content::RenderFrameHost* rfh,
-      const ResultCallback& callback) override;
+      const CreditCard& card,
+      const LegalMessageLines& legal_message_lines,
+      SaveCreditCardOptions options,
+      UploadSaveCardPromptCallback callback) override;
+  void ConfirmCreditCardFillAssist(const CreditCard& card,
+                                   base::OnceClosure callback) override;
   void ShowAutofillPopup(
-      const gfx::RectF& element_bounds,
-      base::i18n::TextDirection text_direction,
-      const std::vector<autofill::Suggestion>& suggestions,
+      const PopupOpenArgs& open_args,
       base::WeakPtr<autofill::AutofillPopupDelegate> delegate) override;
-  void ShowUnmaskPrompt(
-      const autofill::CreditCard& card,
-      base::WeakPtr<autofill::CardUnmaskDelegate> delegate) override;
+  void ShowUnmaskPrompt(const CreditCard& card,
+                        AutofillClient::UnmaskCardReason reason,
+                        base::WeakPtr<CardUnmaskDelegate> delegate) override;
   void UpdateAutofillPopupDataListValues(
       const std::vector<std::u16string>& values,
       const std::vector<std::u16string>& labels) override;
   void OnUnmaskVerificationResult(PaymentsRpcResult result) override;
   bool HasCreditCardScanFeature() override;
-  void ScanCreditCard(const CreditCardScanCallback& callback) override;
-  void OnFirstUserGestureObserved() override;
-  bool IsContextSecure(const GURL& form_origin) override;
+  void ScanCreditCard(CreditCardScanCallback callback) override;
+  bool IsContextSecure() const override;
+
+  signin::IdentityManager* GetIdentityManager() override;
+  ukm::UkmRecorder* GetUkmRecorder() override;
+  ukm::SourceId GetUkmSourceId() override;
+  AddressNormalizer* GetAddressNormalizer() override;
+  security_state::SecurityLevel GetSecurityLevelForUmaHistograms() override;
 
-  IdentityProvider* GetIdentityProvider() override;
-  rappor::RapporService* GetRapporService() override;
-  void HideAutofillPopup() override;
+  bool AreServerCardsSupported() const override;
+  void ExecuteCommand(int id) override;
+  void HideAutofillPopup(PopupHidingReason reason) override;
   bool IsAutocompleteEnabled() override;
   void PropagateAutofillPredictions(
-      content::RenderFrameHost* rfh,
-      const std::vector<autofill::FormStructure*>& forms) override;
-  bool IsAutocompleteSavingEnabled();
+      autofill::AutofillDriver* autofill_driver,
+      const std::vector<FormStructure*>& forms) override;
+  void DidFillOrPreviewField(const std::u16string& autofilled_value,
+                             const std::u16string& profile_full_name) override;
+  bool ShouldShowSigninPromo() override;
+  void ConfirmMigrateLocalCardToCloud(
+      const LegalMessageLines& legal_message_lines,
+      const std::string& user_email,
+      const std::vector<MigratableCreditCard>& migratable_credit_cards,
+      LocalCardMigrationCallback start_migrating_cards_callback) override;
+  void ShowWebauthnOfferDialog(
+      WebauthnDialogCallback offer_dialog_callback) override;
+  void ShowWebauthnVerifyPendingDialog(
+      WebauthnDialogCallback verify_pending_dialog_callback) override;
+  void UpdateWebauthnOfferDialogWithError() override;
+  bool CloseWebauthnDialog() override;
+  void ConfirmSaveUpiIdLocally(
+      const std::string& upi_id,
+      base::OnceCallback<void(bool user_decision)> callback) override;
+  void OfferVirtualCardOptions(
+      const std::vector<CreditCard*>& candidates,
+      base::OnceCallback<void(const std::string&)> callback) override;
+  void CreditCardUploadCompleted(bool card_saved) override;
+  void PinPopupView() override;
+  PopupOpenArgs GetReopenPopupArgs() const override;
+  base::span<const Suggestion> GetPopupSuggestions() const override;
+  void UpdatePopup(const std::vector<Suggestion>& suggestions,
+                   PopupType popup_type) override;
+  const GURL& GetLastCommittedPrimaryMainFrameURL() const override;
+  const translate::LanguageState* GetLanguageState() override;
+  translate::TranslateDriver* GetTranslateDriver() override;
+  std::vector<std::string> GetAllowedMerchantsForVirtualCards() override;
+  std::vector<std::string> GetAllowedBinRangesForVirtualCards() override;
+  void ConfirmSaveAddressProfile(
+      const AutofillProfile& profile,
+      const AutofillProfile* original_profile,
+      AutofillClient::SaveAddressProfilePromptOptions options,
+      AddressProfileSavePromptCallback callback) override;
+  payments::PaymentsClient* GetPaymentsClient() override;
+  url::Origin GetLastCommittedPrimaryMainFrameOrigin() const {};
+  bool IsFastCheckoutSupported() {}
+  bool IsFastCheckoutTriggerForm(const FormData& form,
+                                 const FormFieldData& field) {}
+  bool FastCheckoutScriptSupportsConsentlessExecution(
+      const url::Origin& origin) {}
+  bool FastCheckoutClientSupportsConsentlessExecution() {}
+  bool ShowFastCheckout(base::WeakPtr<FastCheckoutDelegate> delegate) {}
+
+  bool IsTouchToFillCreditCardSupported() {}
+  void HideFastCheckout() {}
+  bool ShowTouchToFillCreditCard(base::WeakPtr<TouchToFillDelegate> delegate) {}
+  void OpenPromoCodeOfferDetailsURL(const GURL& url) {}
+
+  bool IsPasswordManagerEnabled() {}
+  void HideTouchToFillCreditCard() {}
+
   // content::WebContentsObserver implementation.
-  void DidNavigateMainFrame(const content::LoadCommittedDetails& details,
-      const content::FrameNavigateParams& params) override;
+  void PrimaryMainFrameWasResized(bool width_changed) override;
   void WebContentsDestroyed() override;
-  void ShowSavePasswordPopup(scoped_ptr<password_manager::PasswordFormManager> form_to_save);
+  void LoadRiskData(
+      base::OnceCallback<void(const std::string&)> callback) override;
+
+  void ShowSavePasswordPopup(
+      std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save);
   void SetEWebView(EWebView* view) { webview_ = view; }
-  AutofillPopupViewEfl* GetOrCreatePopupController();
-  void DidFillOrPreviewField(const std::u16string& autofilled_value,
-                             const std::u16string& profile_full_name) override;
+  void UpdateAutofillIfRequired();
+  void DidChangeFocusedNodeBounds(const gfx::RectF& node_bounds);
+  bool IsAutocompleteSavingEnabled();
+  FormDataImporter* GetFormDataImporter();
+  StrikeDatabase* GetStrikeDatabase();
+  void ShowLocalCardMigrationDialog(
+      base::OnceClosure show_migration_dialog_closure);
+  void ConfirmMigrateLocalCardToCloud(
+      std::unique_ptr<base::DictionaryValue> legal_message,
+      const std::string& user_email,
+      const std::vector<MigratableCreditCard>& migratable_credit_cards,
+      LocalCardMigrationCallback start_migrating_cards_callback);
+  void ShowLocalCardMigrationResults(
+      const bool has_server_error,
+      const std::u16string& tip_message,
+      const std::vector<MigratableCreditCard>& migratable_credit_cards,
+      MigrationDeleteCardCallback delete_local_card_callback);
+  AutocompleteHistoryManager* GetAutocompleteHistoryManager();
 
  private:
   explicit AutofillClientEfl(content::WebContents* web_contents);
   friend class content::WebContentsUserData<AutofillClientEfl>;
+  AutofillPopupViewEfl* GetOrCreatePopupController();
+  gfx::RectF GetElementBoundsInScreen(const gfx::RectF& element_bounds);
 
   content::WebContents* const web_contents_;
-  EWebView* webview_;
-  scoped_refptr<AutofillWebDataService> database_;
-  AutofillPopupViewEfl* popup_controller_;
+  EWebView* webview_ = nullptr;
+  AutofillPopupViewEfl* popup_controller_ = nullptr;
+
+  WEB_CONTENTS_USER_DATA_KEY_DECL();
 };
 
 }  // namespace autofill
index e31cefb..0bf0c5b 100644 (file)
 namespace autofill {
 
 // static
-PersonalDataManagerFactory* PersonalDataManagerFactory::GetInstance() {
-  return base::Singleton<PersonalDataManagerFactory>::get();
+PersonalDataManagerFactoryEfl* PersonalDataManagerFactoryEfl::GetInstance() {
+  return base::Singleton<PersonalDataManagerFactoryEfl>::get();
 }
 
-void PersonalDataManagerFactory::PersonalDataManagerAdd(content::BrowserContext* ctx) {
+void PersonalDataManagerFactoryEfl::PersonalDataManagerAdd(
+    content::BrowserContext* ctx) {
   DCHECK(ctx);
 
   if (ctx) {
@@ -32,12 +33,14 @@ void PersonalDataManagerFactory::PersonalDataManagerAdd(content::BrowserContext*
       // TODO: LOCALE!
       PrefService* srv = user_prefs::UserPrefs::Get(ctx);
       CHECK(srv);
-      content::ContentBrowserClient* client = content::GetContentClientExport()->browser();
+      auto* client = content::GetContentClientExport()->browser();
       mgr = new PersonalDataManager(client->GetApplicationLocale());
-      mgr->Init(WebDataServiceFactory::GetAutofillWebDataForProfile(),
-                srv,
-                NULL,
-                NULL,
+      mgr->Init(WebDataServiceFactoryEfl::GetAutofillWebDataForProfile(),
+                nullptr, srv, nullptr,
+                nullptr,  // TODO(djmix.kim) : pass nullptr for bringup
+                nullptr,  // TODO(djmix.kim) : pass nullptr for bringup
+                nullptr,  // TODO(djmix.kim) : pass nullptr for bringup
+                nullptr,  // TODO(djmix.kim) : pass nullptr for bringup
                 ctx->IsOffTheRecord());
       mgr->AddObserver(this);
       personal_data_manager_id_map_.AddWithID(mgr, uniqueId);
@@ -45,36 +48,36 @@ void PersonalDataManagerFactory::PersonalDataManagerAdd(content::BrowserContext*
   }
 }
 
-void PersonalDataManagerFactory::PersonalDataManagerRemove(content::BrowserContext* ctx) {
+void PersonalDataManagerFactoryEfl::PersonalDataManagerRemove(
+    content::BrowserContext* ctx) {
   uint64_t uniqueId = reinterpret_cast<uint64_t>(ctx);
   personal_data_manager_id_map_.Remove(uniqueId);
 }
 
-PersonalDataManager* PersonalDataManagerFactory::PersonalDataManagerForContext(
+PersonalDataManager*
+PersonalDataManagerFactoryEfl::PersonalDataManagerForContext(
     content::BrowserContext* ctx) {
   uint64_t uniqueId = reinterpret_cast<uint64_t>(ctx);
   return personal_data_manager_id_map_.Lookup(uniqueId);
 }
 
-PersonalDataManagerFactory::PersonalDataManagerFactory()
-  : callback_(NULL)
-  , callback_user_data_(NULL) {
-}
+PersonalDataManagerFactoryEfl::PersonalDataManagerFactoryEfl()
+    : callback_(NULL), callback_user_data_(NULL) {}
 
-PersonalDataManagerFactory::~PersonalDataManagerFactory() {
+PersonalDataManagerFactoryEfl::~PersonalDataManagerFactoryEfl() {
   if (!personal_data_manager_id_map_.IsEmpty())
     LOG(ERROR) << "Client didn't destroy all WebView objects"
         << " before calling ewk_shutdown";
 }
 
-void PersonalDataManagerFactory::SetCallback(
+void PersonalDataManagerFactoryEfl::SetCallback(
     Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
     void* user_data) {
   callback_ = callback;
   callback_user_data_ = user_data;
 }
 
-void PersonalDataManagerFactory::OnPersonalDataChanged() {
+void PersonalDataManagerFactoryEfl::OnPersonalDataChanged() {
   if(!callback_)
     return;
   callback_(callback_user_data_);
index 662449e..205581d 100644 (file)
@@ -6,8 +6,8 @@
 #define PERSONAL_DATA_MANAGER_FACTORY_H
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-#include "base/id_map.h"
 #include "base/compiler_specific.h"
+#include "base/containers/id_map.h"
 #include "base/memory/ref_counted.h"
 #include "base/memory/singleton.h"
 #include "components/autofill/core/browser/personal_data_manager_observer.h"
@@ -28,9 +28,9 @@ class PersonalDataManager;
 class AutofillProfile;
 class CreditCard;
 
-class PersonalDataManagerFactory : public PersonalDataManagerObserver {
+class PersonalDataManagerFactoryEfl : public PersonalDataManagerObserver {
  public:
-  static PersonalDataManagerFactory* GetInstance();
+  static PersonalDataManagerFactoryEfl* GetInstance();
 
   void PersonalDataManagerAdd(content::BrowserContext* ctx);
   void PersonalDataManagerRemove(content::BrowserContext* ctx);
@@ -44,16 +44,16 @@ class PersonalDataManagerFactory : public PersonalDataManagerObserver {
   void OnPersonalDataChanged() override;
 
  private:
-  friend struct base::DefaultSingletonTraits<PersonalDataManagerFactory>;
+  friend struct base::DefaultSingletonTraits<PersonalDataManagerFactoryEfl>;
 
-  PersonalDataManagerFactory();
-  ~PersonalDataManagerFactory();
+  PersonalDataManagerFactoryEfl();
+  ~PersonalDataManagerFactoryEfl();
 
-  PersonalDataManagerFactory(const PersonalDataManagerFactory&) = delete;
-  PersonalDataManagerFactory& operator=(const PersonalDataManagerFactory&) =
-      delete;
+  PersonalDataManagerFactoryEfl(const PersonalDataManagerFactoryEfl&) = delete;
+  PersonalDataManagerFactoryEfl& operator=(
+      const PersonalDataManagerFactoryEfl&) = delete;
 
-  IDMap<PersonalDataManager, IDMapOwnPointer> personal_data_manager_id_map_;
+  base::IDMap<PersonalDataManager*> personal_data_manager_id_map_;
 
   Ewk_Context_Form_Autofill_Profile_Changed_Callback callback_;
   void* callback_user_data_;
index 7bb79f9..2d36be4 100644 (file)
@@ -5,13 +5,16 @@
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 
 #include "autofill_popup_view_efl.h"
-#include "base/path_service.h"
 #include "base/files/file_path.h"
+#include "base/path_service.h"
 #include "base/strings/utf_string_conversions.h"
-#include "components/autofill/core/browser/popup_item_ids.h"
+#include "components/autofill/core/browser/ui/popup_item_ids.h"
+#include "content/browser/renderer_host/render_widget_host_view_aura.h"
 #include "content/common/paths_efl.h"
 #include "eweb_view.h"
-#include "tizen/profile_info.h"
+#include "tizen/system_info.h"
+#include "ui/display/screen.h"
+#include "ui/gfx/geometry/rect_f.h"
 
 #define AUTOFILL_POPUP_LABEL_COUNT  6 // Autofill component send 6 at max
 #define AUTOFILL_POPUP_LABEL_LEN    100
@@ -80,46 +83,60 @@ void AutofillPopupViewEfl::Hide()
 }
 
 void AutofillPopupViewEfl::ShowSavePasswordPopup(
-    scoped_ptr<PasswordFormManager> form_to_save)
-{
+    std::unique_ptr<PasswordFormManagerForUI> form_to_save) {
   if (password_popup_) {
     evas_object_del(password_popup_);
     password_popup_ = NULL;
   }
-  form_manager_ = form_to_save.Pass();
+  form_manager_ = std::move(form_to_save);
   password_popup_ = elm_popup_add(webview_->evas_object());
-  elm_popup_allow_events_set(password_popup_, EINA_TRUE);
   elm_popup_content_text_wrap_type_set(password_popup_, ELM_WRAP_CHAR);
-  elm_object_part_text_set(password_popup_, "title,text", "Save Your Password?");
+  elm_object_domain_translatable_part_text_set(
+      password_popup_, "title,text", "WebKit",
+      "IDS_WEBVIEW_HEADER_SAVE_SIGN_IN_INFO");
+
+#if BUILDFLAG(IS_EFL) && !BUILDFLAG(IS_TIZEN)
+  // Fix the positioning of the password popup on desktop build
+  auto* rwhv = webview_->web_contents().GetRenderWidgetHostView();
+  auto* rwhva = static_cast<content::RenderWidgetHostViewAura*>(rwhv);
+  if (rwhva) {
+    int w = 0, h = 0;
+    evas_object_geometry_get(password_popup_, 0, 0, &w, &h);
+    gfx::Size size = rwhva->offscreen_helper()->GetVisibleViewportSize();
+    evas_object_move(password_popup_, (size.width() - w) / 2,
+                     (size.height() - h) / 2);
+  }
+#endif
+
   evas_object_show(password_popup_);
 
-  Evas_Object *btn_never = elm_button_add(password_popup_);
-  elm_object_text_set(btn_never, "Never");
+  Evas_Object* btn_never = elm_button_add(password_popup_);
+  elm_object_domain_translatable_part_text_set(btn_never, NULL, "WebKit",
+                                               "IDS_WEBVIEW_BUTTON2_NEVER");
   elm_object_part_content_set(password_popup_, "button1", btn_never);
   evas_object_smart_callback_add(btn_never,
       "clicked",
       savePasswordNeverCb,
       this);
 
-  Evas_Object *btn_yes = elm_button_add(password_popup_);
-  elm_object_text_set(btn_yes, "Yes");
-  elm_object_part_content_set(password_popup_, "button2", btn_yes);
-  evas_object_smart_callback_add(btn_yes,
-      "clicked",
-      savePasswordYesCb,
-      this);
-
-  Evas_Object *btn_not_now = elm_button_add(password_popup_);
-  elm_object_text_set(btn_not_now, "Not Now");
-  elm_object_part_content_set(password_popup_, "button3", btn_not_now);
-  evas_object_smart_callback_add(btn_not_now,
-      "clicked",
-      savePasswordNotNowCb,
-      this);
+  Evas_Object* btn_not_now = elm_button_add(password_popup_);
+  elm_object_domain_translatable_part_text_set(btn_not_now, NULL, "WebKit",
+                                               "IDS_WEBVIEW_BUTTON_LATER_ABB");
+  elm_object_part_content_set(password_popup_, "button2", btn_not_now);
+  evas_object_smart_callback_add(btn_not_now, "clicked", savePasswordNotNowCb,
+                                 this);
+
+  Evas_Object* btn_yes = elm_button_add(password_popup_);
+  elm_object_domain_translatable_part_text_set(btn_yes, NULL, "WebKit",
+                                               "IDS_WEBVIEW_BUTTON_SAVE");
+  elm_object_part_content_set(password_popup_, "button3", btn_yes);
+  evas_object_smart_callback_add(btn_yes, "clicked", savePasswordYesCb, this);
 }
-           
-void AutofillPopupViewEfl::UpdateFormDataPopup(const gfx::RectF& bounds)
-{
+
+void AutofillPopupViewEfl::UpdateFormDataPopup(const gfx::RectF& bounds) {
+  if (bounds.IsEmpty())
+    return;
+
   Elm_Genlist_Item_Class* list_Items = NULL;
   double scale_factor = 1.0;
   if (!autofill_list_)
@@ -146,8 +163,8 @@ void AutofillPopupViewEfl::UpdateFormDataPopup(const gfx::RectF& bounds)
         static_cast<void*>(this));
   }
   if (IsMobileProfile() || IsWearableProfile()) {
-    scale_factor = gfx::Screen::GetNativeScreen()->GetPrimaryDisplay().
-        device_scale_factor();
+    scale_factor =
+        display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
   } else if (IsTvProfile()) {
     scale_factor = webview_->GetScale();
   }
@@ -198,8 +215,20 @@ void AutofillPopupViewEfl::UpdateFormDataPopup(const gfx::RectF& bounds)
   evas_object_propagate_events_set(autofill_popup_, false);
 }
 
+void AutofillPopupViewEfl::UpdateLocation(const gfx::RectF& bounds) {
+  if (bounds.IsEmpty())
+    return;
+
+  double scale_factor =
+      display::Screen::GetScreen()->GetPrimaryDisplay().device_scale_factor();
+
+  evas_object_move(autofill_popup_, bounds.x() * scale_factor,
+                   (bounds.y() + bounds.height()) * scale_factor);
+}
+
 bool isAutofillSpecial(const autofill::Suggestion& suggestion) {
-  return suggestion.frontend_id != POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY &&
+  return suggestion.frontend_id <= 0 &&
+         suggestion.frontend_id != POPUP_ITEM_ID_AUTOCOMPLETE_ENTRY &&
          suggestion.frontend_id != POPUP_ITEM_ID_DATALIST_ENTRY;
 }
 
@@ -216,9 +245,10 @@ void AutofillPopupViewEfl::InitFormData(
 
   for (size_t i = 0; i < values_.size() && i < AUTOFILL_POPUP_LABEL_COUNT;
        ++i) {
-    labels_[i] = UTF16ToUTF8(values_[i].value);
-    if (!values_[i].label.empty())
-      labels_[i].append(" (" + UTF16ToUTF8(values_[i].label) + ")");
+    labels_[i] = base::UTF16ToUTF8(values_[i].main_text.value);
+    if (!values_[i].labels.empty() && !values_[i].labels[0][0].value.empty())
+      labels_[i].append(" (" +
+                        base::UTF16ToUTF8(values_[i].labels[0][0].value) + ")");
     // To keep compatibility with webkit2-efl
     if (AUTOFILL_POPUP_LABEL_LEN < labels_[i].length())
       labels_[i].resize(AUTOFILL_POPUP_LABEL_LEN);
@@ -226,16 +256,13 @@ void AutofillPopupViewEfl::InitFormData(
   delegate_ = delegate;
 }
 
-void AutofillPopupViewEfl::AcceptSuggestion(size_t index)
-{
-  if (delegate_) {
-    if (index < values_.size())
-      delegate_->DidAcceptSuggestion(values_[index].value, values_[index].frontend_id, index);
+void AutofillPopupViewEfl::AcceptSuggestion(size_t index) {
+  if (delegate_ && index < values_.size()) {
+    delegate_->DidAcceptSuggestion(values_[index], index);
   }
 }
 
-void AutofillPopupViewEfl::AcceptPasswordSuggestion(int option)
-{
+void AutofillPopupViewEfl::AcceptPasswordSuggestion(int option) {
   if (password_popup_) {
     evas_object_del(password_popup_);
     password_popup_ = NULL;
@@ -244,7 +271,7 @@ void AutofillPopupViewEfl::AcceptPasswordSuggestion(int option)
     return;
   switch (static_cast<AutofillSavePassword>(option)) {
     case AUTOFILL_SAVE_PASS_NEVER: {
-      form_manager_->PermanentlyBlacklist();
+      form_manager_->Blocklist();
       break;
     }
     case AUTOFILL_SAVE_PASS_YES: {
@@ -265,8 +292,9 @@ void AutofillPopupViewEfl::SetSelectedLine(size_t selected_line)
   selected_line_ = selected_line;
   if (delegate_) {
     if (selected_line_ < values_.size()) {
-      delegate_->DidSelectSuggestion(values_[selected_line].value,
-          selected_line);
+      delegate_->DidSelectSuggestion(values_[selected_line].main_text.value,
+                                     selected_line,
+                                     autofill::Suggestion::BackendId());
     }
     else {
       delegate_->ClearPreviewedForm();
@@ -292,23 +320,29 @@ void AutofillPopupViewEfl::itemSelectCb(void* data, Evas_Object* obj, void* even
     autofill_popup->AcceptSuggestion(index);
 }
 
-void AutofillPopupViewEfl::savePasswordNeverCb(void *data, Evas_Object *obj, void *event_info)
-{
-  AutofillPopupViewEfl * autofill_popup = static_cast<AutofillPopupViewEfl*>(data);
+void AutofillPopupViewEfl::savePasswordNeverCb(void* data,
+                                               Evas_Object* obj,
+                                               void* event_info) {
+  AutofillPopupViewEfl* autofill_popup =
+      static_cast<AutofillPopupViewEfl*>(data);
   if (autofill_popup)
     autofill_popup->AcceptPasswordSuggestion(AUTOFILL_SAVE_PASS_NEVER);
 }
 
-void AutofillPopupViewEfl::savePasswordYesCb(void *data, Evas_Object *obj, void *event_info)
-{
-  AutofillPopupViewEfl * autofill_popup = static_cast<AutofillPopupViewEfl*>(data);
+void AutofillPopupViewEfl::savePasswordYesCb(void* data,
+                                             Evas_Object* obj,
+                                             void* event_info) {
+  AutofillPopupViewEfl* autofill_popup =
+      static_cast<AutofillPopupViewEfl*>(data);
   if (autofill_popup)
     autofill_popup->AcceptPasswordSuggestion(AUTOFILL_SAVE_PASS_YES);
 }
 
-void AutofillPopupViewEfl::savePasswordNotNowCb(void *data, Evas_Object *obj, void *event_info)
-{
-  AutofillPopupViewEfl * autofill_popup = static_cast<AutofillPopupViewEfl*>(data);
+void AutofillPopupViewEfl::savePasswordNotNowCb(void* data,
+                                                Evas_Object* obj,
+                                                void* event_info) {
+  AutofillPopupViewEfl* autofill_popup =
+      static_cast<AutofillPopupViewEfl*>(data);
   if (autofill_popup)
     autofill_popup->AcceptPasswordSuggestion(AUTOFILL_SAVE_PASS_NOTNOW);
 }
index 5320a43..c7b4fd1 100644 (file)
 #include <Elementary.h>
 #include <Evas.h>
 
-#include "components/autofill/core/browser/autofill_popup_delegate.h"
-#include "components/autofill/core/browser/suggestion.h"
-#include "components/password_manager/core/browser/password_form_manager.h"
+#include "base/memory/weak_ptr.h"
+#include "components/autofill/core/browser/ui/autofill_popup_delegate.h"
+#include "components/autofill/core/browser/ui/suggestion.h"
+#include "components/password_manager/core/browser/password_form_manager_for_ui.h"
 #include "ui/gfx/geometry/point.h"
-#include "ui/gfx/screen.h"
 
 class EWebView;
 
@@ -29,26 +29,29 @@ class RectF;
 namespace autofill {
 
 class AutofillPopupViewEfl {
-public:
+ public:
   AutofillPopupViewEfl(EWebView* view);
   ~AutofillPopupViewEfl();
   void Show();
   void Hide();
   void ShowSavePasswordPopup(
-      scoped_ptr<password_manager::PasswordFormManager> form_to_save);
+      std::unique_ptr<password_manager::PasswordFormManagerForUI> form_to_save);
   void UpdateFormDataPopup(const gfx::RectF& bounds);
+  void UpdateLocation(const gfx::RectF& focused_element_bounds);
   void InitFormData(
       const std::vector<autofill::Suggestion>& suggestions,
       base::WeakPtr<AutofillPopupDelegate> delegate);
   void AcceptSuggestion(size_t index);
   void AcceptPasswordSuggestion(int option);
   void SetSelectedLine(size_t index);
+  bool IsVisible() const { return evas_object_visible_get(autofill_popup_); }
   static char* getItemLabel(void* data, Evas_Object* obj, const char* part);
   static void itemSelectCb(void* data, Evas_Object* obj, void* event_info);
   static void savePasswordNeverCb(void *data, Evas_Object *obj, void *event_info);
   static void savePasswordYesCb(void *data, Evas_Object *obj, void *event_info);
   static void savePasswordNotNowCb(void *data, Evas_Object *obj, void *event_info);
-private:
+
+ private:
   EWebView* webview_;
   Evas_Object* autofill_popup_;
   Evas_Object* autofill_list_;
@@ -56,7 +59,7 @@ private:
   std::vector<autofill::Suggestion> values_;
   size_t selected_line_;
   base::WeakPtr<AutofillPopupDelegate> delegate_;
-  scoped_ptr<password_manager::PasswordFormManager> form_manager_;
+  std::unique_ptr<password_manager::PasswordFormManagerForUI> form_manager_;
 };
 
 } //namespace autofill
diff --git a/tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.cc b/tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.cc
new file mode 100644 (file)
index 0000000..439022b
--- /dev/null
@@ -0,0 +1,106 @@
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+
+#include "password_helper_efl.h"
+
+#include "base/memory/weak_ptr.h"
+#include "base/time/time.h"
+#include "components/password_manager/core/browser/password_form.h"
+#include "components/password_manager/core/browser/password_store.h"
+#include "components/password_manager/core/browser/password_store_consumer.h"
+#include "url/gurl.h"
+
+using password_manager::PasswordStore;
+
+namespace password_helper {
+
+namespace {
+
+class PasswordFormGetter : public password_manager::PasswordStoreConsumer {
+ public:
+  PasswordFormGetter(const password_helper::GetLoginsCallback& callback)
+      : callback_(callback) {}
+
+  PasswordFormGetter(const PasswordFormGetter&) = delete;
+  PasswordFormGetter& operator=(const PasswordFormGetter&) = delete;
+
+  void OnGetPasswordStoreResults(
+      std::vector<std::unique_ptr<password_manager::PasswordForm>> results)
+      override {
+    DCHECK(!callback_.is_null());
+    callback_.Run(results);
+
+    delete this;
+  }
+
+  base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
+    return weak_ptr_factory_.GetWeakPtr();
+  }
+
+ private:
+  password_helper::GetLoginsCallback callback_;
+  base::WeakPtrFactory<PasswordFormGetter> weak_ptr_factory_{this};
+};
+
+class PasswordFormRemover : public password_manager::PasswordStoreConsumer {
+ public:
+  PasswordFormRemover(scoped_refptr<PasswordStore> store, const GURL& origin)
+      : store_(store), origin_(origin) {}
+
+  PasswordFormRemover(const PasswordFormRemover&) = delete;
+  PasswordFormRemover& operator=(const PasswordFormRemover&) = delete;
+
+  void OnGetPasswordStoreResults(
+      std::vector<std::unique_ptr<password_manager::PasswordForm>> results)
+      override {
+    for (const auto& form : results) {
+      if (form->url == origin_) {
+        store_->RemoveLogin(*form);
+        break;
+      }
+    }
+
+    delete this;
+  }
+
+  base::WeakPtr<PasswordStoreConsumer> GetWeakPtr() {
+    return weak_ptr_factory_.GetWeakPtr();
+  }
+
+ private:
+  scoped_refptr<PasswordStore> store_;
+  GURL origin_;
+  base::WeakPtrFactory<PasswordFormRemover> weak_ptr_factory_{this};
+};
+
+}  // namespace
+
+void GetLogins(const scoped_refptr<password_manager::PasswordStore>& store,
+               const GetLoginsCallback& callback) {
+  if (store.get()) {
+    auto password_form_getter = new PasswordFormGetter(callback);
+    store->GetAutofillableLogins(password_form_getter->GetWeakPtr());
+  }
+}
+
+void RemoveLogin(const scoped_refptr<PasswordStore>& store,
+                 const GURL& origin) {
+  if (store.get()) {
+    auto password_form_remover = new PasswordFormRemover(store, origin);
+    store->GetAutofillableLogins(password_form_remover->GetWeakPtr());
+  }
+}
+
+void RemoveLogins(const scoped_refptr<PasswordStore>& store) {
+  if (store.get()) {
+    store->RemoveLoginsCreatedBetween(base::Time(), base::Time::Max(),
+                                      base::NullCallback());
+  }
+}
+
+}  // namespace password_helper
+
+#endif  // TIZEN_AUTOFILL_SUPPORT
diff --git a/tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.h b/tizen_src/ewk/efl_integration/browser/password_manager/password_helper_efl.h
new file mode 100644 (file)
index 0000000..1018ec1
--- /dev/null
@@ -0,0 +1,43 @@
+// Copyright 2016 Samsung Electronics. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef EWK_EFL_INTEGRATION_BROWSER_PASSWORD_MANAGER_PASSWORD_HELPER_EFL_H_
+#define EWK_EFL_INTEGRATION_BROWSER_PASSWORD_MANAGER_PASSWORD_HELPER_EFL_H_
+
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+
+#include <vector>
+
+#include "base/callback.h"
+#include "base/memory/ref_counted.h"
+
+class GURL;
+
+namespace password_manager {
+class PasswordStore;
+struct PasswordForm;
+}  // namespace password_manager
+
+namespace password_helper {
+
+typedef base::RepeatingCallback<void(
+    const std::vector<std::unique_ptr<password_manager::PasswordForm>>&
+        results)>
+    GetLoginsCallback;
+
+// Get all password forms from the password store.
+void GetLogins(const scoped_refptr<password_manager::PasswordStore>& store,
+               const GetLoginsCallback& callback);
+
+// Removes password form which is matched with |origin] from the password store.
+void RemoveLogin(const scoped_refptr<password_manager::PasswordStore>& store,
+                 const GURL& origin);
+
+// Removes all password forms from the password store.
+void RemoveLogins(const scoped_refptr<password_manager::PasswordStore>& store);
+
+}  // namespace password_helper
+
+#endif  // TIZEN_AUTOFILL_SUPPORT
+#endif  // EWK_EFL_INTEGRATION_BROWSER_PASSWORD_MANAGER_PASSWORD_HELPER_EFL_H_
index b537857..a28d1f9 100644 (file)
@@ -6,22 +6,26 @@
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 
 #include "browser/password_manager/password_manager_client_efl.h"
-#include "browser/autofill/autofill_client_efl.h"
-#include "autofill_popup_view_efl.h"
-#include "base/bind_helpers.h"
+
 #include "base/command_line.h"
 #include "base/memory/singleton.h"
 #include "base/metrics/histogram.h"
-#include "base/prefs/pref_service.h"
+#include "browser/autofill/autofill_client_efl.h"
+#include "browser/autofill_popup_view_efl.h"
 #include "browser/password_manager/password_store_factory.h"
+#include "components/password_manager/content/browser/bad_message.h"
+#include "components/password_manager/content/browser/content_password_manager_driver.h"
+#include "components/password_manager/core/browser/password_feature_manager.h"
 #include "components/password_manager/core/browser/password_form_manager.h"
 #include "components/password_manager/core/browser/password_manager.h"
 #include "components/password_manager/core/browser/password_manager_metrics_util.h"
 #include "components/password_manager/core/common/password_manager_pref_names.h"
+#include "components/prefs/pref_service.h"
 #include "components/user_prefs/user_prefs.h"
+#include "content/public/browser/render_widget_host_view.h"
 #include "content/public/browser/web_contents.h"
-
-DEFINE_WEB_CONTENTS_USER_DATA_KEY(password_manager::PasswordManagerClientEfl);
+#include "content/public/common/origin_util.h"
+#include "services/network/public/cpp/is_potentially_trustworthy.h"
 
 namespace password_manager {
 
@@ -33,15 +37,32 @@ void PasswordManagerClientEfl::CreateForWebContentsWithAutofillClient(
   if (FromWebContents(contents))
     return;
 
-  contents->SetUserData(
-      UserDataKey(),
-      new PasswordManagerClientEfl(contents, autofill_client));
+  contents->SetUserData(UserDataKey(),
+                        std::move(base::WrapUnique(new PasswordManagerClientEfl(
+                            contents, autofill_client))));
+}
+
+const GURL& PasswordManagerClientEfl::GetLastCommittedURL() const {
+  DCHECK(web_contents_);
+  content::NavigationEntry* entry =
+      web_contents_->GetController().GetLastCommittedEntry();
+  if (!entry)
+    return GURL::EmptyGURL();
+
+  return entry->GetURL();
 }
 
 PasswordManagerClientEfl::PasswordManagerClientEfl(
-    content::WebContents* web_contents, autofill::AutofillClient* autofill_client)
-    : web_contents_(web_contents),
+    content::WebContents* web_contents,
+    autofill::AutofillClient* autofill_client)
+    : content::WebContentsUserData<PasswordManagerClientEfl>(*web_contents),
+      web_contents_(web_contents),
+      password_manager_driver_bindings_(web_contents, this),
       password_manager_(this),
+      password_feature_manager_(
+          GetPrefs(),
+          nullptr,
+          nullptr /*ProfileSyncServiceFactory::GetForProfile(profile_)*/),
       driver_factory_(nullptr),
       weak_factory_(this) {
   ContentPasswordManagerDriverFactory::CreateForWebContents(web_contents, this,
@@ -54,76 +75,294 @@ PasswordManagerClientEfl::~PasswordManagerClientEfl() {
 }
 
 bool PasswordManagerClientEfl::PromptUserToSaveOrUpdatePassword(
-    scoped_ptr<PasswordFormManager> form_to_save,
-    CredentialSourceType type,
+    std::unique_ptr<PasswordFormManagerForUI> form_to_save,
     bool update_password) {
   autofill::AutofillClientEfl * autofill_manager =
       autofill::AutofillClientEfl::FromWebContents(web_contents_);
   if (autofill_manager) {
-    autofill_manager->ShowSavePasswordPopup(form_to_save.Pass());
+    autofill_manager->ShowSavePasswordPopup(std::move(form_to_save));
     return true;
   }
   return false;
 }
 
-PasswordStore* PasswordManagerClientEfl::GetPasswordStore() const {
-  return PasswordStoreFactory::GetPasswordStore().get();
-}
-
-const PasswordManager* PasswordManagerClientEfl::GetPasswordManager() const {
-  return &password_manager_;
+void PasswordManagerClientEfl::ShowManualFallbackForSaving(
+    std::unique_ptr<PasswordFormManagerForUI> form_to_save,
+    bool has_generated_password,
+    bool is_update) {
+  NOTIMPLEMENTED();
 }
 
-bool PasswordManagerClientEfl::IsSavingAndFillingEnabledForCurrentPage()
-    const {
-  return !IsOffTheRecord() && IsFillingEnabledForCurrentPage();
+PasswordStore* PasswordManagerClientEfl::GetProfilePasswordStore() const {
+  return PasswordStoreFactory::GetProfilePasswordStore().get();
 }
 
-bool PasswordManagerClientEfl::IsFillingEnabledForCurrentPage() const {
-  PrefService* prefs =
-      user_prefs::UserPrefs::Get(web_contents_->GetBrowserContext());
-  return prefs->GetBoolean(
-      password_manager::prefs::kPasswordManagerSavingEnabled);
+const PasswordManager* PasswordManagerClientEfl::GetPasswordManager() const {
+  return &password_manager_;
 }
 
 bool PasswordManagerClientEfl::PromptUserToChooseCredentials(
-    ScopedVector<autofill::PasswordForm> local_forms,
-    ScopedVector<autofill::PasswordForm> federated_forms,
-    const GURL& origin,
-    base::OnceCallback<void(const CredentialInfo&)> callback) {
+    std::vector<std::unique_ptr<PasswordForm>> local_forms,
+    const url::Origin& origin,
+    CredentialsCallback callback) {
   NOTIMPLEMENTED();
   return false;
 }
 
 void PasswordManagerClientEfl::NotifyUserAutoSignin(
-    ScopedVector<autofill::PasswordForm> local_forms) {
+    std::vector<std::unique_ptr<PasswordForm>> local_forms,
+    const url::Origin& origin) {
   DCHECK(!local_forms.empty());
   NOTIMPLEMENTED();
 }
 
-void PasswordManagerClientEfl::AutomaticPasswordSave(
-    scoped_ptr<PasswordFormManager> saved_form_manager) {
+void PasswordManagerClientEfl::NotifyUserCouldBeAutoSignedIn(
+    std::unique_ptr<PasswordForm> form) {
   NOTIMPLEMENTED();
 }
 
-const GURL& PasswordManagerClientEfl::GetLastCommittedEntryURL() const {
-  DCHECK(web_contents_);
-  content::NavigationEntry* entry =
-      web_contents_->GetController().GetLastCommittedEntry();
-  if (!entry)
-    return GURL::EmptyGURL();
+void PasswordManagerClientEfl::NotifySuccessfulLoginWithExistingPassword(
+    std::unique_ptr<password_manager::PasswordFormManagerForUI>
+        submitted_manager) {
+  NOTIMPLEMENTED();
+}
 
-  return entry->GetURL();
+void PasswordManagerClientEfl::NotifyStorePasswordCalled() {
+  NOTIMPLEMENTED();
 }
 
-const CredentialsFilter* PasswordManagerClientEfl::GetStoreResultFilter() const {
+void PasswordManagerClientEfl::AutomaticPasswordSave(
+    std::unique_ptr<PasswordFormManagerForUI> saved_form_manager) {
+  NOTIMPLEMENTED();
+}
+
+const CredentialsFilter* PasswordManagerClientEfl::GetStoreResultFilter()
+    const {
   return &credentials_filter_;
 }
 
-PrefService* PasswordManagerClientEfl::GetPrefs() {
+PrefService* PasswordManagerClientEfl::GetPrefs() const {
   return user_prefs::UserPrefs::Get(web_contents_->GetBrowserContext());
 }
 
+autofill::LogManager* PasswordManagerClientEfl::GetLogManager() {
+  return &log_manager_;
+}
+
+ukm::SourceId PasswordManagerClientEfl::GetUkmSourceId() {
+  NOTIMPLEMENTED();
+  return ukm::kInvalidSourceId;
+}
+
+PasswordManagerMetricsRecorder* PasswordManagerClientEfl::GetMetricsRecorder() {
+  if (!metrics_recorder_) {
+    metrics_recorder_.emplace(GetUkmSourceId());
+  }
+  return base::OptionalToPtr(metrics_recorder_);
+}
+
+bool PasswordManagerClientEfl::IsIsolationForPasswordSitesEnabled() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+bool PasswordManagerClientEfl::IsNewTabPage() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void PasswordManagerClientEfl::PasswordFormsParsed(
+    const std::vector<autofill::FormData>& forms) {
+  if (!bad_message::CheckChildProcessSecurityPolicy(
+          password_manager_driver_bindings_.GetCurrentTargetFrame(), forms,
+          BadMessageReason::CPMD_BAD_ORIGIN_FORMS_PARSED_OBSOLETE)) {
+    return;
+  }
+  password_manager::PasswordManagerDriver* driver =
+      driver_factory_->GetDriverForFrame(
+          password_manager_driver_bindings_.GetCurrentTargetFrame());
+  GetPasswordManager()->OnPasswordFormsParsed(driver, forms);
+}
+
+void PasswordManagerClientEfl::PasswordFormsRendered(
+    const std::vector<autofill::FormData>& visible_forms) {
+  if (!bad_message::CheckChildProcessSecurityPolicy(
+          password_manager_driver_bindings_.GetCurrentTargetFrame(),
+          visible_forms,
+          BadMessageReason::CPMD_BAD_ORIGIN_FORMS_RENDERED_OBSOLETE)) {
+    return;
+  }
+  password_manager::PasswordManagerDriver* driver =
+      driver_factory_->GetDriverForFrame(
+          password_manager_driver_bindings_.GetCurrentTargetFrame());
+  GetPasswordManager()->OnPasswordFormsRendered(driver, visible_forms);
+}
+
+void PasswordManagerClientEfl::ShowPasswordSuggestions(
+    base::i18n::TextDirection text_direction,
+    const std::u16string& typed_username,
+    int options,
+    const gfx::RectF& bounds) {
+  password_manager::PasswordManagerDriver* driver =
+      driver_factory_->GetDriverForFrame(
+          password_manager_driver_bindings_.GetCurrentTargetFrame());
+  driver->GetPasswordAutofillManager()->OnShowPasswordSuggestions(
+      text_direction, typed_username, options,
+      TransformToRootCoordinates(
+          password_manager_driver_bindings_.GetCurrentTargetFrame(), bounds));
+}
+
+void PasswordManagerClientEfl::PasswordFormSubmitted(
+    const autofill::FormData& password_form) {
+  if (!bad_message::CheckChildProcessSecurityPolicyForURL(
+          password_manager_driver_bindings_.GetCurrentTargetFrame(),
+          password_form.url,
+          BadMessageReason::CPMD_BAD_ORIGIN_FORM_SUBMITTED)) {
+    return;
+  }
+  password_manager::PasswordManagerDriver* driver =
+      driver_factory_->GetDriverForFrame(
+          password_manager_driver_bindings_.GetCurrentTargetFrame());
+  GetPasswordManager()->OnPasswordFormSubmitted(driver, password_form);
+}
+
+void PasswordManagerClientEfl::HideManualFallbackForSaving() {
+  NOTIMPLEMENTED();
+}
+
+void PasswordManagerClientEfl::RecordSavePasswordProgress(
+    const std::string& log) {
+  LOG_AF(GetLogManager()) << log;
+}
+
+void PasswordManagerClientEfl::UserModifiedPasswordField() {
+  GetMetricsRecorder()->RecordUserModifiedPasswordField();
+}
+
+void PasswordManagerClientEfl::FocusedInputChanged(
+    password_manager::PasswordManagerDriver* driver,
+    autofill::FieldRendererId focused_field_id,
+    autofill::mojom::FocusedFieldType focused_field_type) {
+  NOTIMPLEMENTED();
+}
+
+PasswordManager* PasswordManagerClientEfl::GetPasswordManager() {
+  return &password_manager_;
+}
+
+gfx::RectF PasswordManagerClientEfl::TransformToRootCoordinates(
+    content::RenderFrameHost* frame_host,
+    const gfx::RectF& bounds_in_frame_coordinates) {
+  content::RenderWidgetHostView* rwhv = frame_host->GetView();
+  if (!rwhv)
+    return bounds_in_frame_coordinates;
+  return gfx::RectF(rwhv->TransformPointToRootCoordSpaceF(
+                        bounds_in_frame_coordinates.origin()),
+                    bounds_in_frame_coordinates.size());
+}
+
+void PasswordManagerClientEfl::PromptUserToMovePasswordToAccount(
+    std::unique_ptr<PasswordFormManagerForUI> form_to_move) {
+  NOTIMPLEMENTED();
+}
+
+PasswordStore* PasswordManagerClientEfl::GetAccountPasswordStore() const {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+url::Origin PasswordManagerClientEfl::GetLastCommittedOrigin() const {
+  NOTIMPLEMENTED();
+  return url::Origin();
+}
+
+signin::IdentityManager* PasswordManagerClientEfl::GetIdentityManager() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+scoped_refptr<network::SharedURLLoaderFactory>
+PasswordManagerClientEfl::GetURLLoaderFactory() {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+FieldInfoManager* PasswordManagerClientEfl::GetFieldInfoManager() const {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+
+void PasswordManagerClientEfl::LogFirstFillingResult(
+    autofill::FormRendererId form_renderer_id,
+    int32_t result) {
+  NOTIMPLEMENTED();
+}
+
+bool PasswordManagerClientEfl::IsCommittedMainFrameSecure() const {
+  return network::IsOriginPotentiallyTrustworthy(
+      web_contents_->GetPrimaryMainFrame()->GetLastCommittedOrigin());
+}
+
+void PasswordManagerClientEfl::CheckProtectedPasswordEntry(
+    metrics_util::PasswordType reused_password_type,
+    const std::string& username,
+    const std::vector<MatchingReusedCredential>& matching_reused_credentials,
+    bool password_field_exists,
+    uint64_t reused_password_hash,
+    const std::string& domain) {
+  NOTIMPLEMENTED();
+}
+
+PasswordReuseManager* PasswordManagerClientEfl::GetPasswordReuseManager()
+    const {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+safe_browsing::PasswordProtectionService*
+PasswordManagerClientEfl::GetPasswordProtectionService() const {
+  NOTIMPLEMENTED();
+  return nullptr;
+}
+void PasswordManagerClientEfl::LogPasswordReuseDetectedEvent() {
+  NOTIMPLEMENTED();
+}
+bool PasswordManagerClientEfl::IsAutofillAssistantUIVisible() const {
+  NOTIMPLEMENTED();
+  return false;
+}
+
+void PasswordManagerClientEfl::InformAboutUserInput(
+    const autofill::FormData& form_data) {
+  NOTIMPLEMENTED();
+}
+void PasswordManagerClientEfl::DynamicFormSubmission(
+    autofill::mojom::SubmissionIndicatorEvent submission_indication_event) {
+  NOTIMPLEMENTED();
+}
+void PasswordManagerClientEfl::PasswordFormCleared(
+    const autofill::FormData& form_data) {
+  NOTIMPLEMENTED();
+}
+void PasswordManagerClientEfl::UserModifiedNonPasswordField(
+    autofill::FieldRendererId renderer_id,
+    const std::u16string& field_name,
+    const std::u16string& value) {
+  NOTIMPLEMENTED();
+}
+
+void PasswordManagerClientEfl::FocusedInputChanged(
+    autofill::FieldRendererId focused_field_id,
+    autofill::mojom::FocusedFieldType focused_field_type) {
+  NOTIMPLEMENTED();
+}
+
+void PasswordManagerClientEfl::CheckSafeBrowsingReputation(
+    const GURL& form_action,
+    const GURL& frame_url) {
+  NOTIMPLEMENTED();
+}
+
+WEB_CONTENTS_USER_DATA_KEY_IMPL(PasswordManagerClientEfl);
 }
 
 #endif // TIZEN_AUTOFILL_SUPPORT
index f3a26a2..1690168 100644 (file)
@@ -9,9 +9,16 @@
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 
 #include "base/compiler_specific.h"
-#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
+#include "components/autofill/core/browser/logging/log_manager.h"
+#include "components/autofill/core/browser/logging/stub_log_manager.h"
 #include "components/password_manager/content/browser/content_password_manager_driver.h"
+#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
+#include "components/password_manager/core/browser/password_feature_manager_impl.h"
 #include "components/password_manager/core/browser/password_manager_client.h"
+#include "components/password_manager/core/browser/password_manager_metrics_recorder.h"
+#include "components/password_manager/core/browser/password_store.h"
+#include "components/password_manager/core/browser/stub_credentials_filter.h"
+#include "content/public/browser/render_frame_host_receiver_set.h"
 #include "content/public/browser/web_contents_user_data.h"
 
 class PasswordManager;
@@ -24,40 +31,87 @@ class WebContents;
 namespace password_manager {
 class PasswordManagerClientEfl
     : public PasswordManagerClient,
-      public content::WebContentsUserData<PasswordManagerClientEfl> {
-public:
+      public content::WebContentsUserData<PasswordManagerClientEfl>,
+      public autofill::mojom::PasswordManagerDriver {
+ public:
   virtual ~PasswordManagerClientEfl();
+  using CredentialsCallback = base::OnceCallback<void(const PasswordForm*)>;
 
   static void CreateForWebContentsWithAutofillClient(
       content::WebContents* contents,
       autofill::AutofillClient* autofill_client);
 
   // PasswordManagerClient implementation.
-  virtual bool PromptUserToSaveOrUpdatePassword(
-      std::unique_ptr<PasswordFormManager> form_to_save,
-      CredentialSourceType type,
-      bool update_password) override;
-
-  PasswordStore* GetPasswordStore() const override;
-
+  bool PromptUserToSaveOrUpdatePassword(
+      std::unique_ptr<PasswordFormManagerForUI> form_to_save,
+      bool is_update) override;
+  void ShowManualFallbackForSaving(
+      std::unique_ptr<PasswordFormManagerForUI> form_to_save,
+      bool has_generated_password,
+      bool is_update) override;
+  PasswordStore* GetProfilePasswordStore() const override;
   bool PromptUserToChooseCredentials(
-      ScopedVector<autofill::PasswordForm> local_forms,
-      ScopedVector<autofill::PasswordForm> federated_forms,
-      const GURL& origin,
-      base::OnceCallback<void(const CredentialInfo&)> callback) override;
+      std::vector<std::unique_ptr<PasswordForm>> local_forms,
+      const url::Origin& origin,
+      CredentialsCallback callback) override;
   void NotifyUserAutoSignin(
-      ScopedVector<autofill::PasswordForm> local_forms) override;
+      std::vector<std::unique_ptr<PasswordForm>> local_forms,
+      const url::Origin& origin) override;
+  void NotifyUserCouldBeAutoSignedIn(
+      std::unique_ptr<PasswordForm> form) override;
+  void NotifySuccessfulLoginWithExistingPassword(
+      std::unique_ptr<password_manager::PasswordFormManagerForUI>
+          submitted_manager) override;
+  void NotifyStorePasswordCalled() override;
   void AutomaticPasswordSave(
-      std::unique_ptr<PasswordFormManager> saved_form_manager) override;
+      std::unique_ptr<PasswordFormManagerForUI> saved_form_manager) override;
 
   const PasswordManager* GetPasswordManager() const override;
   const CredentialsFilter* GetStoreResultFilter() const override;
-  const GURL& GetLastCommittedEntryURL() const override;
 
-  PrefService* GetPrefs() override;
-
-  bool IsFillingEnabledForCurrentPage() const override;
-  bool IsSavingAndFillingEnabledForCurrentPage() const override;
+  PrefService* GetPrefs() const override;
+
+  autofill::LogManager* GetLogManager() override;
+
+  void CheckProtectedPasswordEntry(
+      metrics_util::PasswordType reused_password_type,
+      const std::string& username,
+      const std::vector<MatchingReusedCredential>& matching_reused_credentials,
+      bool password_field_exists,
+      uint64_t reused_password_hash,
+      const std::string& domain) override;
+
+  ukm::SourceId GetUkmSourceId() override;
+  PasswordManagerMetricsRecorder* GetMetricsRecorder() override;
+  bool IsIsolationForPasswordSitesEnabled() const override;
+  bool IsNewTabPage() const override;
+  void PromptUserToMovePasswordToAccount(
+      std::unique_ptr<PasswordFormManagerForUI> form_to_move) override;
+  PasswordStore* GetAccountPasswordStore() const override;
+  const GURL& GetLastCommittedURL() const override;
+  url::Origin GetLastCommittedOrigin() const override;
+  signin::IdentityManager* GetIdentityManager() override;
+  scoped_refptr<network::SharedURLLoaderFactory> GetURLLoaderFactory() override;
+  FieldInfoManager* GetFieldInfoManager() const override;
+  void FocusedInputChanged(
+      password_manager::PasswordManagerDriver* driver,
+      autofill::FieldRendererId focused_field_id,
+      autofill::mojom::FocusedFieldType focused_field_type) override;
+  bool IsCommittedMainFrameSecure() const override;
+  PasswordReuseManager* GetPasswordReuseManager() const override;
+  safe_browsing::PasswordProtectionService* GetPasswordProtectionService()
+      const override;
+  void LogPasswordReuseDetectedEvent() override;
+  bool IsAutofillAssistantUIVisible() const override;
+  void HideManualFallbackForSaving() override;
+  const password_manager::PasswordFeatureManager* GetPasswordFeatureManager()
+      const override {
+    return &password_feature_manager_;
+  }
+  PrefService* GetLocalStatePrefs() const {}
+  const syncer::SyncService* GetSyncService() const {}
+  PasswordScriptsFetcher* GetPasswordScriptsFetcher() {}
+  PasswordChangeSuccessTracker* GetPasswordChangeSuccessTracker() {}
 
  private:
   explicit PasswordManagerClientEfl(content::WebContents* web_contents,
@@ -68,31 +122,59 @@ public:
 
   friend class content::WebContentsUserData<PasswordManagerClientEfl>;
 
-  // This filter does not filter out anything, it is a dummy implementation of
-  // the filter interface.
-  class PassThroughCredentialsFilter : public CredentialsFilter {
-   public:
-    PassThroughCredentialsFilter() {}
-
-    // CredentialsFilter:
-    ScopedVector<autofill::PasswordForm> FilterResults(
-        ScopedVector<autofill::PasswordForm> results) const override {
-      return results.Pass();
-    }
-    bool ShouldSave(const autofill::PasswordForm& form) const override {
-      return true;
-    }
-  };
-  PassThroughCredentialsFilter credentials_filter_;
+  // autofill::mojom::PasswordManagerDriver:
+  // Note that these messages received from a potentially compromised renderer.
+  // For that reason, any access to form data should be validated via
+  // bad_message::CheckChildProcessSecurityPolicy.
+  void PasswordFormsParsed(
+      const std::vector<autofill::FormData>& forms) override;
+  void PasswordFormsRendered(
+      const std::vector<autofill::FormData>& visible_forms) override;
+  void PasswordFormSubmitted(const autofill::FormData& password_form) override;
+  void RecordSavePasswordProgress(const std::string& log) override;
+  void UserModifiedPasswordField() override;
+  void ShowPasswordSuggestions(base::i18n::TextDirection text_direction,
+                               const std::u16string& typed_username,
+                               int options,
+                               const gfx::RectF& bounds) override;
+  void LogFirstFillingResult(autofill::FormRendererId form_renderer_id,
+                             int32_t result) override;
+  void InformAboutUserInput(const autofill::FormData& form_data) override;
+  void DynamicFormSubmission(autofill::mojom::SubmissionIndicatorEvent
+                                 submission_indication_event) override;
+  void PasswordFormCleared(const autofill::FormData& form_data) override;
+  void UserModifiedNonPasswordField(autofill::FieldRendererId renderer_id,
+                                    const std::u16string& field_name,
+                                    const std::u16string& value) override;
+  void FocusedInputChanged(
+      autofill::FieldRendererId focused_field_id,
+      autofill::mojom::FocusedFieldType focused_field_type) override;
+  void CheckSafeBrowsingReputation(const GURL& form_action,
+                                   const GURL& frame_url) override;
+
+  password_manager::PasswordManager* GetPasswordManager();
+
+  gfx::RectF TransformToRootCoordinates(
+      content::RenderFrameHost* frame_host,
+      const gfx::RectF& bounds_in_frame_coordinates);
+
+  const StubCredentialsFilter credentials_filter_;
+  autofill::StubLogManager log_manager_;
+  absl::optional<PasswordManagerMetricsRecorder> metrics_recorder_;
 
   content::WebContents* web_contents_;
 
-  password_manager::PasswordManager password_manager_;
+  content::RenderFrameHostReceiverSet<autofill::mojom::PasswordManagerDriver>
+      password_manager_driver_bindings_;
 
+  password_manager::PasswordManager password_manager_;
+  password_manager::PasswordFeatureManagerImpl password_feature_manager_;
   password_manager::ContentPasswordManagerDriverFactory* driver_factory_;
 
   // Allows authentication callbacks to be destroyed when this client is gone.
   base::WeakPtrFactory<PasswordManagerClientEfl> weak_factory_;
+
+  WEB_CONTENTS_USER_DATA_KEY_DECL();
 };
 }
 
index af9cf1f..4a55a7b 100644 (file)
@@ -9,14 +9,14 @@
 
 #include "base/command_line.h"
 #include "base/environment.h"
-#include "base/prefs/pref_service.h"
-#include "base/path_service.h"
 #include "base/files/file_path.h"
+#include "base/path_service.h"
 #include "browser/webdata/web_data_service.h"
 #include "browser/webdata/web_data_service_factory.h"
 #include "components/password_manager/core/browser/login_database.h"
 #include "components/password_manager/core/browser/password_store.h"
-#include "components/password_manager/core/browser/password_store_default.h"
+#include "components/password_manager/core/browser/password_store_built_in_backend.h"
+#include "components/sync/model/syncable_service.h"
 #include "content/common/paths_efl.h"
 #include "content/public/browser/browser_thread.h"
 
@@ -25,64 +25,52 @@ using password_manager::PasswordStore;
 
 PasswordStoreService::PasswordStoreService(
     scoped_refptr<PasswordStore> password_store)
-    : password_store_(password_store)
-{
-}
+    : password_store_(password_store) {}
 
-PasswordStoreService::~PasswordStoreService()
-{
-}
+PasswordStoreService::~PasswordStoreService() {}
 
-scoped_refptr<PasswordStore> PasswordStoreService::GetPasswordStore()
-{
+scoped_refptr<PasswordStore> PasswordStoreService::GetProfilePasswordStore() {
   return password_store_;
 }
 
 // static
-scoped_refptr<PasswordStore> PasswordStoreFactory::GetPasswordStore()
-{
+scoped_refptr<PasswordStore> PasswordStoreFactory::GetProfilePasswordStore() {
   PasswordStoreService* service = GetInstance()->GetService();
   if (!service)
-    return NULL;
-  return service->GetPasswordStore();
+    return nullptr;
+  return service->GetProfilePasswordStore();
 }
 
 // static
-PasswordStoreFactory* PasswordStoreFactory::GetInstance()
-{
+PasswordStoreFactory* PasswordStoreFactory::GetInstance() {
   return base::Singleton<PasswordStoreFactory>::get();
 }
 
 PasswordStoreFactory::PasswordStoreFactory() {
-  WebDataServiceFactory::GetInstance();
+  WebDataServiceFactoryEfl::GetInstance();
   Init();
 }
 
-PasswordStoreFactory::~PasswordStoreFactory()
-{
-}
+PasswordStoreFactory::~PasswordStoreFactory() {}
 
-void PasswordStoreFactory::Init()
-{
+void PasswordStoreFactory::Init() {
   base::FilePath db_path;
   if (!base::PathService::Get(PathsEfl::WEB_DATABASE_DIR, &db_path)) {
     LOG(ERROR) << "Could not access login database path.";
     return;
   }
 
-  base::FilePath login_db_file_path = db_path.Append(FILE_PATH_LITERAL(".LoginData.db"));
-  scoped_ptr<LoginDatabase> login_db(new LoginDatabase(login_db_file_path));
+  base::FilePath login_db_file_path =
+      db_path.Append(FILE_PATH_LITERAL(".LoginData.db"));
+  std::unique_ptr<LoginDatabase> login_db(
+      new LoginDatabase(login_db_file_path, IsAccountStore(false)));
 
-  scoped_refptr<base::SingleThreadTaskRunner> main_thread_runner(
-      base::ThreadTaskRunnerHandle::Get());
-  scoped_refptr<base::SingleThreadTaskRunner> db_thread_runner(
-      content::BrowserThread::GetTaskRunnerForThread(
-          content::BrowserThread::DB));
+  scoped_refptr<PasswordStore> ps = new password_manager::PasswordStore(
+      std::make_unique<password_manager::PasswordStoreBuiltInBackend>(
+          std::move(login_db)));
 
-  scoped_refptr<PasswordStore> ps = new PasswordStoreDefault(
-      main_thread_runner, db_thread_runner, login_db.Pass());
-  if (!ps.get() || !ps->Init(syncer::SyncableService::StartSyncFlare())) {
-    NOTREACHED() << "Could not initialize password manager.";
+  if (!ps.get() || !ps->Init(nullptr, nullptr)) {
+    LOG(ERROR) << "Could not initialize password manager.";
     return;
   }
 
index 4f5d05e..58bb14e 100644 (file)
@@ -10,6 +10,7 @@
 
 #include "base/memory/singleton.h"
 #include "components/password_manager/core/browser/password_manager_driver.h"
+#include "components/prefs/pref_service.h"
 
 namespace password_manager {
 class PasswordStore;
@@ -25,7 +26,7 @@ class PasswordStoreService {
   PasswordStoreService(const PasswordStoreService&) = delete;
   PasswordStoreService& operator=(const PasswordStoreService&) = delete;
 
-  scoped_refptr<PasswordStore> GetPasswordStore();
+  scoped_refptr<PasswordStore> GetProfilePasswordStore();
 
  private:
   scoped_refptr<PasswordStore> password_store_;
@@ -35,7 +36,7 @@ class PasswordStoreService {
 // Profiles.
 class PasswordStoreFactory {
  public:
-  static scoped_refptr<PasswordStore> GetPasswordStore();
+  static scoped_refptr<PasswordStore> GetProfilePasswordStore();
 
   static PasswordStoreFactory* GetInstance();
   PasswordStoreService* GetService() { return service_.get(); }
index 559af0c..554dabf 100644 (file)
@@ -7,15 +7,17 @@
 
 #include "browser/webdata/web_data_service.h"
 
-#include "base/bind.h"
+#include "base/callback.h"
+#include "base/command_line.h"
 #include "base/stl_util.h"
+#include "base/task/thread_pool.h"
 #include "components/webdata/common/web_database_service.h"
+#include "content/public/browser/browser_task_traits.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/notification_details.h"
 #include "content/public/browser/notification_service.h"
 #include "content/public/browser/notification_source.h"
 
-using base::Bind;
 using base::Time;
 using content::BrowserThread;
 
@@ -23,14 +25,14 @@ WebDataService::WebDataService(scoped_refptr<WebDatabaseService> wdbs,
                                const ProfileErrorCallback& callback)
     : WebDataServiceBase(
           wdbs,
-          callback,
-          BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)) {}
+          base::ThreadPool::CreateSingleThreadTaskRunner({BrowserThread::UI})) {
+}
 
 WebDataService::WebDataService()
     : WebDataServiceBase(
-          NULL,
-          ProfileErrorCallback(),
-          BrowserThread::GetTaskRunnerForThread(BrowserThread::UI)) {}
+          nullptr,
+          base::ThreadPool::CreateSingleThreadTaskRunner({BrowserThread::UI})) {
+}
 
 WebDataService::~WebDataService() {
 }
index cb6a2a9..34ae1a6 100644 (file)
@@ -17,7 +17,6 @@
 #include "base/files/file_path.h"
 #include "base/location.h"
 #include "base/memory/ref_counted.h"
-#include "base/sequenced_task_runner_helpers.h"
 #include "components/webdata/common/web_data_results.h"
 #include "components/webdata/common/web_data_service_base.h"
 #include "components/webdata/common/web_data_service_consumer.h"
@@ -43,8 +42,6 @@ class BrowserContext;
 //
 ////////////////////////////////////////////////////////////////////////////////
 
-typedef base::OnceCallback<scoped_ptr<WDTypedResult>(void)> ResultTask;
-
 class WebDataServiceConsumer;
 
 class WebDataService : public WebDataServiceBase {
index 158d011..ab37e60 100644 (file)
@@ -7,24 +7,24 @@
 
 #include "browser/webdata/web_data_service_factory.h"
 
-#include "eweb_view.h"
 #include "base/bind.h"
-#include "base/path_service.h"
 #include "base/files/file_path.h"
-#include "components/autofill/core/browser/autofill_country.h"
+#include "base/path_service.h"
+#include "base/task/thread_pool.h"
+#include "base/threading/thread_task_runner_handle.h"
+#include "components/autofill/core/browser/geo/autofill_country.h"
 #include "components/autofill/core/browser/webdata/autofill_table.h"
 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
 #include "components/webdata/common/webdata_constants.h"
 #include "content/common/paths_efl.h"
-#include "content/public/browser/browser_thread.h"
+#include "eweb_view.h"
 
 using autofill::AutofillWebDataService;
-using content::BrowserThread;
 
 namespace {
 
 // Callback to show error dialog on profile load error.
-void ProfileErrorCallback(int type, sql::InitStatus status) {
+void ProfileErrorCallback(sql::InitStatus status, const std::string& str) {
   //TODO:Need to check what type of error to show
   NOTIMPLEMENTED();
 }
@@ -39,95 +39,70 @@ void InitSyncableServicesOnDBThread(
 
 }  // namespace
 
-WebDataServiceWrapper* WebDataServiceWrapper::GetInstance(){
-  return base::Singleton<WebDataServiceWrapper>::get();
+WebDataServiceWrapperEfl* WebDataServiceWrapperEfl::GetInstance() {
+  return base::Singleton<WebDataServiceWrapperEfl>::get();
 }
 
-WebDataServiceWrapper::WebDataServiceWrapper() {
+WebDataServiceWrapperEfl::WebDataServiceWrapperEfl() {
   base::FilePath db_path;
   base::PathService::Get(PathsEfl::WEB_DATABASE_DIR, &db_path);
   base::FilePath path = db_path.Append(FILE_PATH_LITERAL(".FormData.db"));
 
-  web_database_ = new WebDatabaseService(
-      path, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
-      BrowserThread::GetTaskRunnerForThread(BrowserThread::DB));
-#else
-      BrowserThread::GetTaskRunnerForThread(BrowserThread::UI));
-#endif
+  auto ui_task_runner = base::ThreadTaskRunnerHandle::Get();
+  // TODO(pkasting): http://crbug.com/740773 This should likely be sequenced,
+  // not single-threaded; it's also possible these objects can each use their
+  // own sequences instead of sharing this one.
+  auto db_task_runner = base::ThreadPool::CreateSingleThreadTaskRunner(
+      {base::MayBlock(), base::TaskPriority::USER_VISIBLE,
+       base::TaskShutdownBehavior::BLOCK_SHUTDOWN});
+
+  web_database_ = new WebDatabaseService(path, ui_task_runner, db_task_runner);
 
   // All tables objects that participate in managing the database must
   // be added here.
-  web_database_->AddTable(make_scoped_ptr(new autofill::AutofillTable));
+  web_database_->AddTable(base::WrapUnique(new autofill::AutofillTable));
   web_database_->LoadDatabase();
 
-  autofill_web_data_ = new AutofillWebDataService(
-      web_database_, BrowserThread::GetTaskRunnerForThread(BrowserThread::UI),
-#if !defined(EWK_BRINGUP)  // FIXME: m67 bringup
-      BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
-#else
-      BrowserThread::GetTaskRunnerForThread(BrowserThread::DB),
-#endif
-      base::BindOnce(&ProfileErrorCallback, 0));
-  autofill_web_data_->Init();
-
-  web_data_ = new WebDataService(web_database_,
-                                 base::BindOnce(&ProfileErrorCallback, 0));
-  web_data_->Init();
+  autofill_web_data_ =
+      new AutofillWebDataService(web_database_, ui_task_runner, db_task_runner);
+  autofill_web_data_->Init(base::BindOnce(&ProfileErrorCallback));
 
   autofill_web_data_->GetAutofillBackend(
       base::BindOnce(&InitSyncableServicesOnDBThread, autofill_web_data_,
                      db_path, EWebView::GetPlatformLocale()));
 }
 
-WebDataServiceWrapper::~WebDataServiceWrapper() {
-}
+WebDataServiceWrapperEfl::~WebDataServiceWrapperEfl() {}
 
 scoped_refptr<AutofillWebDataService>
-WebDataServiceWrapper::GetAutofillWebData() {
+WebDataServiceWrapperEfl::GetAutofillWebData() {
   return autofill_web_data_.get();
 }
 
-scoped_refptr<WebDataService> WebDataServiceWrapper::GetWebData() {
-  return web_data_.get();
-}
-
-
-// static
-scoped_refptr<WebDataService> WebDataService::FromBrowserContext(
-    content::BrowserContext* context) {
-  WebDataServiceWrapper* wrapper = WebDataServiceFactory::GetDataService();
-  if (wrapper)
-    return wrapper->GetWebData();
-  // |wrapper| can be NULL in Incognito mode.
-  return scoped_refptr<WebDataService>(NULL);
-}
-
-WebDataServiceFactory::WebDataServiceFactory(){
-  // WebDataServiceFactory has no dependecies.
+WebDataServiceFactoryEfl::WebDataServiceFactoryEfl() {
+  // WebDataServiceFactoryEfl has no dependecies.
 }
 
-WebDataServiceFactory::~WebDataServiceFactory() {}
+WebDataServiceFactoryEfl::~WebDataServiceFactoryEfl() {}
 
 // static
-WebDataServiceWrapper* WebDataServiceFactory::GetDataService() {
-  return WebDataServiceWrapper::GetInstance();
+WebDataServiceWrapperEfl* WebDataServiceFactoryEfl::GetDataService() {
+  return WebDataServiceWrapperEfl::GetInstance();
 }
 
 // static
 scoped_refptr<AutofillWebDataService>
-WebDataServiceFactory::GetAutofillWebDataForProfile() {
-  WebDataServiceWrapper* wrapper =
-      WebDataServiceFactory::GetDataService();
+WebDataServiceFactoryEfl::GetAutofillWebDataForProfile() {
+  WebDataServiceWrapperEfl* wrapper =
+      WebDataServiceFactoryEfl::GetDataService();
   // |wrapper| can be NULL in Incognito mode.
-  return wrapper ?
-      wrapper->GetAutofillWebData() :
-      scoped_refptr<AutofillWebDataService>(NULL);
+  return wrapper ? wrapper->GetAutofillWebData()
+                 : scoped_refptr<AutofillWebDataService>(nullptr);
 }
 
 // static
-WebDataServiceFactory* WebDataServiceFactory::GetInstance() {
-  return base::Singleton<WebDataServiceFactory>::get();
+WebDataServiceFactoryEfl* WebDataServiceFactoryEfl::GetInstance() {
+  return base::Singleton<WebDataServiceFactoryEfl>::get();
 }
 
 #endif // TIZEN_AUTOFILL_SUPPORT
index 14a1e2b..9ee9c67 100644 (file)
@@ -19,46 +19,43 @@ namespace autofill {
 class AutofillWebDataService;
 }  // namespace autofill
 
-class WebDataServiceWrapper{
+class WebDataServiceWrapperEfl {
  public:
-  explicit WebDataServiceWrapper();
+  explicit WebDataServiceWrapperEfl();
 
-  virtual ~WebDataServiceWrapper();
+  virtual ~WebDataServiceWrapperEfl();
 
-  WebDataServiceWrapper(const WebDataServiceWrapper&) = delete;
-  WebDataServiceWrapper& operator=(const WebDataServiceWrapper&) = delete;
+  WebDataServiceWrapperEfl(const WebDataServiceWrapperEfl&) = delete;
+  WebDataServiceWrapperEfl& operator=(const WebDataServiceWrapperEfl&) = delete;
 
   virtual scoped_refptr<autofill::AutofillWebDataService> GetAutofillWebData();
 
-  virtual scoped_refptr<WebDataService> GetWebData();
+  static WebDataServiceWrapperEfl* GetInstance();
 
-  static WebDataServiceWrapper* GetInstance();
  private:
   scoped_refptr<WebDatabaseService> web_database_;
-
   scoped_refptr<autofill::AutofillWebDataService> autofill_web_data_;
   scoped_refptr<WebDataService> web_data_;
 };
 
-// Singleton that owns all WebDataServiceWrappers
-class WebDataServiceFactory {
+// Singleton that owns all WebDataServiceWrapperEfls
+class WebDataServiceFactoryEfl {
  public:
-
-  static WebDataServiceWrapper* GetDataService();
+  static WebDataServiceWrapperEfl* GetDataService();
 
   static scoped_refptr<autofill::AutofillWebDataService>
       GetAutofillWebDataForProfile();
 
-  static WebDataServiceFactory* GetInstance();
+  static WebDataServiceFactoryEfl* GetInstance();
 
  private:
-  friend struct base::DefaultSingletonTraits<WebDataServiceFactory>;
+  friend struct base::DefaultSingletonTraits<WebDataServiceFactoryEfl>;
 
-  WebDataServiceFactory();
-  virtual ~WebDataServiceFactory();
+  WebDataServiceFactoryEfl();
+  virtual ~WebDataServiceFactoryEfl();
 
-  WebDataServiceFactory(const WebDataServiceFactory&) = delete;
-  WebDataServiceFactory& operator=(const WebDataServiceFactory&) = delete;
+  WebDataServiceFactoryEfl(const WebDataServiceFactoryEfl&) = delete;
+  WebDataServiceFactoryEfl& operator=(const WebDataServiceFactoryEfl&) = delete;
 };
 
 #endif // TIZEN_AUTOFILL_SUPPORT
index ff0ea68..42348cf 100644 (file)
@@ -8,11 +8,13 @@
 #include "base/files/file_util.h"
 #include "base/path_service.h"
 #include "base/synchronization/waitable_event.h"
+#include "browser/autofill/autocomplete_history_manager_factory.h"
 #include "browser/autofill/personal_data_manager_factory.h"
 #include "browser/background_sync_controller_efl.h"
 #include "browser/geolocation/geolocation_permission_context_efl.h"
 #include "browser/webdata/web_data_service_factory.h"
 #include "components/autofill/core/browser/personal_data_manager.h"
+#include "components/autofill/core/common/autofill_prefs.h"
 #include "components/password_manager/core/common/password_manager_pref_names.h"
 #include "components/prefs/in_memory_pref_store.h"
 #include "components/prefs/pref_registry_simple.h"
@@ -29,7 +31,7 @@
 #include "network_delegate_efl.h"
 #include "permission_controller_delegate_efl.h"
 
-using namespace prefs;
+using namespace autofill::prefs;
 using namespace password_manager::prefs;
 using std::pair;
 
@@ -58,8 +60,10 @@ BrowserContextEfl::ResourceContextEfl::ResourceContextEfl(
 BrowserContextEfl::~BrowserContextEfl() {
   NotifyWillBeDestroyed();
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-  autofill::PersonalDataManagerFactory::GetInstance()
+  autofill::PersonalDataManagerFactoryEfl::GetInstance()
       ->PersonalDataManagerRemove(this);
+  autofill::AutocompleteHistoryManagerFactoryEfl::GetInstance()
+      ->AutocompleteHistoryManagerRemove(this);
 #endif
   ShutdownStoragePartitions();
   if (resource_context_)
@@ -134,11 +138,16 @@ BrowserContextEfl::BrowserContextEfl(EWebContext* web_context, bool incognito)
 
   PrefRegistrySimple* pref_registry = new PrefRegistrySimple();
 
-#if !defined(EWK_BRINGUP)  // FIXME: m71 bringup
-  pref_registry->RegisterBooleanPref(kAutofillEnabled, true);
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  // autofill preferences
+  pref_registry->RegisterBooleanPref(kAutofillProfileEnabled, true);
   pref_registry->RegisterBooleanPref(kAutofillWalletImportEnabled, true);
-#endif
+  pref_registry->RegisterBooleanPref(kAutofillCreditCardEnabled, true);
+
+  // password manager preferences
   pref_registry->RegisterBooleanPref(kCredentialsEnableService, true);
+  pref_registry->RegisterBooleanPref(kCredentialsEnableAutosignin, true);
+#endif
 
   PrefServiceFactory pref_service_factory;
   pref_service_factory.set_user_prefs(
@@ -150,8 +159,10 @@ BrowserContextEfl::BrowserContextEfl(EWebContext* web_context, bool incognito)
   user_prefs::UserPrefs::Set(this, user_pref_service_.get());
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-  autofill::PersonalDataManagerFactory::GetInstance()->PersonalDataManagerAdd(
-      this);
+  autofill::PersonalDataManagerFactoryEfl::GetInstance()
+      ->PersonalDataManagerAdd(this);
+  autofill::AutocompleteHistoryManagerFactoryEfl::GetInstance()
+      ->AutocompleteHistoryManagerAdd(this);
 #endif
 #if !defined(EWK_BRINGUP)  // FIXME: m85 bringup
   BrowserContext::Initialize(this, GetPath());
index 8ed5784..63b9e7d 100644 (file)
@@ -13,6 +13,7 @@
 #include "base/logging.h"
 #include "cc/base/switches.h"
 #include "common/content_switches_efl.h"
+#include "components/autofill/core/common/autofill_switches.h"
 #include "components/viz/common/switches.h"
 #include "content/public/common/content_client.h"
 #include "content/public/common/content_switches.h"
index 837b144..00ab5fa 100644 (file)
 #include "common/content_switches_efl.h"
 #include "common/version_info.h"
 #include "common/web_contents_utils.h"
+#include "components/autofill/content/browser/content_autofill_driver_factory.h"
 #include "components/error_page/common/error.h"
 #include "components/error_page/common/localized_error.h"
+#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
 #include "content/public/browser/browser_thread.h"
 #include "content/public/browser/navigation_handle.h"
 #include "content/public/browser/render_process_host.h"
 #include "content/public/common/content_switches.h"
 #include "devtools_manager_delegate_efl.h"
 #include "eweb_context.h"
+#include "mojo/public/cpp/bindings/pending_associated_receiver.h"
 #include "services/network/public/cpp/features.h"
 #include "shared_url_loader_factory_efl.h"
 #include "web_contents_delegate_efl.h"
 #include "web_contents_view_delegate_ewk.h"
 
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+#include "components/autofill/core/common/autofill_switches.h"
+#endif
+
 #if BUILDFLAG(IS_TIZEN)
 #include <vconf.h>
 #include "content/browser/speech/tts_message_filter_efl.h"
@@ -487,6 +494,35 @@ ContentBrowserClientEfl::GetWebContentsViewDelegate(WebContents* web_contents) {
       WebViewFromWebContents(web_contents));
 }
 
+bool ContentBrowserClientEfl::BindAssociatedReceiverFromFrame(
+    RenderFrameHost* render_frame_host,
+    const std::string& interface_name,
+    mojo::ScopedInterfaceEndpointHandle* handle) {
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  if (base::CommandLine::ForCurrentProcess()->HasSwitch(
+          autofill::switches::kDisableAutofill)) {
+    return false;
+  }
+
+  if (interface_name == autofill::mojom::AutofillDriver::Name_) {
+    autofill::ContentAutofillDriverFactory::BindAutofillDriver(
+        mojo::PendingAssociatedReceiver<autofill::mojom::AutofillDriver>(
+            std::move(*handle)),
+        render_frame_host);
+    return true;
+  }
+  if (interface_name == autofill::mojom::PasswordManagerDriver::Name_) {
+    password_manager::ContentPasswordManagerDriverFactory::
+        BindPasswordManagerDriver(
+            mojo::PendingAssociatedReceiver<
+                autofill::mojom::PasswordManagerDriver>(std::move(*handle)),
+            render_frame_host);
+    return true;
+  }
+#endif
+  return false;
+}
+
 scoped_refptr<QuotaPermissionContext>
 ContentBrowserClientEfl::CreateQuotaPermissionContext() {
   return new QuotaPermissionContextEfl();
index 5ba1b1a..3482caa 100644 (file)
@@ -8,6 +8,7 @@
 #include "content/public/browser/browser_context.h"
 #include "content/public/browser/content_browser_client.h"
 #include "net/cookies/canonical_cookie.h"
+#include "services/service_manager/public/cpp/binder_registry.h"
 #include "third_party/blink/public/common/loader/url_loader_throttle.h"
 #include "third_party/blink/public/web/web_window_features.h"
 
@@ -123,6 +124,12 @@ class ContentBrowserClientEfl : public ContentBrowserClient {
       scoped_refptr<net::HttpResponseHeaders> response_headers,
       bool first_auth_attempt,
       LoginAuthRequiredCallback auth_required_callback) override;
+
+  bool BindAssociatedReceiverFromFrame(
+      RenderFrameHost* render_frame_host,
+      const std::string& interface_name,
+      mojo::ScopedInterfaceEndpointHandle* handle) override;
+
   std::string GetProduct() override;
   std::string GetUserAgent() override;
   NotificationControllerEfl* GetNotificationController() const;
index 6e0ef15..6c33ec4 100644 (file)
 #include "base/synchronization/waitable_event.h"
 #include "base/task/thread_pool.h"
 #include "browser/favicon/favicon_database.h"
+#include "browser/password_manager/password_helper_efl.h"
 #include "browser/tizen_extensible_host.h"
 #include "browser/webdata/web_data_service_factory.h"
 #include "components/autofill/content/browser/content_autofill_driver.h"
+#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
+#include "components/password_manager/core/browser/password_form.h"
+#include "components/password_manager/core/browser/password_store.h"
 #include "content/public/browser/browser_context.h"
 #include "content/public/browser/browser_task_traits.h"
 #include "content/public/browser/browser_thread.h"
@@ -193,6 +197,24 @@ void OnGetFileSystemOrigins(
                              base::BindOnce(callback, origin_list, user_data));
 }
 
+void OnGetPasswordDataList(
+    Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+    void* user_data,
+    const std::vector<std::unique_ptr<password_manager::PasswordForm>>&
+        results) {
+  Eina_List* list = nullptr;
+
+  for (const auto& form : results) {
+    auto data = new Ewk_Password_Data;
+    data->url = strdup(form->federation_origin.Serialize().c_str());
+    // NOTE: Fingerprint is not supported yet, so it is always FALSE.
+    data->useFingerprint = EINA_FALSE;
+    list = eina_list_append(list, data);
+  }
+
+  callback(list, user_data);
+}
+
 }  // namespace
 
 void EwkDidStartDownloadCallback::TriggerCallback(const string& url) {
@@ -727,8 +749,8 @@ void EWebContext::ClearCandidateData() {
                                               base::Unretained(this)));
     return;
   }
-  WebDataServiceFactory* webDataServiceInstance =
-      WebDataServiceFactory::GetInstance();
+  WebDataServiceFactoryEfl* webDataServiceInstance =
+      WebDataServiceFactoryEfl::GetInstance();
   scoped_refptr<autofill::AutofillWebDataService> autofillWebDataService =
       webDataServiceInstance->GetAutofillWebDataForProfile();
   if (autofillWebDataService.get()) {
@@ -746,11 +768,31 @@ void EWebContext::ClearCandidateData() {
 
 void EWebContext::ClearPasswordData() {
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-  scoped_refptr<password_manager::PasswordStore> store =
-      password_manager::PasswordStoreFactory::GetPasswordStore();
-  if (store.get())
-    store->RemoveLoginsCreatedBetween(base::Time(), base::Time::Max(),
-                                      base::Closure());
+  password_helper::RemoveLogins(
+      password_manager::PasswordStoreFactory::GetProfilePasswordStore());
+#else
+  DLOG(WARNING) << "TIZEN_AUTOFILL_SUPPORT is not enabled";
+#endif
+}
+
+void EWebContext::ClearPasswordDataForUrl(const char* url) {
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  password_helper::RemoveLogin(
+      password_manager::PasswordStoreFactory::GetProfilePasswordStore(),
+      GURL(url));
+#else
+  DLOG(WARNING) << "TIZEN_AUTOFILL_SUPPORT is not enabled";
+#endif
+}
+
+void EWebContext::GetPasswordDataList(
+    Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+    void* user_data) {
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  password_helper::GetLogins(
+      password_manager::PasswordStoreFactory::GetProfilePasswordStore(),
+      base::BindRepeating(&OnGetPasswordDataList, base::Unretained(callback),
+                          base::Unretained(user_data)));
 #else
   DLOG(WARNING) << "TIZEN_AUTOFILL_SUPPORT is not enabled";
 #endif
index 560b3aa..b43a6fb 100644 (file)
@@ -149,6 +149,11 @@ class EWebContext {
 
   void ClearCandidateData();
   void ClearPasswordData();
+  void ClearPasswordDataForUrl(const char* url);
+  void GetPasswordDataList(
+      Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+      void* user_data);
+
   EwkFaviconDatabase* GetFaviconDatabase() const {
     return ewk_favicon_database_.get();
   }
index 182d00a..7f09a38 100644 (file)
@@ -21,7 +21,7 @@
 #include "private/ewk_context_private.h"
 
 namespace autofill {
-class PersonalDataManagerFactory;
+class PersonalDataManagerFactoryEfl;
 }
 
 namespace {
@@ -70,14 +70,8 @@ static std::map<DataType, autofill::ServerFieldType> create_EWK_to_Autofill_prof
   profile_map[PROFILE_CITY_TOWN] = autofill::ADDRESS_HOME_CITY;
   profile_map[PROFILE_STATE_PROVINCE_REGION] = autofill::ADDRESS_HOME_STATE;
   profile_map[PROFILE_ZIPCODE] = autofill::ADDRESS_HOME_ZIP;
-
-  // ADDRESS_HOME_COUNTRY is not saved in the database, so we use
-  // ADDRESS_BILLING_DEPENDENT_LOCALITY instead, that isn't used
-  profile_map[PROFILE_COUNTRY] = autofill::ADDRESS_BILLING_DEPENDENT_LOCALITY;
-
-  // PHONE_HOME_WHOLE_NUMBER is not saved in the database, so we use
-  // ADDRESS_BILLING_LINE3 instead, that isn't used
-  profile_map[PROFILE_PHONE] = autofill::ADDRESS_BILLING_LINE3;
+  profile_map[PROFILE_COUNTRY] = autofill::ADDRESS_HOME_COUNTRY;
+  profile_map[PROFILE_PHONE] = autofill::PHONE_HOME_WHOLE_NUMBER;
   profile_map[PROFILE_EMAIL] = autofill::EMAIL_ADDRESS;
   return profile_map;
 }
@@ -90,8 +84,11 @@ void to_Autofill_Profile_set_data(const Ewk_Autofill_Profile* oldStyleProfile,
   static std::map<DataType, autofill::ServerFieldType> profile_map =
       create_EWK_to_Autofill_profile_map();
   if (0 < (value = oldStyleProfile->get16Data(DataName)).length()) {
-    ret.SetInfo(autofill::AutofillType(profile_map.find(DataName)->second),
-        value, locale);
+    if (DataName == PROFILE_NAME || DataName == PROFILE_COUNTRY) {
+      ret.SetInfo(autofill::AutofillType(profile_map.find(DataName)->second),
+                  value, locale);
+    } else
+      ret.SetRawInfo(profile_map.find(DataName)->second, value);
   }
 }
 
@@ -146,11 +143,15 @@ void to_EWK_Profile_set_data(const autofill::AutofillProfile& newStyleProfile,
   std::u16string value;
   static std::map<autofill::ServerFieldType, DataType> profile_map =
       create_Autofill_to_EWK_profile_map();
-  if (0 < (value = newStyleProfile.GetInfo(autofill::AutofillType(
-      DataName), locale)).length()) {
-    ret->setData(profile_map.find(DataName)->second,
-        base::UTF16ToASCII(value));
+  if (DataName == autofill::NAME_FULL ||
+      DataName == autofill::ADDRESS_HOME_COUNTRY) {
+    value = newStyleProfile.GetInfo(autofill::AutofillType(DataName), locale);
+  } else {
+    value = newStyleProfile.GetRawInfo(DataName);
   }
+
+  if (value.length())
+    ret->setData(profile_map.find(DataName)->second, base::UTF16ToASCII(value));
 }
 
 Ewk_Autofill_Profile* to_Ewk_Autofill_Profile(
@@ -174,16 +175,10 @@ Ewk_Autofill_Profile* to_Ewk_Autofill_Profile(
       autofill::ADDRESS_HOME_STATE, locale, ret);
   to_EWK_Profile_set_data(newStyleProfile,
       autofill::ADDRESS_HOME_ZIP, locale, ret);
-
-  // ADDRESS_HOME_COUNTRY is not saved in the database, so we use
-  // ADDRESS_BILLING_DEPENDENT_LOCALITY instead, that isn't used
-  to_EWK_Profile_set_data(newStyleProfile,
-      autofill::ADDRESS_BILLING_DEPENDENT_LOCALITY, locale, ret);
-
-  // PHONE_HOME_WHOLE_NUMBER is not saved in the database, so we use
-  // ADDRESS_BILLING_LINE3 instead, that isn't used
-  to_EWK_Profile_set_data(newStyleProfile,
-      autofill::ADDRESS_BILLING_LINE3, locale, ret);
+  to_EWK_Profile_set_data(newStyleProfile, autofill::ADDRESS_HOME_COUNTRY,
+                          locale, ret);
+  to_EWK_Profile_set_data(newStyleProfile, autofill::PHONE_HOME_WHOLE_NUMBER,
+                          locale, ret);
   to_EWK_Profile_set_data(newStyleProfile,
       autofill::EMAIL_ADDRESS, locale, ret);
   return ret;
@@ -193,8 +188,8 @@ autofill::PersonalDataManager* PersonalDataManagerForEWKContext(
     Ewk_Context* ewk_context) {
   EINA_SAFETY_ON_NULL_RETURN_VAL(ewk_context, nullptr);
 
-  autofill::PersonalDataManagerFactory* personal_data_manager_factory =
-      autofill::PersonalDataManagerFactory::GetInstance();
+  autofill::PersonalDataManagerFactoryEfl* personal_data_manager_factory =
+      autofill::PersonalDataManagerFactoryEfl::GetInstance();
   content::BrowserContext* context = ewk_context->browser_context();
   EINA_SAFETY_ON_NULL_RETURN_VAL(context, nullptr);
 
@@ -287,8 +282,8 @@ void
 EwkContextFormAutofillProfileManager::priv_form_autofill_profile_changed_callback_set(
     Ewk_Context_Form_Autofill_Profile_Changed_Callback callback,
     void* user_data) {
-  autofill::PersonalDataManagerFactory* personalDataManagerFactory =
-      autofill::PersonalDataManagerFactory::GetInstance();
+  autofill::PersonalDataManagerFactoryEfl* personalDataManagerFactory =
+      autofill::PersonalDataManagerFactoryEfl::GetInstance();
   personalDataManagerFactory->SetCallback(callback, user_data);
 }
 
index f10f434..922eb92 100644 (file)
@@ -247,6 +247,16 @@ void Ewk_Context::ClearPasswordData() {
   impl->ClearPasswordData();
 }
 
+void Ewk_Context::ClearPasswordDataForUrl(const char* url) {
+  impl->ClearPasswordDataForUrl(url);
+}
+
+void Ewk_Context::GetPasswordDataList(
+    Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+    void* user_data) {
+  impl->GetPasswordDataList(callback, user_data);
+}
+
 unsigned int Ewk_Context::InspectorServerStart(unsigned int port) const {
   return impl->InspectorServerStart(port);
 }
index d6daffc..ee969bf 100644 (file)
@@ -113,6 +113,10 @@ struct Ewk_Context : public base::RefCounted<Ewk_Context> {
 
   // Password
   void ClearPasswordData();
+  void ClearPasswordDataForUrl(const char* url);
+  void GetPasswordDataList(
+      Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+      void* user_data);
 
   // Extensible
   bool SetExtensibleAPI(const std::string& api_name, bool enable);
index 358a967..3353d91 100644 (file)
@@ -411,18 +411,30 @@ void ewk_context_form_password_data_delete_all(Ewk_Context* context)
 
 void ewk_context_form_password_data_delete(Ewk_Context* ewkContext, const char* url)
 {
-  LOG_EWK_API_MOCKUP();
+  EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+  EINA_SAFETY_ON_NULL_RETURN(url);
+  ewkContext->ClearPasswordDataForUrl(url);
 }
 
-Eina_List* ewk_context_form_password_data_list_get(Ewk_Context* ewkContext)
-{
-  LOG_EWK_API_MOCKUP();
-  return NULL;
+void ewk_context_form_password_data_list_get(
+    Ewk_Context* ewkContext,
+    Ewk_Context_Form_Password_Data_List_Get_Callback callback,
+    void* user_data) {
+  EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+  EINA_SAFETY_ON_NULL_RETURN(callback);
+  ewkContext->GetPasswordDataList(callback, user_data);
 }
 
 void ewk_context_form_password_data_list_free(Ewk_Context* ewkContext, Eina_List* list)
 {
-  LOG_EWK_API_MOCKUP();
+  EINA_SAFETY_ON_NULL_RETURN(ewkContext);
+  EINA_SAFETY_ON_NULL_RETURN(list);
+
+  void* item;
+  EINA_LIST_FREE(list, item) {
+    delete[] (static_cast<Ewk_Password_Data*>(item))->url;
+    delete static_cast<Ewk_Password_Data*>(item);
+  }
 }
 
 void ewk_context_form_candidate_data_delete_all(Ewk_Context* context)
@@ -789,11 +801,6 @@ void ewk_context_password_confirm_popup_reply(Ewk_Context* context, Ewk_Context_
   LOG_EWK_API_MOCKUP();
 }
 
-void ewk_context_form_password_data_list_get(Ewk_Context* context, Ewk_Context_Form_Password_Data_List_Get_Callback callback, void* user_data)
-{
-  LOG_EWK_API_MOCKUP();
-}
-
 void ewk_context_icon_database_delete_all(Ewk_Context* context)
 {
   LOG_EWK_API_MOCKUP();
index aaf4c52..b182d0b 100644 (file)
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 #include "components/autofill/content/renderer/autofill_agent.h"
+#include "components/autofill/content/renderer/autofill_assistant_agent.h"
 #include "components/autofill/content/renderer/password_autofill_agent.h"
 #include "components/autofill/content/renderer/password_generation_agent.h"
+#include "components/autofill/core/common/autofill_switches.h"
 #include "components/autofill/core/common/password_generation_util.h"
 #endif
 
@@ -66,6 +68,7 @@
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
 using autofill::AutofillAgent;
+using autofill::AutofillAssistantAgent;
 using autofill::PasswordAutofillAgent;
 using autofill::PasswordGenerationAgent;
 #endif
@@ -146,19 +149,29 @@ void ContentRendererClientEfl::RenderThreadStarted() {
 }
 
 void ContentRendererClientEfl::RenderFrameCreated(content::RenderFrame* render_frame) {
-  new content::RenderFrameObserverEfl(render_frame);
+  content::RenderFrameObserverEfl* render_frame_observer =
+      new content::RenderFrameObserverEfl(render_frame);
   new content::ContentSettingsClientEfl(render_frame);
   // Deletes itself when render_frame is destroyed.
   new content::GinNativeBridgeDispatcher(render_frame);
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-  PasswordAutofillAgent* password_autofill_agent =
-      new PasswordAutofillAgent(render_frame);
-  PasswordGenerationAgent* password_generation_agent =
-      new PasswordGenerationAgent(render_frame, password_autofill_agent);
-  new AutofillAgent(render_frame,
-                    password_autofill_agent,
-                    password_generation_agent);
+  if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+          autofill::switches::kDisableAutofill)) {
+    blink::AssociatedInterfaceRegistry* registry =
+        render_frame_observer->associated_interfaces();
+
+    AutofillAssistantAgent* autofill_assistant_agent =
+        new AutofillAssistantAgent(render_frame);
+    PasswordAutofillAgent* password_autofill_agent =
+        new PasswordAutofillAgent(render_frame, registry);
+    PasswordGenerationAgent* password_generation_agent =
+        new PasswordGenerationAgent(render_frame, password_autofill_agent,
+                                    registry);
+    new AutofillAgent(render_frame, password_autofill_agent,
+                      password_generation_agent, autofill_assistant_agent,
+                      registry);
+  }
 #endif
 }
 
index 170608a..f5f3208 100644 (file)
@@ -62,6 +62,18 @@ RenderFrameObserverEfl::RenderFrameObserverEfl(RenderFrame* render_frame)
 RenderFrameObserverEfl::~RenderFrameObserverEfl() {
 }
 
+void RenderFrameObserverEfl::OnInterfaceRequestForFrame(
+    const std::string& interface_name,
+    mojo::ScopedMessagePipeHandle* interface_pipe) {
+  registry_.TryBindInterface(interface_name, interface_pipe);
+}
+
+bool RenderFrameObserverEfl::OnAssociatedInterfaceRequestForFrame(
+    const std::string& interface_name,
+    mojo::ScopedInterfaceEndpointHandle* handle) {
+  return associated_interfaces_.TryBindInterface(interface_name, handle);
+}
+
 void RenderFrameObserverEfl::OnDestruct() {
   delete this;
 }
index ebd5523..9b56cb3 100644 (file)
@@ -8,6 +8,8 @@
 #include <vector>
 
 #include "content/public/renderer/render_frame_observer.h"
+#include "services/service_manager/public/cpp/binder_registry.h"
+#include "third_party/blink/public/common/associated_interfaces/associated_interface_registry.h"
 #include "ui/gfx/geometry/size.h"
 
 namespace blink {
@@ -21,11 +23,25 @@ class RenderFrameImpl;
 class RenderFrameObserverEfl : public RenderFrameObserver {
  public:
   explicit RenderFrameObserverEfl(RenderFrame* render_frame);
-  virtual ~RenderFrameObserverEfl();
+  ~RenderFrameObserverEfl() override;
+
+  RenderFrameObserverEfl(const RenderFrameObserverEfl&) = delete;
+  RenderFrameObserverEfl& operator=(const RenderFrameObserverEfl&) = delete;
+
+  service_manager::BinderRegistry* registry() { return &registry_; }
+  blink::AssociatedInterfaceRegistry* associated_interfaces() {
+    return &associated_interfaces_;
+  }
+
+  void OnInterfaceRequestForFrame(
+      const std::string& interface_name,
+      mojo::ScopedMessagePipeHandle* interface_pipe) override;
+  bool OnAssociatedInterfaceRequestForFrame(
+      const std::string& interface_name,
+      mojo::ScopedInterfaceEndpointHandle* handle) override;
 
   void OnDestruct() override;
 
-  // IPC::Listener implementation.
   bool OnMessageReceived(const IPC::Message& message) override;
 
   void DidChangeScrollOffset() override;
@@ -50,6 +66,8 @@ class RenderFrameObserverEfl : public RenderFrameObserver {
   gfx::Size max_scroll_offset_;
   gfx::Size last_scroll_offset_;
   gfx::Size last_sent_contents_size_;
+  service_manager::BinderRegistry registry_;
+  blink::AssociatedInterfaceRegistry associated_interfaces_;
 };
 
 } // namespace content
index c1d6e59..16b6108 100644 (file)
 #endif
 
 #if defined(TIZEN_AUTOFILL_SUPPORT)
+#include "base/command_line.h"
 #include "browser/autofill/autofill_client_efl.h"
-#include "components/autofill/content/browser/content_autofill_driver_factory.h"
 #include "browser/password_manager/password_manager_client_efl.h"
+#include "components/autofill/content/browser/content_autofill_driver_factory.h"
 #include "components/autofill/core/browser/autofill_client.h"
 #include "components/autofill/core/browser/autofill_manager.h"
+#include "components/autofill/core/common/autofill_switches.h"
 #include "components/web_modal/web_contents_modal_dialog_manager.h"
 
 using autofill::AutofillManager;
@@ -86,15 +88,19 @@ WebContentsDelegateEfl::WebContentsDelegateEfl(EWebView* view)
       web_contents_(view->web_contents()),
       contents_observer_(std::make_unique<WebContentsObserverEfl>(view, this)) {
 #if defined(TIZEN_AUTOFILL_SUPPORT)
-  AutofillClientEfl::CreateForWebContents(&web_contents_);
-  AutofillClientEfl* autofill_client =
-      AutofillClientEfl::FromWebContents(&web_contents_);
-  autofill_client->SetEWebView(view);
-  PasswordManagerClientEfl::CreateForWebContentsWithAutofillClient(
-      &web_contents_, autofill_client);
-  ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
-      &web_contents_, autofill_client, EWebView::GetPlatformLocale(),
-      AutofillManager::DISABLE_AUTOFILL_DOWNLOAD_MANAGER);
+  if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
+          autofill::switches::kDisableAutofill)) {
+    AutofillClientEfl::CreateForWebContents(&web_contents_);
+    AutofillClientEfl* autofill_client =
+        AutofillClientEfl::FromWebContents(&web_contents_);
+    autofill_client->SetEWebView(view);
+    PasswordManagerClientEfl::CreateForWebContentsWithAutofillClient(
+        &web_contents_, autofill_client);
+    ContentAutofillDriverFactory::CreateForWebContentsAndDelegate(
+        &web_contents_, autofill_client,
+        base::BindRepeating(&autofill::BrowserDriverInitHook, autofill_client,
+                            EWebView::GetPlatformLocale()));
+  }
 #endif
 }
 
@@ -410,6 +416,25 @@ void WebContentsDelegateEfl::SetContentSecurityPolicy(
   contents_observer_->SetContentSecurityPolicy(policy, header_type);
 }
 
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+void WebContentsDelegateEfl::UpdateAutofillIfRequired() {
+  if (AutofillClientEfl* autofill_client =
+          AutofillClientEfl::FromWebContents(&web_contents_)) {
+    autofill_client->UpdateAutofillIfRequired();
+  }
+}
+#endif
+
+void WebContentsDelegateEfl::OnDidChangeFocusedNodeBounds(
+    const gfx::RectF& focused_node_bounds) {
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  if (AutofillClientEfl* autofill_client =
+          AutofillClientEfl::FromWebContents(&web_contents_)) {
+    autofill_client->DidChangeFocusedNodeBounds(focused_node_bounds);
+  }
+#endif
+}
+
 void WebContentsDelegateEfl::FindReply(WebContents* web_contents,
                                        int request_id,
                                        int number_of_matches,
@@ -452,7 +477,7 @@ void WebContentsDelegateEfl::OnUpdateSettings(const Ewk_Settings* settings) {
       PasswordManagerClientEfl::FromWebContents(&web_contents_);
   if (client) {
     PrefService* prefs = client->GetPrefs();
-    prefs->SetBoolean(password_manager::prefs::kPasswordManagerSavingEnabled,
+    prefs->SetBoolean(password_manager::prefs::kCredentialsEnableService,
                       settings->autofillPasswordForm());
   }
 #endif
index add0161..dcb7068 100644 (file)
@@ -138,12 +138,15 @@ class WebContentsDelegateEfl : public WebContentsDelegate {
                               MediaResponseCallback callback);
 #endif
 
+#if defined(TIZEN_AUTOFILL_SUPPORT)
+  void UpdateAutofillIfRequired();
+#endif
  private:
   void OnDidGetManifest(Ewk_View_Request_Manifest_Callback callback,
                         void* user_data,
                         const GURL& manifest_url,
                         blink::mojom::ManifestPtr manifest);
-
+  void OnDidChangeFocusedNodeBounds(const gfx::RectF& focused_node_bounds);
   EWebView* web_view_;
   bool is_fullscreen_;
   WebContents& web_contents_;
index d5d0875..686e21d 100644 (file)
@@ -1169,6 +1169,15 @@ std::u16string ResourceBundle::GetLocalizedStringImpl(int resource_id) const {
       // Fall back on the main data pack (shouldn't be any strings here except
       // in unittests).
       data = GetRawDataResource(resource_id);
+#if BUILDFLAG(IS_EFL)
+      // Accessing autofill component resources causes crash in chromium-efl.
+      // Hence we retain the code same as M85 for now.
+      if (data.empty()) {
+        LOG(WARNING) << "unable to find resource: " << resource_id;
+        NOTREACHED();
+        return std::u16string();
+      }
+#else
       CHECK(!data.empty())
           << "Unable to find resource: " << resource_id
           << ". If this happens in a browser test running on Windows, it may "
@@ -1176,6 +1185,7 @@ std::u16string ResourceBundle::GetLocalizedStringImpl(int resource_id) const {
              " resource, causing the resource to be stripped out because the "
              "resource is not used by chrome.dll. See "
              "https://crbug.com/1181150.";
+#endif
     }
   }