diff --git a/filenames.gni b/filenames.gni index 20ce1b16667f..62fe494f959c 100644 --- a/filenames.gni +++ b/filenames.gni @@ -125,6 +125,10 @@ filenames = { "shell/browser/auto_updater.cc", "shell/browser/auto_updater.h", "shell/browser/auto_updater_mac.mm", + "shell/browser/atom_autofill_driver_factory.cc", + "shell/browser/atom_autofill_driver_factory.h", + "shell/browser/atom_autofill_driver.cc", + "shell/browser/atom_autofill_driver.h", "shell/browser/atom_blob_reader.cc", "shell/browser/atom_blob_reader.h", "shell/browser/atom_browser_client.cc", diff --git a/shell/browser/api/atom_api_web_contents.cc b/shell/browser/api/atom_api_web_contents.cc index 66644b7ea587..91c501eb2485 100644 --- a/shell/browser/api/atom_api_web_contents.cc +++ b/shell/browser/api/atom_api_web_contents.cc @@ -50,6 +50,7 @@ #include "shell/browser/api/atom_api_browser_window.h" #include "shell/browser/api/atom_api_debugger.h" #include "shell/browser/api/atom_api_session.h" +#include "shell/browser/atom_autofill_driver_factory.h" #include "shell/browser/atom_browser_client.h" #include "shell/browser/atom_browser_context.h" #include "shell/browser/atom_browser_main_parts.h" @@ -471,6 +472,7 @@ void WebContents::InitWithSessionAndOptions( base::Unretained(this))); bindings_.set_connection_error_handler(base::BindRepeating( &WebContents::OnElectronBrowserConnectionError, base::Unretained(this))); + AutofillDriverFactory::CreateForWebContents(web_contents()); web_contents()->SetUserAgentOverride(GetBrowserContext()->GetUserAgent(), false); @@ -626,7 +628,13 @@ void WebContents::SetContentsBounds(content::WebContents* source, void WebContents::CloseContents(content::WebContents* source) { Emit("close"); - HideAutofillPopup(); + + auto* autofill_driver_factory = + AutofillDriverFactory::FromWebContents(web_contents()); + if (autofill_driver_factory) { + autofill_driver_factory->CloseAllPopups(); + } + if (managed_web_contents()) managed_web_contents()->GetView()->SetDelegate(nullptr); for (ExtendedWebContentsObserver& observer : observers_) @@ -1153,26 +1161,6 @@ void WebContents::DevToolsClosed() { Emit("devtools-closed"); } -void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host, - const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels) { - bool offscreen = IsOffScreen() || (embedder_ && embedder_->IsOffScreen()); - gfx::RectF popup_bounds(bounds); - content::RenderFrameHost* embedder_frame_host = nullptr; - if (embedder_) { - auto* embedder_view = embedder_->web_contents()->GetMainFrame()->GetView(); - auto* view = web_contents()->GetMainFrame()->GetView(); - auto offset = view->GetViewBounds().origin() - - embedder_view->GetViewBounds().origin(); - popup_bounds.Offset(offset.x(), offset.y()); - embedder_frame_host = embedder_->web_contents()->GetMainFrame(); - } - - CommonWebContentsDelegate::ShowAutofillPopup( - frame_host, embedder_frame_host, offscreen, popup_bounds, values, labels); -} - bool WebContents::OnMessageReceived(const IPC::Message& message) { bool handled = true; IPC_BEGIN_MESSAGE_MAP(WebContents, message) @@ -2214,17 +2202,6 @@ void WebContents::DoGetZoomLevel(DoGetZoomLevelCallback callback) { std::move(callback).Run(GetZoomLevel()); } -void WebContents::ShowAutofillPopup(const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels) { - content::RenderFrameHost* frame_host = bindings_.dispatch_context(); - ShowAutofillPopup(frame_host, bounds, values, labels); -} - -void WebContents::HideAutofillPopup() { - CommonWebContentsDelegate::HideAutofillPopup(); -} - std::vector WebContents::GetPreloadPaths() const { auto result = SessionPreferences::GetValidPreloads(GetBrowserContext()); @@ -2279,7 +2256,7 @@ v8::Local WebContents::Session(v8::Isolate* isolate) { return v8::Local::New(isolate, session_); } -content::WebContents* WebContents::HostWebContents() { +content::WebContents* WebContents::HostWebContents() const { if (!embedder_) return nullptr; return embedder_->web_contents(); diff --git a/shell/browser/api/atom_api_web_contents.h b/shell/browser/api/atom_api_web_contents.h index c9067a4b6b23..6ad3bf5663ab 100644 --- a/shell/browser/api/atom_api_web_contents.h +++ b/shell/browser/api/atom_api_web_contents.h @@ -14,6 +14,7 @@ #include "base/observer_list_types.h" #include "content/common/cursors/webcursor.h" #include "content/public/browser/keyboard_event_processing_result.h" +#include "content/public/browser/render_widget_host.h" #include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents_binding_set.h" #include "content/public/browser/web_contents_observer.h" @@ -27,7 +28,6 @@ #include "shell/browser/api/save_page_handler.h" #include "shell/browser/api/trackable_object.h" #include "shell/browser/common_web_contents_delegate.h" -#include "shell/browser/ui/autofill_popup.h" #include "ui/gfx/image/image.h" #if BUILDFLAG(ENABLE_PRINTING) @@ -305,7 +305,7 @@ class WebContents : public mate::TrackableObject, // Properties. int32_t ID() const; v8::Local Session(v8::Isolate* isolate); - content::WebContents* HostWebContents(); + content::WebContents* HostWebContents() const; v8::Local DevToolsWebContents(v8::Isolate* isolate); v8::Local Debugger(v8::Isolate* isolate); @@ -323,6 +323,8 @@ class WebContents : public mate::TrackableObject, bool EmitNavigationEvent(const std::string& event, content::NavigationHandle* navigation_handle); + WebContents* embedder() { return embedder_; } + protected: // Does not manage lifetime of |web_contents|. WebContents(v8::Isolate* isolate, content::WebContents* web_contents); @@ -469,13 +471,6 @@ class WebContents : public mate::TrackableObject, void DevToolsOpened() override; void DevToolsClosed() override; -#if defined(TOOLKIT_VIEWS) - void ShowAutofillPopup(content::RenderFrameHost* frame_host, - const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels); -#endif - private: AtomBrowserContext* GetBrowserContext() const; @@ -514,11 +509,6 @@ class WebContents : public mate::TrackableObject, void SetTemporaryZoomLevel(double level) override; void DoGetZoomLevel(DoGetZoomLevelCallback callback) override; - void ShowAutofillPopup(const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels) override; - void HideAutofillPopup() override; - // Called when we receive a CursorChange message from chromium. void OnCursorChange(const content::WebCursor& cursor); diff --git a/shell/browser/atom_autofill_driver.cc b/shell/browser/atom_autofill_driver.cc new file mode 100644 index 000000000000..dd6bedf4d41e --- /dev/null +++ b/shell/browser/atom_autofill_driver.cc @@ -0,0 +1,63 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/atom_autofill_driver.h" + +#include + +#include "content/public/browser/render_widget_host_view.h" +#include "shell/browser/api/atom_api_web_contents.h" +#include "shell/browser/native_window.h" + +namespace electron { + +AutofillDriver::AutofillDriver( + content::RenderFrameHost* render_frame_host, + mojom::ElectronAutofillDriverAssociatedRequest request) + : render_frame_host_(render_frame_host), binding_(this) { + autofill_popup_.reset(new AutofillPopup()); + binding_.Bind(std::move(request)); +} + +AutofillDriver::~AutofillDriver() {} + +void AutofillDriver::ShowAutofillPopup( + const gfx::RectF& bounds, + const std::vector& values, + const std::vector& labels) { + auto* web_contents = + api::WebContents::From( + v8::Isolate::GetCurrent(), + content::WebContents::FromRenderFrameHost(render_frame_host_)) + .get(); + if (!web_contents || !web_contents->owner_window()) + return; + + auto* embedder = web_contents->embedder(); + + bool osr = + web_contents->IsOffScreen() || (embedder && embedder->IsOffScreen()); + gfx::RectF popup_bounds(bounds); + content::RenderFrameHost* embedder_frame_host = nullptr; + if (embedder) { + auto* embedder_view = embedder->web_contents()->GetMainFrame()->GetView(); + auto* view = web_contents->web_contents()->GetMainFrame()->GetView(); + auto offset = view->GetViewBounds().origin() - + embedder_view->GetViewBounds().origin(); + popup_bounds.Offset(offset.x(), offset.y()); + embedder_frame_host = embedder->web_contents()->GetMainFrame(); + } + + autofill_popup_->CreateView(render_frame_host_, embedder_frame_host, osr, + web_contents->owner_window()->content_view(), + bounds); + autofill_popup_->SetItems(values, labels); +} + +void AutofillDriver::HideAutofillPopup() { + if (autofill_popup_) + autofill_popup_->Hide(); +} + +} // namespace electron diff --git a/shell/browser/atom_autofill_driver.h b/shell/browser/atom_autofill_driver.h new file mode 100644 index 000000000000..b30521491d6b --- /dev/null +++ b/shell/browser/atom_autofill_driver.h @@ -0,0 +1,44 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_H_ +#define SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_H_ + +#include +#include + +#if defined(TOOLKIT_VIEWS) +#include "shell/browser/ui/autofill_popup.h" +#endif + +#include "mojo/public/cpp/bindings/associated_binding.h" +#include "shell/common/api/api.mojom.h" + +namespace electron { + +class AutofillDriver : public mojom::ElectronAutofillDriver { + public: + AutofillDriver(content::RenderFrameHost* render_frame_host, + mojom::ElectronAutofillDriverAssociatedRequest request); + + ~AutofillDriver() override; + + void ShowAutofillPopup(const gfx::RectF& bounds, + const std::vector& values, + const std::vector& labels) override; + void HideAutofillPopup() override; + + private: + content::RenderFrameHost* const render_frame_host_; + +#if defined(TOOLKIT_VIEWS) + std::unique_ptr autofill_popup_; +#endif + + mojo::AssociatedBinding binding_; +}; + +} // namespace electron + +#endif // SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_H_ diff --git a/shell/browser/atom_autofill_driver_factory.cc b/shell/browser/atom_autofill_driver_factory.cc new file mode 100644 index 000000000000..bcac60d8c4be --- /dev/null +++ b/shell/browser/atom_autofill_driver_factory.cc @@ -0,0 +1,111 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#include "shell/browser/atom_autofill_driver_factory.h" + +#include +#include +#include + +#include "base/bind.h" +#include "base/callback.h" +#include "content/public/browser/navigation_handle.h" +#include "content/public/browser/render_frame_host.h" +#include "content/public/browser/web_contents.h" +#include "shell/browser/atom_autofill_driver.h" + +namespace electron { + +namespace { + +std::unique_ptr CreateDriver( + content::RenderFrameHost* render_frame_host, + mojom::ElectronAutofillDriverAssociatedRequest request) { + return std::make_unique(render_frame_host, + std::move(request)); +} + +} // namespace + +AutofillDriverFactory::~AutofillDriverFactory() {} + +// static +void AutofillDriverFactory::BindAutofillDriver( + mojom::ElectronAutofillDriverAssociatedRequest request, + content::RenderFrameHost* render_frame_host) { + content::WebContents* web_contents = + content::WebContents::FromRenderFrameHost(render_frame_host); + if (!web_contents) + return; + + AutofillDriverFactory* factory = + AutofillDriverFactory::FromWebContents(web_contents); + if (!factory) + return; + + AutofillDriver* driver = factory->DriverForFrame(render_frame_host); + if (!driver) + factory->AddDriverForFrame( + render_frame_host, + base::BindOnce(CreateDriver, render_frame_host, std::move(request))); +} + +AutofillDriverFactory::AutofillDriverFactory(content::WebContents* web_contents) + : content::WebContentsObserver(web_contents) { + const std::vector frames = + web_contents->GetAllFrames(); + for (content::RenderFrameHost* frame : frames) { + if (frame->IsRenderFrameLive()) + RenderFrameCreated(frame); + } +} + +void AutofillDriverFactory::RenderFrameDeleted( + content::RenderFrameHost* render_frame_host) { + DeleteDriverForFrame(render_frame_host); +} + +void AutofillDriverFactory::DidFinishNavigation( + content::NavigationHandle* navigation_handle) { + // For the purposes of this code, a navigation is not important if it has not + // committed yet or if it's in a subframe. + if (!navigation_handle->HasCommitted() || + !navigation_handle->IsInMainFrame()) { + return; + } + + CloseAllPopups(); +} + +AutofillDriver* AutofillDriverFactory::DriverForFrame( + content::RenderFrameHost* render_frame_host) { + auto mapping = driver_map_.find(render_frame_host); + return mapping == driver_map_.end() ? nullptr : mapping->second.get(); +} + +void AutofillDriverFactory::AddDriverForFrame( + content::RenderFrameHost* render_frame_host, + CreationCallback factory_method) { + auto insertion_result = + driver_map_.insert(std::make_pair(render_frame_host, nullptr)); + // This can be called twice for the key representing the main frame. + if (insertion_result.second) { + insertion_result.first->second = std::move(factory_method).Run(); + } +} + +void AutofillDriverFactory::DeleteDriverForFrame( + content::RenderFrameHost* render_frame_host) { + driver_map_.erase(render_frame_host); +} + +void AutofillDriverFactory::CloseAllPopups() { + for (auto& it : driver_map_) { + it.second->HideAutofillPopup(); + } +} + +WEB_CONTENTS_USER_DATA_KEY_IMPL(AutofillDriverFactory) + +} // namespace electron diff --git a/shell/browser/atom_autofill_driver_factory.h b/shell/browser/atom_autofill_driver_factory.h new file mode 100644 index 000000000000..bcf0b4a29cac --- /dev/null +++ b/shell/browser/atom_autofill_driver_factory.h @@ -0,0 +1,57 @@ +// Copyright (c) 2019 GitHub, Inc. +// Use of this source code is governed by the MIT license that can be +// found in the LICENSE file. + +#ifndef SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_FACTORY_H_ +#define SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_FACTORY_H_ + +#include +#include + +#include "base/callback_forward.h" +#include "content/public/browser/web_contents_observer.h" +#include "content/public/browser/web_contents_user_data.h" +#include "shell/common/api/api.mojom.h" + +namespace electron { + +class AutofillDriver; + +class AutofillDriverFactory + : public content::WebContentsObserver, + public content::WebContentsUserData { + public: + typedef base::OnceCallback()> + CreationCallback; + + ~AutofillDriverFactory() override; + + static void BindAutofillDriver( + mojom::ElectronAutofillDriverAssociatedRequest request, + content::RenderFrameHost* render_frame_host); + + // content::WebContentsObserver: + void RenderFrameDeleted(content::RenderFrameHost* render_frame_host) override; + void DidFinishNavigation( + content::NavigationHandle* navigation_handle) override; + + AutofillDriver* DriverForFrame(content::RenderFrameHost* render_frame_host); + void AddDriverForFrame(content::RenderFrameHost* render_frame_host, + CreationCallback factory_method); + void DeleteDriverForFrame(content::RenderFrameHost* render_frame_host); + + void CloseAllPopups(); + + WEB_CONTENTS_USER_DATA_KEY_DECL(); + + private: + explicit AutofillDriverFactory(content::WebContents* web_contents); + friend class content::WebContentsUserData; + + std::unordered_map> + driver_map_; +}; + +} // namespace electron + +#endif // SHELL_BROWSER_ATOM_AUTOFILL_DRIVER_FACTORY_H_ diff --git a/shell/browser/atom_browser_client.cc b/shell/browser/atom_browser_client.cc index fbb01bc6a883..75ff9bb30251 100644 --- a/shell/browser/atom_browser_client.cc +++ b/shell/browser/atom_browser_client.cc @@ -53,6 +53,7 @@ #include "shell/browser/api/atom_api_protocol_ns.h" #include "shell/browser/api/atom_api_web_contents.h" #include "shell/browser/api/atom_api_web_request_ns.h" +#include "shell/browser/atom_autofill_driver_factory.h" #include "shell/browser/atom_browser_context.h" #include "shell/browser/atom_browser_main_parts.h" #include "shell/browser/atom_navigation_throttle.h" @@ -74,6 +75,7 @@ #include "shell/browser/web_contents_permission_helper.h" #include "shell/browser/web_contents_preferences.h" #include "shell/browser/window_list.h" +#include "shell/common/api/api.mojom.h" #include "shell/common/application_info.h" #include "shell/common/options_switches.h" #include "shell/common/platform_util.h" @@ -1047,6 +1049,20 @@ bool AtomBrowserClient::PreSpawnRenderer(sandbox::TargetPolicy* policy) { } #endif // defined(OS_WIN) +bool AtomBrowserClient::BindAssociatedInterfaceRequestFromFrame( + content::RenderFrameHost* render_frame_host, + const std::string& interface_name, + mojo::ScopedInterfaceEndpointHandle* handle) { + if (interface_name == mojom::ElectronAutofillDriver::Name_) { + AutofillDriverFactory::BindAutofillDriver( + mojom::ElectronAutofillDriverAssociatedRequest(std::move(*handle)), + render_frame_host); + return true; + } + + return false; +} + std::string AtomBrowserClient::GetApplicationLocale() { if (BrowserThread::CurrentlyOn(BrowserThread::IO)) return g_io_thread_application_locale.Get(); diff --git a/shell/browser/atom_browser_client.h b/shell/browser/atom_browser_client.h index 1a40c382b4e0..de150acf2c41 100644 --- a/shell/browser/atom_browser_client.h +++ b/shell/browser/atom_browser_client.h @@ -183,6 +183,10 @@ class AtomBrowserClient : public content::ContentBrowserClient, #if defined(OS_WIN) bool PreSpawnRenderer(sandbox::TargetPolicy* policy) override; #endif + bool BindAssociatedInterfaceRequestFromFrame( + content::RenderFrameHost* render_frame_host, + const std::string& interface_name, + mojo::ScopedInterfaceEndpointHandle* handle) override; bool HandleExternalProtocol( const GURL& url, diff --git a/shell/browser/common_web_contents_delegate.cc b/shell/browser/common_web_contents_delegate.cc index d7b774ef1a49..21e9e5cdd2cc 100644 --- a/shell/browser/common_web_contents_delegate.cc +++ b/shell/browser/common_web_contents_delegate.cc @@ -214,7 +214,6 @@ void CommonWebContentsDelegate::SetOwnerWindow( NativeWindow* owner_window) { if (owner_window) { owner_window_ = owner_window->GetWeakPtr(); - autofill_popup_.reset(new AutofillPopup()); NativeWindowRelay::CreateForWebContents(web_contents, owner_window->GetWeakPtr()); } else { @@ -637,24 +636,4 @@ void CommonWebContentsDelegate::SetHtmlApiFullscreen(bool enter_fullscreen) { native_fullscreen_ = false; } -void CommonWebContentsDelegate::ShowAutofillPopup( - content::RenderFrameHost* frame_host, - content::RenderFrameHost* embedder_frame_host, - bool offscreen, - const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels) { - if (!owner_window()) - return; - - autofill_popup_->CreateView(frame_host, embedder_frame_host, offscreen, - owner_window()->content_view(), bounds); - autofill_popup_->SetItems(values, labels); -} - -void CommonWebContentsDelegate::HideAutofillPopup() { - if (autofill_popup_) - autofill_popup_->Hide(); -} - } // namespace electron diff --git a/shell/browser/common_web_contents_delegate.h b/shell/browser/common_web_contents_delegate.h index 245655d14daa..a583f8f84c46 100644 --- a/shell/browser/common_web_contents_delegate.h +++ b/shell/browser/common_web_contents_delegate.h @@ -18,10 +18,6 @@ #include "shell/browser/ui/inspectable_web_contents_impl.h" #include "shell/browser/ui/inspectable_web_contents_view_delegate.h" -#if defined(TOOLKIT_VIEWS) -#include "shell/browser/ui/autofill_popup.h" -#endif - namespace base { class SequencedTaskRunner; } @@ -107,15 +103,6 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, content::WebContents* source, const content::NativeWebKeyboardEvent& event) override; - // Autofill related events. - void ShowAutofillPopup(content::RenderFrameHost* frame_host, - content::RenderFrameHost* embedder_frame_host, - bool offscreen, - const gfx::RectF& bounds, - const std::vector& values, - const std::vector& labels); - void HideAutofillPopup(); - // InspectableWebContentsDelegate: void DevToolsSaveToFile(const std::string& url, const std::string& content, @@ -176,9 +163,6 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate, bool native_fullscreen_ = false; // UI related helper classes. -#if defined(TOOLKIT_VIEWS) - std::unique_ptr autofill_popup_; -#endif std::unique_ptr web_dialog_helper_; scoped_refptr devtools_file_system_indexer_; diff --git a/shell/common/api/api.mojom b/shell/common/api/api.mojom index a549fad71d19..1ea6345399ef 100644 --- a/shell/common/api/api.mojom +++ b/shell/common/api/api.mojom @@ -21,6 +21,11 @@ interface ElectronAutofillAgent { AcceptDataListSuggestion(mojo_base.mojom.String16 value); }; +interface ElectronAutofillDriver { + ShowAutofillPopup(gfx.mojom.RectF bounds, array values, array labels); + HideAutofillPopup(); +}; + struct DraggableRegion { bool draggable; gfx.mojom.Rect bounds; @@ -71,8 +76,4 @@ interface ElectronBrowser { [Sync] DoGetZoomLevel() => (double result); - - // TODO: move these into a separate interface - ShowAutofillPopup(gfx.mojom.RectF bounds, array values, array labels); - HideAutofillPopup(); }; diff --git a/shell/renderer/atom_autofill_agent.cc b/shell/renderer/atom_autofill_agent.cc index e111ea68df51..4a158df53098 100644 --- a/shell/renderer/atom_autofill_agent.cc +++ b/shell/renderer/atom_autofill_agent.cc @@ -9,7 +9,7 @@ #include "content/public/renderer/render_frame.h" #include "content/public/renderer/render_view.h" -#include "services/service_manager/public/cpp/interface_provider.h" +#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h" #include "third_party/blink/public/platform/web_keyboard_event.h" #include "third_party/blink/public/platform/web_string.h" #include "third_party/blink/public/web/web_document.h" @@ -182,7 +182,7 @@ bool AutofillAgent::IsUserGesture() const { } void AutofillAgent::HidePopup() { - GetElectronBrowser()->HideAutofillPopup(); + GetAutofillDriver()->HideAutofillPopup(); } void AutofillAgent::ShowPopup(const blink::WebFormControlElement& element, @@ -190,7 +190,7 @@ void AutofillAgent::ShowPopup(const blink::WebFormControlElement& element, const std::vector& labels) { gfx::RectF bounds = render_frame()->GetRenderView()->ElementBoundsInWindow(element); - GetElectronBrowser()->ShowAutofillPopup(bounds, values, labels); + GetAutofillDriver()->ShowAutofillPopup(bounds, values, labels); } void AutofillAgent::AcceptDataListSuggestion(const base::string16& suggestion) { @@ -218,13 +218,14 @@ void AutofillAgent::DoFocusChangeComplete() { focused_node_was_last_clicked_ = false; } -const mojom::ElectronBrowserPtr& AutofillAgent::GetElectronBrowser() { - if (!browser_ptr_) { - render_frame()->GetRemoteInterfaces()->GetInterface( - mojo::MakeRequest(&browser_ptr_)); +const mojom::ElectronAutofillDriverAssociatedPtr& +AutofillAgent::GetAutofillDriver() { + if (!autofill_driver_) { + render_frame()->GetRemoteAssociatedInterfaces()->GetInterface( + mojo::MakeRequest(&autofill_driver_)); } - return browser_ptr_; + return autofill_driver_; } } // namespace electron diff --git a/shell/renderer/atom_autofill_agent.h b/shell/renderer/atom_autofill_agent.h index e172cbaba622..81026ae7c18e 100644 --- a/shell/renderer/atom_autofill_agent.h +++ b/shell/renderer/atom_autofill_agent.h @@ -67,8 +67,8 @@ class AutofillAgent : public content::RenderFrameObserver, void DoFocusChangeComplete(); - const mojom::ElectronBrowserPtr& GetElectronBrowser(); - mojom::ElectronBrowserPtr browser_ptr_; + const mojom::ElectronAutofillDriverAssociatedPtr& GetAutofillDriver(); + mojom::ElectronAutofillDriverAssociatedPtr autofill_driver_; // True when the last click was on the focused node. bool focused_node_was_last_clicked_ = false;