Skip to content

Commit

Permalink
Revert of [Autofill] Migrate ContentPasswordManagerDriver<-->Password…
Browse files Browse the repository at this point in the history
…{Autofill,Generation}Agent IPCs to mojo. (patchset Pissandshittium#12 id:220001 of https://codereview.chromium.org/2216463002/ )

Reason for revert:
Broke browser_test PasswordManagerBrowserTestBase.InternalsPage

https://uberchromegw.corp.google.com/i/chromium.mac/builders/Mac10.10%20Tests/builds/7902/steps/browser_tests

Original issue's description:
> [Autofill] Migrate ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent IPCs to mojo.
>
> This CL
> -Migrates all ContentPasswordManagerDriver<-->Password{Autofill,Generation}Agent
>  IPC messages into mojo interfaces.
> -Revises related unit tests and browser tests.
>
> TEST=components_unittests, browser_tests
> BUG=582391
>
> Committed: https://crrev.com/38eab5aeedba6745c0d9f7d7c897c16982299d88
> Cr-Commit-Position: refs/heads/master@{#413708}

TBR=rockot@chromium.org,mathp@chromium.org,sky@chromium.org,tsepez@chromium.org,vabr@chromium.org,yzshen@chromium.org,leon.han@intel.com
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=582391

Review-Url: https://codereview.chromium.org/2274783002
Cr-Commit-Position: refs/heads/master@{#413934}
  • Loading branch information
keishi authored and Commit bot committed Aug 24, 2016
1 parent 4f455b2 commit f4a12b8
Show file tree
Hide file tree
Showing 42 changed files with 711 additions and 1,099 deletions.
6 changes: 0 additions & 6 deletions chrome/browser/chrome_content_browser_client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
#include "components/google/core/browser/google_util.h"
#include "components/metrics/client_info.h"
#include "components/net_log/chrome_net_log.h"
#include "components/password_manager/content/browser/content_password_manager_driver_factory.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
Expand Down Expand Up @@ -2925,11 +2924,6 @@ void ChromeContentBrowserClient::RegisterRenderFrameMojoInterfaces(
base::Bind(&autofill::ContentAutofillDriverFactory::BindAutofillDriver,
render_frame_host));

registry->AddInterface(
base::Bind(&password_manager::ContentPasswordManagerDriverFactory::
BindPasswordManagerDriver,
render_frame_host));

#if BUILDFLAG(ANDROID_JAVA_UI)
ChromeInterfaceRegistrarAndroid::ExposeInterfacesToFrame(
registry, render_frame_host);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
#include <stdint.h>

#include <string>
#include <tuple>

#include "base/macros.h"
#include "base/metrics/field_trial.h"
#include "base/run_loop.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/test/scoped_feature_list.h"
Expand All @@ -19,7 +19,7 @@
#include "chrome/common/channel_info.h"
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "components/autofill/content/public/interfaces/autofill_agent.mojom.h"
#include "components/autofill/content/common/autofill_messages.h"
#include "components/password_manager/content/browser/password_manager_internals_service_factory.h"
#include "components/password_manager/core/browser/credentials_filter.h"
#include "components/password_manager/core/browser/log_manager.h"
Expand All @@ -37,8 +37,7 @@
#include "components/version_info/version_info.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "services/shell/public/cpp/interface_provider.h"
#include "content/public/test/mock_render_process_host.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

Expand Down Expand Up @@ -83,55 +82,6 @@ class DummyLogReceiver : public password_manager::LogReceiver {
DISALLOW_COPY_AND_ASSIGN(DummyLogReceiver);
};

class FakePasswordAutofillAgent
: public autofill::mojom::PasswordAutofillAgent {
public:
FakePasswordAutofillAgent()
: called_set_logging_state_(false),
logging_state_active_(false),
binding_(this) {}

~FakePasswordAutofillAgent() override {}

void BindRequest(mojo::ScopedMessagePipeHandle handle) {
binding_.Bind(mojo::MakeRequest<autofill::mojom::PasswordAutofillAgent>(
std::move(handle)));
}

bool called_set_logging_state() { return called_set_logging_state_; }

bool logging_state_active() { return logging_state_active_; }

void reset_data() {
called_set_logging_state_ = false;
logging_state_active_ = false;
}

private:
// autofill::mojom::PasswordAutofillAgent:
void FillPasswordForm(
int key,
const autofill::PasswordFormFillData& form_data) override {}

void SetLoggingState(bool active) override {
called_set_logging_state_ = true;
logging_state_active_ = active;
}

void AutofillUsernameAndPasswordDataReceived(
const autofill::FormsPredictionsMap& predictions) override {}

void FindFocusedPasswordForm(
const FindFocusedPasswordFormCallback& callback) override {}

// Records whether SetLoggingState() gets called.
bool called_set_logging_state_;
// Records data received via SetLoggingState() call.
bool logging_state_active_;

mojo::Binding<autofill::mojom::PasswordAutofillAgent> binding_;
};

} // namespace

class ChromePasswordManagerClientTest : public ChromeRenderViewHostTestHarness {
Expand All @@ -152,27 +102,17 @@ class ChromePasswordManagerClientTest : public ChromeRenderViewHostTestHarness {
protected:
ChromePasswordManagerClient* GetClient();

// If autofill::mojom::PasswordAutofillAgent::SetLoggingState() got called,
// If the test IPC sink contains an AutofillMsg_SetLoggingState message, then
// copies its argument into |activation_flag| and returns true. Otherwise
// returns false.
bool WasLoggingActivationMessageSent(bool* activation_flag);

FakePasswordAutofillAgent fake_agent_;

TestingPrefServiceSimple prefs_;
base::FieldTrialList field_trial_list_;
};

void ChromePasswordManagerClientTest::SetUp() {
ChromeRenderViewHostTestHarness::SetUp();

shell::InterfaceProvider* remote_interfaces =
web_contents()->GetMainFrame()->GetRemoteInterfaces();
shell::InterfaceProvider::TestApi test_api(remote_interfaces);
test_api.SetBinderForName(autofill::mojom::PasswordAutofillAgent::Name_,
base::Bind(&FakePasswordAutofillAgent::BindRequest,
base::Unretained(&fake_agent_)));

prefs_.registry()->RegisterBooleanPref(
password_manager::prefs::kPasswordManagerSavingEnabled, true);
ChromePasswordManagerClient::CreateForWebContentsWithAutofillClient(
Expand All @@ -185,13 +125,15 @@ ChromePasswordManagerClient* ChromePasswordManagerClientTest::GetClient() {

bool ChromePasswordManagerClientTest::WasLoggingActivationMessageSent(
bool* activation_flag) {
base::RunLoop().RunUntilIdle();
if (!fake_agent_.called_set_logging_state())
const uint32_t kMsgID = AutofillMsg_SetLoggingState::ID;
const IPC::Message* message =
process()->sink().GetFirstMessageMatching(kMsgID);
if (!message)
return false;

if (activation_flag)
*activation_flag = fake_agent_.logging_state_active();
fake_agent_.reset_data();
std::tuple<bool> param;
AutofillMsg_SetLoggingState::Read(message, &param);
*activation_flag = std::get<0>(param);
process()->sink().ClearMessages();
return true;
}

Expand Down
32 changes: 17 additions & 15 deletions chrome/browser/password_manager/password_manager_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/autofill/content/common/autofill_messages.h"
#include "components/autofill/core/browser/autofill_test_utils.h"
#include "components/autofill/core/browser/test_autofill_client.h"
#include "components/autofill/core/common/password_form.h"
Expand All @@ -50,6 +51,7 @@
#include "content/public/common/content_switches.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/test_utils.h"
#include "ipc/ipc_security_test_util.h"
#include "net/base/filename_util.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
Expand Down Expand Up @@ -1635,11 +1637,12 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
password_manager::ContentPasswordManagerDriverFactory::FromWebContents(
WebContents());
ObservingAutofillClient observing_autofill_client;
password_manager::ContentPasswordManagerDriver* driver =
driver_factory->GetDriverForFrame(RenderViewHost()->GetMainFrame());
DCHECK(driver);
driver->GetPasswordAutofillManager()->set_autofill_client(
&observing_autofill_client);
driver_factory->TestingSetDriverForFrame(
RenderViewHost()->GetMainFrame(),
base::WrapUnique(new password_manager::ContentPasswordManagerDriver(
RenderViewHost()->GetMainFrame(),
ChromePasswordManagerClient::FromWebContents(WebContents()),
&observing_autofill_client)));

NavigateToFile("/password/password_form.html");

Expand Down Expand Up @@ -2050,21 +2053,20 @@ IN_PROC_BROWSER_TEST_F(PasswordManagerBrowserTestBase,
EXPECT_NE(main_site_instance, iframe_site_instance);
EXPECT_NE(main_frame->GetProcess(), iframe->GetProcess());

content::RenderProcessHostWatcher iframe_killed(
iframe->GetProcess(),
content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);

// Try to get cross-site passwords from the subframe's process and wait for it
// to be killed.
std::vector<autofill::PasswordForm> password_forms;
password_forms.push_back(autofill::PasswordForm());
password_forms.back().origin = main_frame_url;
ContentPasswordManagerDriverFactory* factory =
ContentPasswordManagerDriverFactory::FromWebContents(WebContents());
EXPECT_TRUE(factory);
ContentPasswordManagerDriver* driver = factory->GetDriverForFrame(iframe);
EXPECT_TRUE(driver);
driver->PasswordFormsParsed(password_forms);
AutofillHostMsg_PasswordFormsParsed illegal_forms_parsed(
iframe->GetRoutingID(), password_forms);

content::RenderProcessHostWatcher iframe_killed(
iframe->GetProcess(),
content::RenderProcessHostWatcher::WATCH_FOR_PROCESS_EXIT);

IPC::IpcSecurityTestUtil::PwnMessageReceived(
iframe->GetProcess()->GetChannel(), illegal_forms_parsed);

iframe_killed.Wait();
}
Expand Down
2 changes: 0 additions & 2 deletions chrome/chrome_tests.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@
'renderer/autofill/form_autofill_browsertest.cc',
'renderer/autofill/form_classifier_browsertest.cc',
'renderer/autofill/page_click_tracker_browsertest.cc',
'renderer/autofill/fake_content_password_manager_driver.cc',
'renderer/autofill/fake_content_password_manager_driver.h',
'renderer/autofill/password_autofill_agent_browsertest.cc',
'renderer/autofill/password_generation_agent_browsertest.cc',
'renderer/autofill/password_generation_test_utils.cc',
Expand Down
75 changes: 0 additions & 75 deletions chrome/renderer/autofill/fake_content_password_manager_driver.cc

This file was deleted.

Loading

0 comments on commit f4a12b8

Please sign in to comment.