Update Checkstyle library from 6.1 to 6.5
[chromium-blink-merge.git] / components / password_manager / content / browser / credential_manager_dispatcher.h
blob87b5f665a3adecb9ca994a7d1989de99e45a690f
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_
6 #define COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_
8 #include "base/callback.h"
9 #include "base/macros.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "base/memory/weak_ptr.h"
12 #include "base/prefs/pref_member.h"
13 #include "components/password_manager/core/browser/password_store_consumer.h"
14 #include "content/public/browser/web_contents_observer.h"
16 class GURL;
18 namespace autofill {
19 struct PasswordForm;
22 namespace content {
23 class WebContents;
26 namespace password_manager {
27 class CredentialManagerPasswordFormManager;
28 class PasswordManagerClient;
29 class PasswordManagerDriver;
30 class PasswordStore;
31 struct CredentialInfo;
33 class CredentialManagerDispatcher : public content::WebContentsObserver {
34 public:
35 CredentialManagerDispatcher(content::WebContents* web_contents,
36 PasswordManagerClient* client);
37 ~CredentialManagerDispatcher() override;
39 void OnProvisionalSaveComplete();
41 // Called in response to an IPC from the renderer, triggered by a page's call
42 // to 'navigator.credentials.notifyFailedSignIn'.
43 virtual void OnNotifyFailedSignIn(int request_id,
44 const password_manager::CredentialInfo&);
46 // Called in response to an IPC from the renderer, triggered by a page's call
47 // to 'navigator.credentials.notifySignedIn'.
48 virtual void OnNotifySignedIn(int request_id,
49 const password_manager::CredentialInfo&);
51 // Called in response to an IPC from the renderer, triggered by a page's call
52 // to 'navigator.credentials.notifySignedOut'.
53 virtual void OnNotifySignedOut(int request_id);
55 // Called in response to an IPC from the renderer, triggered by a page's call
56 // to 'navigator.credentials.request'.
58 // TODO(vabr): Determine if we can drop the `const` here to save some copies
59 // while processing the request.
60 virtual void OnRequestCredential(int request_id,
61 bool zero_click_only,
62 const std::vector<GURL>& federations);
64 // content::WebContentsObserver implementation.
65 bool OnMessageReceived(const IPC::Message& message) override;
67 using CredentialCallback =
68 base::Callback<void(const autofill::PasswordForm&)>;
70 PasswordManagerClient* client() const { return client_; }
72 private:
73 class PendingRequestTask;
74 class PendingSignedOutTask;
76 PasswordStore* GetPasswordStore();
78 bool IsSavingEnabledForCurrentPage() const;
79 bool IsZeroClickAllowed() const;
81 // Returns the driver for the current main frame.
82 // Virtual for testing.
83 virtual base::WeakPtr<PasswordManagerDriver> GetDriver();
85 void SendCredential(int request_id, const CredentialInfo& info);
86 void DoneSigningOut();
88 PasswordManagerClient* client_;
89 scoped_ptr<CredentialManagerPasswordFormManager> form_manager_;
91 // Set to false to disable automatic signing in.
92 BooleanPrefMember auto_signin_enabled_;
94 // When 'OnRequestCredential' is called, it in turn calls out to the
95 // PasswordStore; we push enough data into Pending*Task objects so that
96 // they can properly respond to the request once the PasswordStore gives
97 // us data.
98 scoped_ptr<PendingRequestTask> pending_request_;
99 scoped_ptr<PendingSignedOutTask> pending_sign_out_;
101 DISALLOW_COPY_AND_ASSIGN(CredentialManagerDispatcher);
104 } // namespace password_manager
106 #endif // COMPONENTS_PASSWORD_MANAGER_CONTENT_BROWSER_CONTENT_CREDENTIAL_MANAGER_DISPATCHER_H_