Skip to content

Commit

Permalink
[WebView Autofill] fix the broken autofill
Browse files Browse the repository at this point in the history
WebView autofill was broken by
https://chromium-review.googlesource.com/c/587034

WebView autofill calls AutofillAgent at very early stage, it relies
on OnInterfaceRequestForFrame to work, this patch moves the
BinderRegistry to AwRenderFrameExt, also overrides
OnInterfaceRequestForFrame in AwRenderFrameExt.

BUG=752277

Change-Id: I7c3138e6a7b65f4165b5d1066f72ce44404f7e60
Reviewed-on: https://chromium-review.googlesource.com/609400
Commit-Queue: Tao Bai <michaelbai@chromium.org>
Reviewed-by: Ben Goodger <ben@chromium.org>
Cr-Commit-Position: refs/heads/master@{#493202}
  • Loading branch information
Tao Bai authored and Commit Bot committed Aug 10, 2017
1 parent 48b8ef3 commit 1d5460a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 17 deletions.
11 changes: 0 additions & 11 deletions android_webview/renderer/aw_content_renderer_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "base/metrics/histogram_macros.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "components/printing/renderer/print_render_frame_helper.h"
#include "components/safe_browsing/renderer/renderer_url_loader_throttle.h"
#include "components/safe_browsing/renderer/websocket_sb_handshake_throttle.h"
Expand Down Expand Up @@ -178,15 +176,6 @@ void AwContentRendererClient::RenderFrameCreated(
parent_frame->GetRoutingID(), render_frame->GetRoutingID()));
}

registry_ = base::MakeUnique<service_manager::BinderRegistry>();

// TODO(sgurun) do not create a password autofill agent (change
// autofill agent to store a weakptr).
autofill::PasswordAutofillAgent* password_autofill_agent =
new autofill::PasswordAutofillAgent(render_frame, registry_.get());
new autofill::AutofillAgent(render_frame, password_autofill_agent, nullptr,
registry_.get());

#if BUILDFLAG(ENABLE_SPELLCHECK)
new SpellCheckProvider(render_frame, spellcheck_.get());
#endif
Expand Down
3 changes: 0 additions & 3 deletions android_webview/renderer/aw_content_renderer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "components/spellcheck/spellcheck_build_features.h"
#include "components/web_restrictions/interfaces/web_restrictions.mojom.h"
#include "content/public/renderer/content_renderer_client.h"
#include "services/service_manager/public/cpp/binder_registry.h"

#if BUILDFLAG(ENABLE_SPELLCHECK)
class SpellCheck;
Expand Down Expand Up @@ -81,8 +80,6 @@ class AwContentRendererClient : public content::ContentRendererClient {
std::unique_ptr<SpellCheck> spellcheck_;
#endif

std::unique_ptr<service_manager::BinderRegistry> registry_;

DISALLOW_COPY_AND_ASSIGN(AwContentRendererClient);
};

Expand Down
19 changes: 18 additions & 1 deletion android_webview/renderer/aw_render_frame_ext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "android_webview/renderer/aw_render_frame_ext.h"

#include "android_webview/common/aw_hit_test_data.h"
#include "android_webview/common/render_view_messages.h"
#include "android_webview/renderer/aw_render_frame_ext.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/content/renderer/autofill_agent.h"
#include "components/autofill/content/renderer/password_autofill_agent.h"
#include "content/public/renderer/document_state.h"
#include "content/public/renderer/render_frame.h"
#include "content/public/renderer/render_view.h"
Expand Down Expand Up @@ -137,11 +140,25 @@ void PopulateHitTestData(const GURL& absolute_link_url,

AwRenderFrameExt::AwRenderFrameExt(content::RenderFrame* render_frame)
: content::RenderFrameObserver(render_frame) {
registry_ = base::MakeUnique<service_manager::BinderRegistry>();

// TODO(sgurun) do not create a password autofill agent (change
// autofill agent to store a weakptr).
autofill::PasswordAutofillAgent* password_autofill_agent =
new autofill::PasswordAutofillAgent(render_frame, registry_.get());
new autofill::AutofillAgent(render_frame, password_autofill_agent, nullptr,
registry_.get());
}

AwRenderFrameExt::~AwRenderFrameExt() {
}

void AwRenderFrameExt::OnInterfaceRequestForFrame(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) {
registry_->TryBindInterface(interface_name, interface_pipe);
}

void AwRenderFrameExt::DidCommitProvisionalLoad(
bool is_new_navigation,
bool is_same_document_navigation) {
Expand Down
9 changes: 7 additions & 2 deletions android_webview/renderer/aw_render_frame_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

#include "base/macros.h"
#include "content/public/renderer/render_frame_observer.h"
#include "services/service_manager/public/cpp/binder_registry.h"
#include "third_party/skia/include/core/SkColor.h"
#include "ui/gfx/geometry/point_f.h"
#include "ui/gfx/geometry/size.h"
#include "ui/gfx/geometry/size_f.h"
Expand All @@ -31,6 +33,9 @@ class AwRenderFrameExt : public content::RenderFrameObserver {
~AwRenderFrameExt() override;

// RenderFrameObserver:
void OnInterfaceRequestForFrame(
const std::string& interface_name,
mojo::ScopedMessagePipeHandle* interface_pipe) override;
void DidCommitProvisionalLoad(bool is_new_navigation,
bool is_same_document_navigation) override;

Expand All @@ -57,11 +62,11 @@ class AwRenderFrameExt : public content::RenderFrameObserver {

url::Origin last_origin_;

std::unique_ptr<service_manager::BinderRegistry> registry_;

DISALLOW_COPY_AND_ASSIGN(AwRenderFrameExt);
};

} // namespace android_webview

#endif // ANDROID_WEBVIEW_RENDERER_AW_RENDER_FRAME_EXT_H_


0 comments on commit 1d5460a

Please sign in to comment.