#include "base/memory/scoped_ptr.h"
#include "content/public/renderer/render_view_observer.h"
#include "third_party/WebKit/public/web/WebInputElement.h"
-#include "third_party/WebKit/public/web/WebPasswordGeneratorClient.h"
#include "url/gurl.h"
namespace blink {
-class WebCString;
class WebDocument;
}
// This class is responsible for controlling communication for password
// generation between the browser (which shows the popup and generates
// passwords) and WebKit (shows the generation icon in the password field).
-class PasswordGenerationAgent : public content::RenderViewObserver,
- public blink::WebPasswordGeneratorClient {
+class PasswordGenerationAgent : public content::RenderViewObserver {
public:
explicit PasswordGenerationAgent(content::RenderView* render_view);
- virtual ~PasswordGenerationAgent();
+ ~PasswordGenerationAgent() override;
// Returns true if the field being changed is one where a generated password
// is being offered. Updates the state of the popup if necessary.
bool TextDidChangeInTextField(const blink::WebInputElement& element);
+ // Returns true if the newly focused node caused the generation UI to show.
+ bool FocusedNodeHasChanged(const blink::WebNode& node);
+
+ // Called when new form controls are inserted.
+ void OnDynamicFormsSeen(blink::WebLocalFrame* frame);
+
+ // The length that a password can be before the UI is hidden.
+ static const size_t kMaximumOfferSize = 5;
+
protected:
// Returns true if this document is one that we should consider analyzing.
// Virtual so that it can be overriden during testing.
virtual bool ShouldAnalyzeDocument(const blink::WebDocument& document) const;
// RenderViewObserver:
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ bool OnMessageReceived(const IPC::Message& message) override;
// Use to force enable during testing.
void set_enabled(bool enabled) { enabled_ = enabled; }
private:
// RenderViewObserver:
- virtual void DidFinishDocumentLoad(blink::WebFrame* frame) OVERRIDE;
- virtual void DidFinishLoad(blink::WebFrame* frame) OVERRIDE;
- virtual void FocusedNodeChanged(const blink::WebNode& node) OVERRIDE;
-
- // WebPasswordGeneratorClient:
- virtual void openPasswordGenerator(blink::WebInputElement& element) OVERRIDE;
+ void DidFinishDocumentLoad(blink::WebLocalFrame* frame) override;
+ void DidFinishLoad(blink::WebLocalFrame* frame) override;
// Message handlers.
void OnFormNotBlacklisted(const PasswordForm& form);
void OnAccountCreationFormsDetected(
const std::vector<autofill::FormData>& forms);
+ // Helper function that will try and populate |password_elements_| and
+ // |possible_account_creation_form_|.
+ void FindPossibleGenerationForm(blink::WebLocalFrame* frame);
+
// Helper function to decide if |passwords_| contains password fields for
// an account creation form. Sets |generation_element_| to the field that
// we want to trigger the generation UI on.
// stats.
bool password_edited_;
+ // True if the generation popup was shown during this navigation. Used to
+ // track UMA stats per page visit rather than per display, since the former
+ // is more interesting.
+ bool generation_popup_shown_;
+
+ // True if the editing popup was shown during this navigation. Used to track
+ // UMA stats per page rather than per display, since the former is more
+ // interesting.
+ bool editing_popup_shown_;
+
// If this feature is enabled. Controlled by Finch.
bool enabled_;