refactor: mojofy autofill renderer->browser (#18760)
* re-implement renderer->browser calls with mojo * lint * fix: clean up after rebase * lint * fix: lazy load autofill drivers
This commit is contained in:
parent
43e6d7fe88
commit
b33558d822
14 changed files with 329 additions and 98 deletions
|
@ -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<base::string16>& values,
|
||||
const std::vector<base::string16>& 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<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) {
|
||||
content::RenderFrameHost* frame_host = bindings_.dispatch_context();
|
||||
ShowAutofillPopup(frame_host, bounds, values, labels);
|
||||
}
|
||||
|
||||
void WebContents::HideAutofillPopup() {
|
||||
CommonWebContentsDelegate::HideAutofillPopup();
|
||||
}
|
||||
|
||||
std::vector<base::FilePath::StringType> WebContents::GetPreloadPaths() const {
|
||||
auto result = SessionPreferences::GetValidPreloads(GetBrowserContext());
|
||||
|
||||
|
@ -2279,7 +2256,7 @@ v8::Local<v8::Value> WebContents::Session(v8::Isolate* isolate) {
|
|||
return v8::Local<v8::Value>::New(isolate, session_);
|
||||
}
|
||||
|
||||
content::WebContents* WebContents::HostWebContents() {
|
||||
content::WebContents* WebContents::HostWebContents() const {
|
||||
if (!embedder_)
|
||||
return nullptr;
|
||||
return embedder_->web_contents();
|
||||
|
|
|
@ -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<WebContents>,
|
|||
// Properties.
|
||||
int32_t ID() const;
|
||||
v8::Local<v8::Value> Session(v8::Isolate* isolate);
|
||||
content::WebContents* HostWebContents();
|
||||
content::WebContents* HostWebContents() const;
|
||||
v8::Local<v8::Value> DevToolsWebContents(v8::Isolate* isolate);
|
||||
v8::Local<v8::Value> Debugger(v8::Isolate* isolate);
|
||||
|
||||
|
@ -323,6 +323,8 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
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<WebContents>,
|
|||
void DevToolsOpened() override;
|
||||
void DevToolsClosed() override;
|
||||
|
||||
#if defined(TOOLKIT_VIEWS)
|
||||
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
|
||||
const gfx::RectF& bounds,
|
||||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels);
|
||||
#endif
|
||||
|
||||
private:
|
||||
AtomBrowserContext* GetBrowserContext() const;
|
||||
|
||||
|
@ -514,11 +509,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
void SetTemporaryZoomLevel(double level) override;
|
||||
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
|
||||
|
||||
void ShowAutofillPopup(const gfx::RectF& bounds,
|
||||
const std::vector<base::string16>& values,
|
||||
const std::vector<base::string16>& labels) override;
|
||||
void HideAutofillPopup() override;
|
||||
|
||||
// Called when we receive a CursorChange message from chromium.
|
||||
void OnCursorChange(const content::WebCursor& cursor);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue