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 PasswordGenerationBubbleController;
26 namespace password_manager {
27 class PasswordManager;
30 // Customized text field that is used to display the regenerate icon.
31 @interface PasswordGenerationTextField : StyledTextField {
34 - (id)initWithFrame:(NSRect)frame
35 withController:(PasswordGenerationBubbleController*)controller
36 normalImage:(NSImage*)normalImage
37 hoverImage:(NSImage*)hoverImage;
40 @interface PasswordGenerationBubbleController :
41 BaseBubbleController<NSTextFieldDelegate> {
43 // |renderViewHost_| and |passwordManager_| may be nil in testing.
44 content::RenderViewHost* renderViewHost_;
45 password_manager::PasswordManager* passwordManager_;
46 autofill::PasswordGenerator* passwordGenerator_;
47 autofill::PasswordForm form_;
48 autofill::password_generation::PasswordGenerationActions actions_;
50 PasswordGenerationTextField* textField_; // weak
53 @property(readonly) PasswordGenerationTextField* textField;
55 - (id)initWithWindow:(NSWindow*)parentWindow
56 anchoredAt:(NSPoint)point
57 renderViewHost:(content::RenderViewHost*)renderViewHost
58 passwordManager:(password_manager::PasswordManager*)passwordManager
59 usingGenerator:(autofill::PasswordGenerator*)passwordGenerator
60 forForm:(const autofill::PasswordForm&)form;
61 - (void)performLayout;
62 - (IBAction)fillPassword:(id)sender;
63 - (void)regeneratePassword;
68 @interface PasswordGenerationTextField (ExposedForTesting)
69 - (void)simulateIconClick;
72 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_