summaryrefslogtreecommitdiffstats
path: root/ios/chrome/browser/passwords/password_controller.h
blob: 498481fb14232df9809b2f19d04f95e08fa59326 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_CONTROLLER_H_
#define IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_CONTROLLER_H_

#import <Foundation/NSObject.h>

#import "ios/chrome/browser/autofill/form_suggestion_provider.h"
#import "ios/chrome/browser/passwords/ios_chrome_password_manager_client.h"
#import "ios/chrome/browser/passwords/ios_chrome_password_manager_driver.h"

@protocol FormInputAccessoryViewProvider;
@protocol PasswordsUiDelegate;
@class PasswordGenerationAgent;

namespace password_manager {
class PasswordGenerationManager;
class PasswordManager;
class PasswordManagerClient;
class PasswordManagerDriver;
}  // namespace password_manager

// Per-tab password controller. Handles password autofill and saving.
@interface PasswordController
    : NSObject<PasswordManagerClientDelegate, PasswordManagerDriverDelegate>

// An object that can provide suggestions from this PasswordController.
@property(readonly) id<FormSuggestionProvider> suggestionProvider;

// An object that can provide an input accessory view from this
// PasswordController.
@property(readonly) id<FormInputAccessoryViewProvider> accessoryViewProvider;

// The PasswordGenerationManager owned by this PasswordController.
@property(readonly)
    password_manager::PasswordGenerationManager* passwordGenerationManager;

// The PasswordManagerClient owned by this PasswordController.
@property(readonly)
    password_manager::PasswordManagerClient* passwordManagerClient;

// The PasswordManagerDriver owned by this PasswordController.
@property(readonly)
    password_manager::PasswordManagerDriver* passwordManagerDriver;

// |webState| should not be nil.
- (instancetype)initWithWebState:(web::WebState*)webState
             passwordsUiDelegate:(id<PasswordsUiDelegate>)UIDelegate
    NS_DESIGNATED_INITIALIZER;

- (instancetype)init NS_UNAVAILABLE;

// Releases all tab-specific members. Must be called when the Tab is closing,
// otherwise invalid memory might be accessed during destruction.
- (void)detach;

// Uses JavaScript to find password forms using the |webState_| and fills
// them with the |username| and |password|. |completionHandler|, if not nil,
// is called once per form filled.
- (void)findAndFillPasswordForms:(NSString*)username
                        password:(NSString*)password
               completionHandler:(void (^)(BOOL))completionHandler;

@end

#endif  // IOS_CHROME_BROWSER_PASSWORDS_PASSWORD_CONTROLLER_H_