| 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_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ | 5 #ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ |
| 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ | 6 #define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/memory/scoped_vector.h" | 9 #include "base/memory/scoped_vector.h" |
| 10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 virtual bool IsSyncAccountCredential(const std::string& username, | 65 virtual bool IsSyncAccountCredential(const std::string& username, |
| 66 const std::string& origin) const = 0; | 66 const std::string& origin) const = 0; |
| 67 | 67 |
| 68 // This should be called if the password manager encounters a problem on | 68 // This should be called if the password manager encounters a problem on |
| 69 // |url|. The implementation should show the "Allow to collect URL?" bubble | 69 // |url|. The implementation should show the "Allow to collect URL?" bubble |
| 70 // and, if the user confirms, report the |url|. | 70 // and, if the user confirms, report the |url|. |
| 71 virtual void AskUserAndMaybeReportURL(const GURL& url) const; | 71 virtual void AskUserAndMaybeReportURL(const GURL& url) const; |
| 72 | 72 |
| 73 // Called when all autofill results have been computed. Client can use | 73 // Called when all autofill results have been computed. Client can use |
| 74 // this signal to report statistics. Default implementation is a noop. | 74 // this signal to report statistics. Default implementation is a noop. |
| 75 virtual void AutofillResultsComputed() {} | 75 virtual void AutofillResultsComputed(); |
| 76 | 76 |
| 77 // Informs the embedder of a password form that can be saved if the user | 77 // Informs the embedder of a password form that can be saved if the user |
| 78 // allows it. The embedder is not required to prompt the user if it decides | 78 // allows it. The embedder is not required to prompt the user if it decides |
| 79 // that this form doesn't need to be saved. | 79 // that this form doesn't need to be saved. |
| 80 // Returns true if the prompt was indeed displayed. | 80 // Returns true if the prompt was indeed displayed. |
| 81 virtual bool PromptUserToSavePassword( | 81 virtual bool PromptUserToSavePassword( |
| 82 scoped_ptr<PasswordFormManager> form_to_save) = 0; | 82 scoped_ptr<PasswordFormManager> form_to_save) = 0; |
| 83 | 83 |
| 84 // Informs the embedder of a password forms that the user should choose from. | 84 // Informs the embedder of a password forms that the user should choose from. |
| 85 // Returns true if the prompt is indeed displayed. If the prompt is not | 85 // Returns true if the prompt is indeed displayed. If the prompt is not |
| 86 // displayed, returns false and does not call |callback|. | 86 // displayed, returns false and does not call |callback|. |
| 87 // |callback| should be invoked with the chosen form. | 87 // |callback| should be invoked with the chosen form. |
| 88 virtual bool PromptUserToChooseCredentials( | 88 virtual bool PromptUserToChooseCredentials( |
| 89 ScopedVector<autofill::PasswordForm> local_forms, | 89 ScopedVector<autofill::PasswordForm> local_forms, |
| 90 ScopedVector<autofill::PasswordForm> federated_forms, | 90 ScopedVector<autofill::PasswordForm> federated_forms, |
| 91 const GURL& origin, | 91 const GURL& origin, |
| 92 base::Callback<void(const CredentialInfo&)> callback) = 0; | 92 base::Callback<void(const CredentialInfo&)> callback) = 0; |
| 93 | 93 |
| 94 // Called when a password is saved in an automated fashion. Embedder may | 94 // Called when a password is saved in an automated fashion. Embedder may |
| 95 // inform the user that this save has occured. | 95 // inform the user that this save has occured. |
| 96 virtual void AutomaticPasswordSave( | 96 virtual void AutomaticPasswordSave( |
| 97 scoped_ptr<PasswordFormManager> saved_form_manager) = 0; | 97 scoped_ptr<PasswordFormManager> saved_form_manager) = 0; |
| 98 | 98 |
| 99 // Called when a password is autofilled. |best_matches| contains the | 99 // Called when a password is autofilled. |best_matches| contains the |
| 100 // PasswordForm into which a password was filled: the client may choose to | 100 // PasswordForm into which a password was filled: the client may choose to |
| 101 // save this to the PasswordStore, for example. Default implementation is a | 101 // save this to the PasswordStore, for example. Default implementation is a |
| 102 // noop. | 102 // noop. |
| 103 virtual void PasswordWasAutofilled( | 103 virtual void PasswordWasAutofilled( |
| 104 const autofill::PasswordFormMap& best_matches) const {} | 104 const autofill::PasswordFormMap& best_matches) const; |
| 105 | 105 |
| 106 // Called when password autofill is blocked by the blacklist. |best_matches| | 106 // Called when password autofill is blocked by the blacklist. |best_matches| |
| 107 // contains the PasswordForm that flags the current site as being on the | 107 // contains the PasswordForm that flags the current site as being on the |
| 108 // blacklist. The client may choose to remove this from the PasswordStore in | 108 // blacklist. The client may choose to remove this from the PasswordStore in |
| 109 // order to unblacklist a site, for example. Default implementation is a noop. | 109 // order to unblacklist a site, for example. Default implementation is a noop. |
| 110 virtual void PasswordAutofillWasBlocked( | 110 virtual void PasswordAutofillWasBlocked( |
| 111 const autofill::PasswordFormMap& best_matches) const {} | 111 const autofill::PasswordFormMap& best_matches) const; |
| 112 | 112 |
| 113 // Gets prefs associated with this embedder. | 113 // Gets prefs associated with this embedder. |
| 114 virtual PrefService* GetPrefs() = 0; | 114 virtual PrefService* GetPrefs() = 0; |
| 115 | 115 |
| 116 // Returns the PasswordStore associated with this instance. | 116 // Returns the PasswordStore associated with this instance. |
| 117 virtual PasswordStore* GetPasswordStore() = 0; | 117 virtual PasswordStore* GetPasswordStore() const = 0; |
| 118 | 118 |
| 119 // Returns the probability that the experiment identified by |experiment_name| | 119 // Returns the probability that the experiment identified by |experiment_name| |
| 120 // should be enabled. The default implementation returns 0. | 120 // should be enabled. The default implementation returns 0. |
| 121 virtual base::FieldTrial::Probability GetProbabilityForExperiment( | 121 virtual base::FieldTrial::Probability GetProbabilityForExperiment( |
| 122 const std::string& experiment_name); | 122 const std::string& experiment_name) const; |
| 123 | 123 |
| 124 // Returns true if password sync is enabled in the embedder. Return value for | 124 // Returns true if password sync is enabled in the embedder. Return value for |
| 125 // custom passphrase users depends on |state|. The default implementation | 125 // custom passphrase users depends on |state|. The default implementation |
| 126 // always returns false. | 126 // always returns false. |
| 127 virtual bool IsPasswordSyncEnabled(CustomPassphraseState state); | 127 virtual bool IsPasswordSyncEnabled(CustomPassphraseState state) const; |
| 128 | 128 |
| 129 // Only for clients which registered with a LogRouter: If called with | 129 // Only for clients which registered with a LogRouter: If called with |
| 130 // |router_can_be_used| set to false, the client may no longer use the | 130 // |router_can_be_used| set to false, the client may no longer use the |
| 131 // LogRouter. If |router_can_be_used| is true, the LogRouter can be used after | 131 // LogRouter. If |router_can_be_used| is true, the LogRouter can be used after |
| 132 // the return from OnLogRouterAvailabilityChanged. | 132 // the return from OnLogRouterAvailabilityChanged. |
| 133 virtual void OnLogRouterAvailabilityChanged(bool router_can_be_used); | 133 virtual void OnLogRouterAvailabilityChanged(bool router_can_be_used); |
| 134 | 134 |
| 135 // Forward |text| for display to the LogRouter (if registered with one). | 135 // Forward |text| for display to the LogRouter (if registered with one). |
| 136 virtual void LogSavePasswordProgress(const std::string& text) const; | 136 virtual void LogSavePasswordProgress(const std::string& text) const; |
| 137 | 137 |
| 138 // Returns true if logs recorded via LogSavePasswordProgress will be | 138 // Returns true if logs recorded via LogSavePasswordProgress will be |
| 139 // displayed, and false otherwise. | 139 // displayed, and false otherwise. |
| 140 virtual bool IsLoggingActive() const; | 140 virtual bool IsLoggingActive() const; |
| 141 | 141 |
| 142 // Returns true if last navigation page had HTTP error i.e 5XX or 4XX | 142 // Returns true if last navigation page had HTTP error i.e 5XX or 4XX |
| 143 virtual bool WasLastNavigationHTTPError() const; | 143 virtual bool WasLastNavigationHTTPError() const; |
| 144 | 144 |
| 145 // Returns the authorization prompt policy to be used with the given form. | 145 // Returns the authorization prompt policy to be used with the given form. |
| 146 // Only relevant on OSX. | 146 // Only relevant on OSX. |
| 147 virtual PasswordStore::AuthorizationPromptPolicy GetAuthorizationPromptPolicy( | 147 virtual PasswordStore::AuthorizationPromptPolicy GetAuthorizationPromptPolicy( |
| 148 const autofill::PasswordForm& form); | 148 const autofill::PasswordForm& form); |
| 149 | 149 |
| 150 // Returns whether any SSL certificate errors were encountered as a result of | 150 // Returns whether any SSL certificate errors were encountered as a result of |
| 151 // the last page load. | 151 // the last page load. |
| 152 virtual bool DidLastPageLoadEncounterSSLErrors(); | 152 virtual bool DidLastPageLoadEncounterSSLErrors() const; |
| 153 | 153 |
| 154 // If this browsing session should not be persisted. | 154 // If this browsing session should not be persisted. |
| 155 virtual bool IsOffTheRecord(); | 155 virtual bool IsOffTheRecord() const; |
| 156 | 156 |
| 157 // Returns the PasswordManager associated with this client. | 157 // Returns the PasswordManager associated with this client. |
| 158 virtual PasswordManager* GetPasswordManager(); | 158 virtual PasswordManager* GetPasswordManager(); |
| 159 | 159 |
| 160 // Returns the AutofillManager for the main frame. | 160 // Returns the AutofillManager for the main frame. |
| 161 virtual autofill::AutofillManager* GetAutofillManagerForMainFrame(); | 161 virtual autofill::AutofillManager* GetAutofillManagerForMainFrame(); |
| 162 | 162 |
| 163 // Returns the main frame URL. | 163 // Returns the main frame URL. |
| 164 virtual const GURL& GetMainFrameURL(); | 164 virtual const GURL& GetMainFrameURL() const; |
| 165 | 165 |
| 166 private: | 166 private: |
| 167 DISALLOW_COPY_AND_ASSIGN(PasswordManagerClient); | 167 DISALLOW_COPY_AND_ASSIGN(PasswordManagerClient); |
| 168 }; | 168 }; |
| 169 | 169 |
| 170 } // namespace password_manager | 170 } // namespace password_manager |
| 171 | 171 |
| 172 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ | 172 #endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_CLIENT_H_ |
| OLD | NEW |