| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_DRI
VER_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "components/password_manager/core/browser/password_autofill_manager.h" | 10 #include "components/password_manager/core/browser/password_autofill_manager.h" |
| 11 #include "components/password_manager/core/browser/password_generation_manager.h
" | 11 #include "components/password_manager/core/browser/password_generation_manager.h
" |
| 12 #include "components/password_manager/core/browser/password_manager.h" | 12 #include "components/password_manager/core/browser/password_manager.h" |
| 13 #include "components/password_manager/core/browser/password_manager_driver.h" | 13 #include "components/password_manager/core/browser/password_manager_driver.h" |
| 14 #include "content/public/browser/web_contents_observer.h" | |
| 15 | 14 |
| 16 namespace autofill { | 15 namespace autofill { |
| 17 class AutofillManager; | 16 class AutofillManager; |
| 18 struct PasswordForm; | 17 struct PasswordForm; |
| 19 } | 18 } |
| 20 | 19 |
| 21 namespace content { | 20 namespace content { |
| 21 struct FrameNavigateParams; |
| 22 struct LoadCommittedDetails; |
| 23 class RenderFrameHost; |
| 22 class WebContents; | 24 class WebContents; |
| 23 } | 25 } |
| 24 | 26 |
| 27 namespace IPC { |
| 28 class Message; |
| 29 } |
| 30 |
| 25 namespace password_manager { | 31 namespace password_manager { |
| 26 | 32 |
| 27 class ContentPasswordManagerDriver : public PasswordManagerDriver, | 33 // There is one ContentPasswordManagerDriver per RenderFrameHost. |
| 28 public content::WebContentsObserver { | 34 // The lifetime is managed by the ContentPasswordManagerDriverFactory. |
| 35 class ContentPasswordManagerDriver : public PasswordManagerDriver { |
| 29 public: | 36 public: |
| 30 ContentPasswordManagerDriver(content::WebContents* web_contents, | 37 ContentPasswordManagerDriver(content::RenderFrameHost* render_frame_host, |
| 31 PasswordManagerClient* client, | 38 PasswordManagerClient* client, |
| 32 autofill::AutofillClient* autofill_client); | 39 autofill::AutofillClient* autofill_client); |
| 33 ~ContentPasswordManagerDriver() override; | 40 ~ContentPasswordManagerDriver() override; |
| 34 | 41 |
| 42 // Gets the driver for |render_frame_host|. |
| 43 static ContentPasswordManagerDriver* GetForRenderFrameHost( |
| 44 content::RenderFrameHost* render_frame_host); |
| 45 |
| 35 // PasswordManagerDriver implementation. | 46 // PasswordManagerDriver implementation. |
| 36 void FillPasswordForm( | 47 void FillPasswordForm( |
| 37 const autofill::PasswordFormFillData& form_data) override; | 48 const autofill::PasswordFormFillData& form_data) override; |
| 38 bool DidLastPageLoadEncounterSSLErrors() override; | |
| 39 bool IsOffTheRecord() override; | |
| 40 void AllowPasswordGenerationForForm( | 49 void AllowPasswordGenerationForForm( |
| 41 const autofill::PasswordForm& form) override; | 50 const autofill::PasswordForm& form) override; |
| 42 void AccountCreationFormsFound( | 51 void AccountCreationFormsFound( |
| 43 const std::vector<autofill::FormData>& forms) override; | 52 const std::vector<autofill::FormData>& forms) override; |
| 44 void FillSuggestion(const base::string16& username, | 53 void FillSuggestion(const base::string16& username, |
| 45 const base::string16& password) override; | 54 const base::string16& password) override; |
| 46 void PreviewSuggestion(const base::string16& username, | 55 void PreviewSuggestion(const base::string16& username, |
| 47 const base::string16& password) override; | 56 const base::string16& password) override; |
| 48 void ClearPreviewedForm() override; | 57 void ClearPreviewedForm() override; |
| 49 | 58 |
| 50 PasswordGenerationManager* GetPasswordGenerationManager() override; | 59 PasswordGenerationManager* GetPasswordGenerationManager() override; |
| 51 PasswordManager* GetPasswordManager() override; | 60 PasswordManager* GetPasswordManager() override; |
| 52 autofill::AutofillManager* GetAutofillManager() override; | 61 autofill::AutofillManager* GetAutofillManager() override; |
| 53 PasswordAutofillManager* GetPasswordAutofillManager() override; | 62 PasswordAutofillManager* GetPasswordAutofillManager() override; |
| 54 | 63 |
| 55 // content::WebContentsObserver overrides. | 64 bool HandleMessage(const IPC::Message& message); |
| 56 bool OnMessageReceived(const IPC::Message& message) override; | 65 void DidNavigateFrame(const content::LoadCommittedDetails& details, |
| 57 void DidNavigateMainFrame( | 66 const content::FrameNavigateParams& params); |
| 58 const content::LoadCommittedDetails& details, | 67 |
| 59 const content::FrameNavigateParams& params) override; | 68 // Pass-throughs to PasswordManager. |
| 69 void OnPasswordFormsParsed(const std::vector<autofill::PasswordForm>& forms); |
| 70 void OnPasswordFormsRendered( |
| 71 const std::vector<autofill::PasswordForm>& visible_forms, |
| 72 bool did_stop_loading); |
| 73 void OnPasswordFormSubmitted(const autofill::PasswordForm& password_form); |
| 60 | 74 |
| 61 private: | 75 private: |
| 62 PasswordManager password_manager_; | 76 content::RenderFrameHost* render_frame_host_; |
| 77 PasswordManagerClient* client_; |
| 63 PasswordGenerationManager password_generation_manager_; | 78 PasswordGenerationManager password_generation_manager_; |
| 64 PasswordAutofillManager password_autofill_manager_; | 79 PasswordAutofillManager password_autofill_manager_; |
| 65 | 80 |
| 66 // Every instance of PasswordFormFillData created by |*this| and sent to | 81 // Every instance of PasswordFormFillData created by |*this| and sent to |
| 67 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that | 82 // PasswordAutofillManager and PasswordAutofillAgent is given an ID, so that |
| 68 // the latter two classes can reference to the same instance without sending | 83 // the latter two classes can reference to the same instance without sending |
| 69 // it to each other over IPC. The counter below is used to generate new IDs. | 84 // it to each other over IPC. The counter below is used to generate new IDs. |
| 70 int next_free_key_; | 85 int next_free_key_; |
| 71 | 86 |
| 72 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver); | 87 DISALLOW_COPY_AND_ASSIGN(ContentPasswordManagerDriver); |
| 73 }; | 88 }; |
| 74 | 89 |
| 75 } // namespace password_manager | 90 } // namespace password_manager |
| 76 | 91 |
| 77 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_
DRIVER_H_ | 92 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_PASSWORD_MANAGER_
DRIVER_H_ |
| OLD | NEW |