| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef COMPONENTS_AUTOFILL_RENDERER_PASSWORD_GENERATION_MANAGER_H_ | |
| 6 #define COMPONENTS_AUTOFILL_RENDERER_PASSWORD_GENERATION_MANAGER_H_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "content/public/renderer/render_view_observer.h" | |
| 13 #include "googleurl/src/gurl.h" | |
| 14 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputElement.h" | |
| 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebTextFieldDecorator
Client.h" | |
| 16 | |
| 17 namespace WebKit { | |
| 18 class WebCString; | |
| 19 class WebDocument; | |
| 20 } | |
| 21 | |
| 22 namespace content { | |
| 23 struct PasswordForm; | |
| 24 } | |
| 25 | |
| 26 namespace autofill { | |
| 27 | |
| 28 // This class is responsible for controlling communication for password | |
| 29 // generation between the browser (which shows the popup and generates | |
| 30 // passwords) and WebKit (shows the generation icon in the password field). | |
| 31 class PasswordGenerationManager : public content::RenderViewObserver, | |
| 32 public WebKit::WebTextFieldDecoratorClient { | |
| 33 public: | |
| 34 explicit PasswordGenerationManager(content::RenderView* render_view); | |
| 35 virtual ~PasswordGenerationManager(); | |
| 36 | |
| 37 protected: | |
| 38 // Returns true if this document is one that we should consider analyzing. | |
| 39 // Virtual so that it can be overriden during testing. | |
| 40 virtual bool ShouldAnalyzeDocument(const WebKit::WebDocument& document) const; | |
| 41 | |
| 42 // RenderViewObserver: | |
| 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 44 | |
| 45 private: | |
| 46 // RenderViewObserver: | |
| 47 virtual void DidFinishDocumentLoad(WebKit::WebFrame* frame) OVERRIDE; | |
| 48 virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE; | |
| 49 | |
| 50 // WebTextFieldDecoratorClient: | |
| 51 virtual bool shouldAddDecorationTo( | |
| 52 const WebKit::WebInputElement& element) OVERRIDE; | |
| 53 virtual bool visibleByDefault() OVERRIDE; | |
| 54 virtual WebKit::WebCString imageNameForNormalState() OVERRIDE; | |
| 55 virtual WebKit::WebCString imageNameForDisabledState() OVERRIDE; | |
| 56 virtual WebKit::WebCString imageNameForReadOnlyState() OVERRIDE; | |
| 57 virtual WebKit::WebCString imageNameForHoverState() OVERRIDE; | |
| 58 virtual void handleClick(WebKit::WebInputElement& element) OVERRIDE; | |
| 59 virtual void willDetach(const WebKit::WebInputElement& element) OVERRIDE; | |
| 60 | |
| 61 // Message handlers. | |
| 62 void OnFormNotBlacklisted(const content::PasswordForm& form); | |
| 63 void OnPasswordAccepted(const base::string16& password); | |
| 64 void OnPasswordGenerationEnabled(bool enabled); | |
| 65 | |
| 66 // Helper function to decide whether we should show password generation icon. | |
| 67 void MaybeShowIcon(); | |
| 68 | |
| 69 content::RenderView* render_view_; | |
| 70 | |
| 71 // True if password generation is enabled for the profile associated | |
| 72 // with this renderer. | |
| 73 bool enabled_; | |
| 74 | |
| 75 // Stores the origin of the account creation form we detected. | |
| 76 GURL account_creation_form_origin_; | |
| 77 | |
| 78 // Stores the origins of the password forms confirmed not to be blacklisted | |
| 79 // by the browser. A form can be blacklisted if a user chooses "never save | |
| 80 // passwords for this site". | |
| 81 std::vector<GURL> not_blacklisted_password_form_origins_; | |
| 82 | |
| 83 std::vector<WebKit::WebInputElement> passwords_; | |
| 84 | |
| 85 DISALLOW_COPY_AND_ASSIGN(PasswordGenerationManager); | |
| 86 }; | |
| 87 | |
| 88 } // namespace autofill | |
| 89 | |
| 90 #endif // COMPONENTS_AUTOFILL_RENDERER_PASSWORD_GENERATION_MANAGER_H_ | |
| OLD | NEW |