X Tutup
Skip to content

Commit ba96cdb

Browse files
authored
refactor: mojofy autofill (electron#18723)
1 parent ec10fd3 commit ba96cdb

26 files changed

+76
-160
lines changed

atom/app/atom_main_delegate.cc

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,6 @@
3737
#include "ui/base/resource/resource_bundle.h"
3838
#include "ui/base/ui_base_switches.h"
3939

40-
#if BUILDFLAG(IPC_MESSAGE_LOG_ENABLED)
41-
#define IPC_MESSAGE_MACROS_LOG_ENABLED
42-
#include "content/public/common/content_ipc_logging.h"
43-
#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
44-
content::RegisterIPCLogger(msg_id, logger)
45-
#include "atom/common/common_message_generator.h"
46-
#endif
47-
4840
#if defined(OS_MACOSX)
4941
#include "atom/app/atom_main_delegate_mac.h"
5042
#endif

atom/browser/api/atom_api_browser_window.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "atom/browser/unresponsive_suppressor.h"
1111
#include "atom/browser/web_contents_preferences.h"
1212
#include "atom/browser/window_list.h"
13-
#include "atom/common/api/api_messages.h"
1413
#include "atom/common/api/constructor.h"
1514
#include "atom/common/color_util.h"
1615
#include "atom/common/native_mate_converters/callback.h"

atom/browser/api/atom_api_web_contents.cc

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#include "atom/browser/web_contents_preferences.h"
3030
#include "atom/browser/web_contents_zoom_controller.h"
3131
#include "atom/browser/web_view_guest_delegate.h"
32-
#include "atom/common/api/api_messages.h"
3332
#include "atom/common/api/atom_api_native_image.h"
3433
#include "atom/common/api/event_emitter_caller.h"
3534
#include "atom/common/color_util.h"
@@ -570,9 +569,7 @@ void WebContents::SetContentsBounds(content::WebContents* source,
570569

571570
void WebContents::CloseContents(content::WebContents* source) {
572571
Emit("close");
573-
#if defined(TOOLKIT_VIEWS)
574572
HideAutofillPopup();
575-
#endif
576573
if (managed_web_contents())
577574
managed_web_contents()->GetView()->SetDelegate(nullptr);
578575
for (ExtendedWebContentsObserver& observer : observers_)
@@ -1095,7 +1092,6 @@ void WebContents::DevToolsClosed() {
10951092
Emit("devtools-closed");
10961093
}
10971094

1098-
#if defined(TOOLKIT_VIEWS)
10991095
void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
11001096
const gfx::RectF& bounds,
11011097
const std::vector<base::string16>& values,
@@ -1115,7 +1111,6 @@ void WebContents::ShowAutofillPopup(content::RenderFrameHost* frame_host,
11151111
CommonWebContentsDelegate::ShowAutofillPopup(
11161112
frame_host, embedder_frame_host, offscreen, popup_bounds, values, labels);
11171113
}
1118-
#endif
11191114

11201115
bool WebContents::OnMessageReceived(const IPC::Message& message) {
11211116
bool handled = true;
@@ -1128,20 +1123,6 @@ bool WebContents::OnMessageReceived(const IPC::Message& message) {
11281123
return handled;
11291124
}
11301125

1131-
bool WebContents::OnMessageReceived(const IPC::Message& message,
1132-
content::RenderFrameHost* frame_host) {
1133-
bool handled = true;
1134-
IPC_BEGIN_MESSAGE_MAP_WITH_PARAM(WebContents, message, frame_host)
1135-
#if defined(TOOLKIT_VIEWS)
1136-
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_ShowPopup, ShowAutofillPopup)
1137-
IPC_MESSAGE_HANDLER(AtomAutofillFrameHostMsg_HidePopup, HideAutofillPopup)
1138-
#endif
1139-
IPC_MESSAGE_UNHANDLED(handled = false)
1140-
IPC_END_MESSAGE_MAP()
1141-
1142-
return handled;
1143-
}
1144-
11451126
// There are three ways of destroying a webContents:
11461127
// 1. call webContents.destroy();
11471128
// 2. garbage collection;
@@ -2031,6 +2012,17 @@ void WebContents::DoGetZoomLevel(DoGetZoomLevelCallback callback) {
20312012
std::move(callback).Run(GetZoomLevel());
20322013
}
20332014

2015+
void WebContents::ShowAutofillPopup(const gfx::RectF& bounds,
2016+
const std::vector<base::string16>& values,
2017+
const std::vector<base::string16>& labels) {
2018+
content::RenderFrameHost* frame_host = bindings_.dispatch_context();
2019+
ShowAutofillPopup(frame_host, bounds, values, labels);
2020+
}
2021+
2022+
void WebContents::HideAutofillPopup() {
2023+
CommonWebContentsDelegate::HideAutofillPopup();
2024+
}
2025+
20342026
v8::Local<v8::Value> WebContents::GetPreloadPath(v8::Isolate* isolate) const {
20352027
if (auto* web_preferences = WebContentsPreferences::From(web_contents())) {
20362028
base::FilePath::StringType preload;

atom/browser/api/atom_api_web_contents.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -436,8 +436,6 @@ class WebContents : public mate::TrackableObject<WebContents>,
436436
void DidFinishNavigation(
437437
content::NavigationHandle* navigation_handle) override;
438438
bool OnMessageReceived(const IPC::Message& message) override;
439-
bool OnMessageReceived(const IPC::Message& message,
440-
content::RenderFrameHost* frame_host) override;
441439
void WebContentsDestroyed() override;
442440
void NavigationEntryCommitted(
443441
const content::LoadCommittedDetails& load_details) override;
@@ -511,6 +509,11 @@ class WebContents : public mate::TrackableObject<WebContents>,
511509
void SetTemporaryZoomLevel(double level) override;
512510
void DoGetZoomLevel(DoGetZoomLevelCallback callback) override;
513511

512+
void ShowAutofillPopup(const gfx::RectF& bounds,
513+
const std::vector<base::string16>& values,
514+
const std::vector<base::string16>& labels) override;
515+
void HideAutofillPopup() override;
516+
514517
// Called when we receive a CursorChange message from chromium.
515518
void OnCursorChange(const content::WebCursor& cursor);
516519

atom/browser/api/event.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77
#include <utility>
88

9-
#include "atom/common/api/api_messages.h"
109
#include "atom/common/native_mate_converters/string16_converter.h"
1110
#include "atom/common/native_mate_converters/value_converter.h"
1211
#include "content/public/browser/render_frame_host.h"

atom/browser/common_web_contents_delegate.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,7 @@ void CommonWebContentsDelegate::SetOwnerWindow(
214214
NativeWindow* owner_window) {
215215
if (owner_window) {
216216
owner_window_ = owner_window->GetWeakPtr();
217-
#if defined(TOOLKIT_VIEWS)
218217
autofill_popup_.reset(new AutofillPopup());
219-
#endif
220218
NativeWindowRelay::CreateForWebContents(web_contents,
221219
owner_window->GetWeakPtr());
222220
} else {

atom/browser/common_web_contents_delegate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,13 @@ class CommonWebContentsDelegate : public content::WebContentsDelegate,
105105
const content::NativeWebKeyboardEvent& event) override;
106106

107107
// Autofill related events.
108-
#if defined(TOOLKIT_VIEWS)
109108
void ShowAutofillPopup(content::RenderFrameHost* frame_host,
110109
content::RenderFrameHost* embedder_frame_host,
111110
bool offscreen,
112111
const gfx::RectF& bounds,
113112
const std::vector<base::string16>& values,
114113
const std::vector<base::string16>& labels);
115114
void HideAutofillPopup();
116-
#endif
117115

118116
// InspectableWebContentsDelegate:
119117
void DevToolsSaveToFile(const std::string& url,

atom/browser/osr/osr_web_contents_view.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "atom/browser/osr/osr_web_contents_view.h"
66

7-
#include "atom/common/api/api_messages.h"
87
#include "content/browser/web_contents/web_contents_impl.h" // nogncheck
98
#include "content/public/browser/render_view_host.h"
109
#include "third_party/blink/public/platform/web_screen_info.h"

atom/browser/ui/autofill_popup.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@
88

99
#include "atom/browser/native_window_views.h"
1010
#include "atom/browser/ui/autofill_popup.h"
11-
#include "atom/common/api/api_messages.h"
11+
#include "atom/common/api/api.mojom.h"
1212
#include "base/i18n/rtl.h"
1313
#include "chrome/browser/ui/autofill/popup_view_common.h"
1414
#include "electron/buildflags/buildflags.h"
15+
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
1516
#include "ui/display/display.h"
1617
#include "ui/display/screen.h"
1718
#include "ui/gfx/geometry/point.h"
@@ -110,8 +111,10 @@ void AutofillPopup::SetItems(const std::vector<base::string16>& values,
110111
}
111112

112113
void AutofillPopup::AcceptSuggestion(int index) {
113-
frame_host_->Send(new AtomAutofillFrameMsg_AcceptSuggestion(
114-
frame_host_->GetRoutingID(), GetValueAt(index)));
114+
mojom::ElectronAutofillAgentAssociatedPtr autofill_agent;
115+
frame_host_->GetRemoteAssociatedInterfaces()->GetInterface(
116+
mojo::MakeRequest(&autofill_agent));
117+
autofill_agent->AcceptDataListSuggestion(GetValueAt(index));
115118
}
116119

117120
void AutofillPopup::UpdatePopupBounds() {

atom/browser/ui/webui/pdf_viewer_ui.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "atom/browser/atom_browser_context.h"
1212
#include "atom/browser/loader/layered_resource_handler.h"
1313
#include "atom/browser/ui/webui/pdf_viewer_handler.h"
14-
#include "atom/common/api/api_messages.h"
1514
#include "atom/common/atom_constants.h"
1615
#include "base/sequenced_task_runner_helpers.h"
1716
#include "base/task/post_task.h"

0 commit comments

Comments
 (0)
X Tutup