Chromium Code Reviews| 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_CREDENTIAL_MANAGER_D ISPATCHER_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_I MPL_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_D ISPATCHER_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_I MPL_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 12 #include "components/password_manager/content/public/interfaces/credential_manag er.mojom.h" | |
| 12 #include "components/password_manager/core/browser/credential_manager_password_f orm_manager.h" | 13 #include "components/password_manager/core/browser/credential_manager_password_f orm_manager.h" |
| 13 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h" | 14 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h" |
| 14 #include "components/password_manager/core/browser/credential_manager_pending_re quire_user_mediation_task.h" | 15 #include "components/password_manager/core/browser/credential_manager_pending_re quire_user_mediation_task.h" |
| 15 #include "components/password_manager/core/browser/password_store_consumer.h" | 16 #include "components/password_manager/core/browser/password_store_consumer.h" |
| 16 #include "components/prefs/pref_member.h" | 17 #include "components/prefs/pref_member.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 18 #include "content/public/browser/web_contents_observer.h" |
| 19 #include "mojo/public/cpp/bindings/binding_set.h" | |
| 18 | 20 |
| 19 class GURL; | 21 class GURL; |
| 20 | 22 |
| 21 namespace autofill { | 23 namespace autofill { |
| 22 struct PasswordForm; | 24 struct PasswordForm; |
| 23 } | 25 } |
| 24 | 26 |
| 25 namespace content { | 27 namespace content { |
| 26 class WebContents; | 28 class WebContents; |
| 27 } | 29 } |
| 28 | 30 |
| 29 namespace password_manager { | 31 namespace password_manager { |
| 30 class CredentialManagerPasswordFormManager; | 32 class CredentialManagerPasswordFormManager; |
| 31 class PasswordManagerClient; | 33 class PasswordManagerClient; |
| 32 class PasswordManagerDriver; | 34 class PasswordManagerDriver; |
| 33 class PasswordStore; | 35 class PasswordStore; |
| 34 struct CredentialInfo; | 36 struct CredentialInfo; |
| 35 | 37 |
| 36 class CredentialManagerDispatcher | 38 class CredentialManagerImpl |
| 37 : public content::WebContentsObserver, | 39 : public mojom::CredentialManager, |
| 40 public content::WebContentsObserver, | |
| 38 public CredentialManagerPasswordFormManagerDelegate, | 41 public CredentialManagerPasswordFormManagerDelegate, |
| 39 public CredentialManagerPendingRequestTaskDelegate, | 42 public CredentialManagerPendingRequestTaskDelegate, |
| 40 public CredentialManagerPendingRequireUserMediationTaskDelegate { | 43 public CredentialManagerPendingRequireUserMediationTaskDelegate { |
| 41 public: | 44 public: |
| 42 CredentialManagerDispatcher(content::WebContents* web_contents, | 45 CredentialManagerImpl(content::WebContents* web_contents, |
| 43 PasswordManagerClient* client); | 46 PasswordManagerClient* client); |
| 44 ~CredentialManagerDispatcher() override; | 47 ~CredentialManagerImpl() override; |
| 45 | 48 |
| 46 // Called in response to an IPC from the renderer, triggered by a page's call | 49 void BindRequest(mojom::CredentialManagerRequest request); |
| 47 // to 'navigator.credentials.store'. | |
| 48 virtual void OnStore(int request_id, const password_manager::CredentialInfo&); | |
| 49 | |
| 50 // Called in response to an IPC from the renderer, triggered by a page's call | |
| 51 // to 'navigator.credentials.requireUserMediation'. | |
| 52 virtual void OnRequireUserMediation(int request_id); | |
| 53 | |
| 54 // Called in response to an IPC from the renderer, triggered by a page's call | |
| 55 // to 'navigator.credentials.request'. | |
| 56 // | |
| 57 // TODO(vabr): Determine if we can drop the `const` here to save some copies | |
| 58 // while processing the request. | |
| 59 virtual void OnRequestCredential(int request_id, | |
| 60 bool zero_click_only, | |
| 61 bool include_passwords, | |
| 62 const std::vector<GURL>& federations); | |
| 63 | |
| 64 // content::WebContentsObserver implementation. | |
| 65 bool OnMessageReceived(const IPC::Message& message) override; | |
| 66 | 50 |
| 67 // CredentialManagerPendingRequestTaskDelegate: | 51 // CredentialManagerPendingRequestTaskDelegate: |
| 68 bool IsZeroClickAllowed() const override; | 52 bool IsZeroClickAllowed() const override; |
| 69 GURL GetOrigin() const override; | 53 GURL GetOrigin() const override; |
| 70 void SendCredential(int request_id, const CredentialInfo& info) override; | 54 void SendCredential(const SendCredentialCallback& send_callback, |
| 55 const CredentialInfo& info) override; | |
| 71 PasswordManagerClient* client() const override; | 56 PasswordManagerClient* client() const override; |
| 72 autofill::PasswordForm GetSynthesizedFormForOrigin() const override; | 57 autofill::PasswordForm GetSynthesizedFormForOrigin() const override; |
| 73 | 58 |
| 74 // CredentialManagerPendingSignedOutTaskDelegate: | 59 // CredentialManagerPendingSignedOutTaskDelegate: |
| 75 PasswordStore* GetPasswordStore() override; | 60 PasswordStore* GetPasswordStore() override; |
| 76 void DoneRequiringUserMediation() override; | 61 void DoneRequiringUserMediation() override; |
| 77 | 62 |
| 78 // CredentialManagerPasswordFormManagerDelegate: | 63 // CredentialManagerPasswordFormManagerDelegate: |
| 79 void OnProvisionalSaveComplete() override; | 64 void OnProvisionalSaveComplete() override; |
| 80 | 65 |
| 81 private: | 66 private: |
| 67 friend class CredentialManagerImplTest; | |
|
vabr (Chromium)
2016/03/14 15:40:26
What exactly is this needed for? It is usually a w
leonhsl(Using Gerrit)
2016/03/16 07:07:28
Done. Removed this line.
This was to enable Creden
vabr (Chromium)
2016/03/16 07:16:20
Acknowledged, SGTM.
| |
| 68 | |
| 69 // mojom::CredentialManager methods: | |
| 70 void Store(mojom::CredentialInfoPtr credential, | |
| 71 const StoreCallback& callback) override; | |
| 72 | |
| 73 void RequireUserMediation( | |
| 74 const RequireUserMediationCallback& callback) override; | |
| 75 | |
| 76 void Get(bool zero_click_only, | |
| 77 bool include_passwords, | |
| 78 mojo::Array<mojo::String> federations, | |
| 79 const GetCallback& callback) override; | |
| 80 | |
| 82 // Returns the driver for the current main frame. | 81 // Returns the driver for the current main frame. |
| 83 // Virtual for testing. | 82 // Virtual for testing. |
| 84 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); | 83 virtual base::WeakPtr<PasswordManagerDriver> GetDriver(); |
| 85 | 84 |
| 86 // Schedules a CredentiaManagerPendingRequestTask (during | 85 // Schedules a CredentiaManagerPendingRequestTask (during |
| 87 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper | 86 // |OnRequestCredential()|) after the PasswordStore's AffiliationMatchHelper |
| 88 // grabs a list of realms related to the current web origin. | 87 // grabs a list of realms related to the current web origin. |
| 89 void ScheduleRequestTask(int request_id, | 88 void ScheduleRequestTask(const GetCallback& callback, |
| 90 bool zero_click_only, | 89 bool zero_click_only, |
| 91 bool include_passwords, | 90 bool include_passwords, |
| 92 const std::vector<GURL>& federations, | 91 const std::vector<GURL>& federations, |
| 93 const std::vector<std::string>& android_realms); | 92 const std::vector<std::string>& android_realms); |
| 94 | 93 |
| 95 // Schedules a CredentialManagerPendingRequireUserMediationTask after the | 94 // Schedules a CredentialManagerPendingRequireUserMediationTask after the |
| 96 // AffiliationMatchHelper grabs a list of realms related to the current | 95 // AffiliationMatchHelper grabs a list of realms related to the current |
| 97 // web origin. | 96 // web origin. |
| 98 void ScheduleRequireMediationTask( | 97 void ScheduleRequireMediationTask( |
| 99 int request_id, | 98 const RequireUserMediationCallback& callback, |
| 100 const std::vector<std::string>& android_realms); | 99 const std::vector<std::string>& android_realms); |
| 101 | 100 |
| 102 // Returns true iff it's OK to update credentials in the password store. | 101 // Returns true iff it's OK to update credentials in the password store. |
| 103 bool IsUpdatingCredentialAllowed() const; | 102 bool IsUpdatingCredentialAllowed() const; |
| 104 | 103 |
| 105 PasswordManagerClient* client_; | 104 PasswordManagerClient* client_; |
| 106 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_; | 105 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_; |
| 107 | 106 |
| 108 // Set to false to disable automatic signing in. | 107 // Set to false to disable automatic signing in. |
| 109 BooleanPrefMember auto_signin_enabled_; | 108 BooleanPrefMember auto_signin_enabled_; |
| 110 | 109 |
| 111 // When 'OnRequestCredential' is called, it in turn calls out to the | 110 // When 'OnRequestCredential' is called, it in turn calls out to the |
| 112 // PasswordStore; we push enough data into Pending*Task objects so that | 111 // PasswordStore; we push enough data into Pending*Task objects so that |
| 113 // they can properly respond to the request once the PasswordStore gives | 112 // they can properly respond to the request once the PasswordStore gives |
| 114 // us data. | 113 // us data. |
| 115 scoped_ptr<CredentialManagerPendingRequestTask> pending_request_; | 114 scoped_ptr<CredentialManagerPendingRequestTask> pending_request_; |
| 116 scoped_ptr<CredentialManagerPendingRequireUserMediationTask> | 115 scoped_ptr<CredentialManagerPendingRequireUserMediationTask> |
| 117 pending_require_user_mediation_; | 116 pending_require_user_mediation_; |
| 118 | 117 |
| 119 base::WeakPtrFactory<CredentialManagerDispatcher> weak_factory_; | 118 mojo::BindingSet<mojom::CredentialManager> bindings_; |
| 120 | 119 |
| 121 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher); | 120 base::WeakPtrFactory<CredentialManagerImpl> weak_factory_; |
| 121 | |
| 122 DISALLOW_COPY_AND_ASSIGN(CredentialManagerImpl); | |
| 122 }; | 123 }; |
| 123 | 124 |
| 124 } // namespace password_manager | 125 } // namespace password_manager |
| 125 | 126 |
| 126 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_DISPATCHER_H_ | 127 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGE R_IMPL_H_ |
| OLD | NEW |