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. 4 5 #ifndef CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_ 7 8 #import <Cocoa/Cocoa.h> 9 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" 14 15 namespace autofill { 16 class PasswordGenerator; 17 } 18 19 namespace content { 20 class RenderViewHost; 21 } 22 23 class Browser; 24 @class PasswordGenerationBubbleController; 25 26 namespace password_manager { 27 class PasswordManager; 28 } 29 30 // Customized text field that is used to display the regenerate icon. 31 @interface PasswordGenerationTextField : StyledTextField { 32 } 33 34 - (id)initWithFrame:(NSRect)frame 35 withController:(PasswordGenerationBubbleController*)controller 36 normalImage:(NSImage*)normalImage 37 hoverImage:(NSImage*)hoverImage; 38 @end 39 40 @interface PasswordGenerationBubbleController : 41 BaseBubbleController<NSTextFieldDelegate> { 42 @private 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_; 49 50 PasswordGenerationTextField* textField_; // weak 51 } 52 53 @property(readonly) PasswordGenerationTextField* textField; 54 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; 64 @end 65 66 // Testing interfaces 67 68 @interface PasswordGenerationTextField (ExposedForTesting) 69 - (void)simulateIconClick; 70 @end 71 72 #endif // CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_ 73