OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 IOS_CHROME_BROWSER_PASSWORDS_CREDENTIAL_MANAGER_H_ | |
6 #define IOS_CHROME_BROWSER_PASSWORDS_CREDENTIAL_MANAGER_H_ | |
7 | |
8 #include <string> | |
9 #include <vector> | |
10 | |
11 #include "base/mac/scoped_nsobject.h" | |
Eugene But (OOO till 7-30)
2015/11/18 17:06:48
s/include/import because scoped_nsobject.h is an O
vabr (Chromium)
2015/11/19 10:02:27
Done.
| |
12 #include "base/macros.h" | |
13 #include "base/memory/scoped_ptr.h" | |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/prefs/pref_member.h" | |
16 #include "components/password_manager/core/browser/credential_manager_password_f orm_manager.h" | |
17 #include "components/password_manager/core/browser/credential_manager_pending_re quest_task.h" | |
18 #include "components/password_manager/core/browser/credential_manager_pending_re quire_user_mediation_task.h" | |
19 #include "components/password_manager/core/browser/password_manager_client.h" | |
20 #include "components/password_manager/core/browser/password_store.h" | |
21 #include "ios/web/public/web_state/web_state_observer.h" | |
22 | |
23 @class JSCredentialManager; | |
24 | |
25 namespace ios { | |
droger
2015/11/18 16:24:16
We don't use the ios:: namespace in //ios.
We als
vabr (Chromium)
2015/11/18 16:52:28
Done.
| |
26 namespace passwords { | |
27 | |
28 // Implements the app-side of the CredentialManagement JavaScript API. | |
29 // Injects and listens to the injected JavaScript, owns and drives the user | |
30 // interface, and integrates with the password manager. This is the iOS | |
31 // equivalent of the upstream class CredentialManagerDispatcher. Note: Only | |
32 // activates on iOS 8 and later. | |
33 class CredentialManager | |
34 : public password_manager::CredentialManagerPasswordFormManagerDelegate, | |
35 public password_manager::CredentialManagerPendingRequestTaskDelegate, | |
36 public password_manager:: | |
37 CredentialManagerPendingRequireUserMediationTaskDelegate, | |
38 public web::WebStateObserver { | |
39 public: | |
40 CredentialManager(web::WebState* web_state, | |
41 password_manager::PasswordManagerClient* client, | |
42 password_manager::PasswordManagerDriver* driver, | |
43 JSCredentialManager* js_manager); | |
44 ~CredentialManager() override; | |
45 | |
46 // web::WebStateObserver: | |
47 void PageLoaded( | |
48 web::PageLoadCompletionStatus load_completion_status) override; | |
49 void CredentialsRequested(int request_id, | |
50 const GURL& source_url, | |
51 bool zero_click_only, | |
52 const std::vector<std::string>& federations, | |
53 bool is_user_initiated) override; | |
54 void SignedIn(int request_id, | |
55 const GURL& source_url, | |
56 const web::Credential& credential) override; | |
57 void SignedOut(int request_id, const GURL& source_url) override; | |
58 void WebStateDestroyed() override; | |
59 | |
60 // password_manager::CredentialManagerPendingRequestTaskDelegate: | |
61 bool IsZeroClickAllowed() const override; | |
62 GURL GetOrigin() const override; | |
63 void SendCredential( | |
64 int id, | |
65 const password_manager::CredentialInfo& credential) override; | |
66 password_manager::PasswordManagerClient* client() const override; | |
67 autofill::PasswordForm GetSynthesizedFormForOrigin() const override; | |
68 | |
69 // password_manager::CredentialManagerPendingRequireUserMediationTaskDelegate: | |
70 password_manager::PasswordStore* GetPasswordStore() override; | |
71 void DoneRequiringUserMediation() override; | |
72 | |
73 // CredentialManagerPasswordFormManagerDelegate: | |
74 void OnProvisionalSaveComplete() override; | |
75 | |
76 private: | |
77 // The errors that can cause a request to fail. | |
78 enum ErrorType { | |
79 // An existing request is outstanding. | |
80 ERROR_TYPE_PENDING_REQUEST = 0, | |
81 | |
82 // The password store isn't available. | |
83 ERROR_TYPE_PASSWORD_STORE_UNAVAILABLE, | |
84 | |
85 // The page origin is untrusted. | |
86 ERROR_TYPE_SECURITY_ERROR_UNTRUSTED_ORIGIN, | |
87 }; | |
88 | |
89 explicit CredentialManager(const CredentialManager&) = delete; | |
90 CredentialManager& operator=(const CredentialManager&) = delete; | |
droger
2015/11/18 16:24:16
Could this be replaced by the
DISALLOW_COPY_AND_AS
vabr (Chromium)
2015/11/18 16:52:28
Done.
| |
91 | |
92 // Sends a message via |js_manager_| to resolve the JavaScript Promise | |
93 // associated with |request_id|. Invoked after a page-initiated credential | |
94 // event is acknowledged by the PasswordStore. | |
95 void ResolvePromise(int request_id); | |
96 | |
97 // Sends a message via |js_manager_| to reject the JavaScript Promise | |
98 // associated with |request_id_| with the given |error_type|. Invoked after a | |
99 // page-initiated credential event, store, or retrieval fails. | |
100 void RejectPromise(int request_id, ErrorType error_type); | |
101 | |
102 // Determines the currently loaded page's URL from the active WebState, but | |
103 // only if it is absolutely trusted. Does not hit the network, but still might | |
104 // be costly depending on the webview. Returns true if successful. | |
105 bool GetURLWithAbsoluteTrust(GURL* page_url); | |
Eugene But (OOO till 7-30)
2015/11/18 17:06:48
According to C++ Style guide this should be GetUrl
vabr (Chromium)
2015/11/19 10:02:27
Done.
| |
106 | |
107 // The request to retrieve credentials from the PasswordStore. | |
108 scoped_ptr<password_manager::CredentialManagerPendingRequestTask> | |
109 pending_request_; | |
110 | |
111 // The task to notify the password manager that the user was signed out. | |
112 scoped_ptr<password_manager::CredentialManagerPendingRequireUserMediationTask> | |
113 pending_require_user_mediation_; | |
114 | |
115 // Saves credentials to the PasswordStore. | |
116 scoped_ptr<password_manager::CredentialManagerPasswordFormManager> | |
117 form_manager_; | |
118 | |
119 // Injected JavaScript to provide the API to web pages. | |
120 base::scoped_nsobject<JSCredentialManager> js_manager_; | |
121 | |
122 // Client to access Chrome-specific password manager functionality. Weak. | |
123 password_manager::PasswordManagerClient* client_; | |
124 | |
125 // Driver to access embedder-specific password manager functionality. Weak. | |
126 password_manager::PasswordManagerDriver* driver_; | |
127 | |
128 // Whether zero-click sign-in is enabled. | |
129 BooleanPrefMember zero_click_sign_in_enabled_; | |
130 | |
131 // Weak pointer factory for asynchronously resolving requests. | |
132 base::WeakPtrFactory<CredentialManager> weak_factory_; | |
133 }; | |
134 | |
135 } // namespace passwords | |
136 } // namespace ios | |
137 | |
138 #endif // IOS_CHROME_BROWSER_PASSWORDS_CREDENTIAL_MANAGER_H_ | |
OLD | NEW |