1 // Copyright (c) 2012 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 CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_
8 #import <Cocoa/Cocoa.h>
10 #import "chrome/browser/ui/cocoa/base_bubble_controller.h"
11 #import "chrome/browser/ui/cocoa/styled_text_field.h"
12 #include "components/autofill/core/common/password_form.h"
13 #include "components/autofill/core/common/password_generation_util.h"
16 class PasswordGenerator;
24 class PasswordManager;
25 @class PasswordGenerationBubbleController;
27 // Customized text field that is used to display the regenerate icon.
28 @interface PasswordGenerationTextField : StyledTextField {
31 - (id)initWithFrame:(NSRect)frame
32 withController:(PasswordGenerationBubbleController*)controller
33 normalImage:(NSImage*)normalImage
34 hoverImage:(NSImage*)hoverImage;
37 @interface PasswordGenerationBubbleController :
38 BaseBubbleController<NSTextFieldDelegate> {
40 // |renderViewHost_| and |passwordManager_| may be nil in testing.
41 content::RenderViewHost* renderViewHost_;
42 PasswordManager* passwordManager_;
43 autofill::PasswordGenerator* passwordGenerator_;
44 autofill::PasswordForm form_;
45 autofill::password_generation::PasswordGenerationActions actions_;
47 PasswordGenerationTextField* textField_; // weak
50 @property(readonly) PasswordGenerationTextField* textField;
52 - (id)initWithWindow:(NSWindow*)parentWindow
53 anchoredAt:(NSPoint)point
54 renderViewHost:(content::RenderViewHost*)renderViewHost
55 passwordManager:(PasswordManager*)passwordManager
56 usingGenerator:(autofill::PasswordGenerator*)passwordGenerator
57 forForm:(const autofill::PasswordForm&)form;
58 - (void)performLayout;
59 - (IBAction)fillPassword:(id)sender;
60 - (void)regeneratePassword;
65 @interface PasswordGenerationTextField (ExposedForTesting)
66 - (void)simulateIconClick;
69 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_