Chromium Code Reviews
DescriptionUse AutofillDriver* in ContentAutofillDriverFactory when possible
ContentAutofillDriverFactory creates ContentAutofillDriver instances in
production code. However, it interacts with them in a limited way. Apart from
creating and destroying those instances, there are currently two actions
performed by the factory: calling DidNavigateFrame, and BindRequest.
DidNavigateFrame passes an unnecessary amount of //content-dependent detail to
just notify the driver when the frame navigated to a different page. The latter
is a //content-independent notion. This CL pushes the //content-related
aruguments out of this method, renames it accordingly, and promotes it to the
parent interface, AutofillDriver.
BindRequest is specific to ContentAutofillDriver, as opposed to AutofillDriver,
because the iOS implementation of AutofillDriver does not use interprocess
communication at all. The BindRequest is only performed in a static binding
method used by ChromeContentBrowserClient.
The fact that ContentAutofillDriverFactory expects to be handling a
ContentAutofillDriver makes unittesting hard. In fact, there is no unittest for
the factory at the moment. The inability to mock the AutofillDriver API results
in a cascade of production-code dependencies when trying to construct a factory
instance and test it. Given that DidNavigateFrame is renamed and pushed to
AutofillDriver, and that BindRequest is not used in instance methods of the
factory, this CL reduces the expectation of the factory to only work with
AutofillDriver. This paves the way for creating a unittest.
Another necessary step to allow creating a unittest for the factory was allowing
the factory to create mocks of AutofillDriver instead of the production version.
This CL achieves this by passing a factory function to the
ContentAutofillDriverFactory on construction. In production code this function
creates ContentAutofillDriver instances, but the test can inject a different
function, creating mocks.
Finally, the CL also adds a unittest for the factory, testing the logic for
calling NavigatedToDifferentPage which moved from the driver to the factory.
BUG=669045
Patch Set 1 #Patch Set 2 : Version 2 #Patch Set 3 : Fix compile #Patch Set 4 : downcast for autofill_manager() #Patch Set 5 : Fix Android compilation #Dependent Patchsets: Messages
Total messages: 23 (22 generated)
|