refactor: mojofy autofill (#18723)

This commit is contained in:
Jeremy Apthorp 2019-06-12 15:08:22 -07:00 committed by GitHub
parent ec10fd3044
commit ba96cdb7dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 76 additions and 160 deletions

View file

@ -29,7 +29,6 @@
#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_contents_zoom_controller.h"
#include "atom/browser/web_view_guest_delegate.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/atom_api_native_image.h"
#include "atom/common/api/event_emitter_caller.h"
#include "atom/common/color_util.h"
@ -570,9 +569,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
void WebContents::CloseContents(content::WebContents* source) {
Emit("close");
#if defined(TOOLKIT_VIEWS)
HideAutofillPopup();
#endif
if (managed_web_contents())
managed_web_contents()->GetView()->SetDelegate(nullptr);
for (ExtendedWebContentsObserver& observer : observers_)
@ -1095,7 +1092,6 @@ void WebContents::DevToolsClosed() {
Emit("devtools-closed");
}
#if defined(TOOLKIT_VIEWS)
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
const gfx::RectF& bounds,
const std::vector<base::string16>& values,
@ -1115,7 +1111,6 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
CommonWebContentsDelegate::ShowAutofillPopup(
frame_host, embedder_frame_host, offscreen, popup_bounds, values, labels);
}
#endif
bool WebContents::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
@ -1128,20 +1123,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
return handled;
}
bool WebContents::OnMessageReceived(const IPC::Message& message,
content::RenderFrameHost* frame_host) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
#if defined(TOOLKIT_VIEWS)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
#endif
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
// There are three ways of destroying a webContents:
// 1. call webContents.destroy();
// 2. garbage collection;
@ -2031,6 +2012,17 @@ 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();
}
v8::Local<v8::Value> WebContents::GetPreloadPath(v8::Isolate* isolate) const {
if (auto* web_preferences = WebContentsPreferences::From(web_contents())) {
base::FilePath::StringType preload;