password_generation_bubble_controller.h revision 7d4cd473f85ac64c3747c96c277f9e506a0d2246
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_generation_util.h" 13#include "content/public/common/password_form.h" 14 15namespace autofill { 16class PasswordGenerator; 17} 18 19namespace content { 20class RenderViewHost; 21} 22 23class Browser; 24class PasswordManager; 25@class PasswordGenerationBubbleController; 26 27// Customized text field that is used to display the regenerate icon. 28@interface PasswordGenerationTextField : StyledTextField { 29} 30 31- (id)initWithFrame:(NSRect)frame 32 withController:(PasswordGenerationBubbleController*)controller 33 normalImage:(NSImage*)normalImage 34 hoverImage:(NSImage*)hoverImage; 35@end 36 37@interface PasswordGenerationBubbleController : 38 BaseBubbleController<NSTextFieldDelegate> { 39 @private 40 // |renderViewHost_| and |passwordManager_| may be nil in testing. 41 content::RenderViewHost* renderViewHost_; 42 PasswordManager* passwordManager_; 43 autofill::PasswordGenerator* passwordGenerator_; 44 content::PasswordForm form_; 45 autofill::password_generation::PasswordGenerationActions actions_; 46 47 PasswordGenerationTextField* textField_; // weak 48} 49 50@property(readonly) PasswordGenerationTextField* textField; 51 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 content::PasswordForm&)form; 58- (void)performLayout; 59- (IBAction)fillPassword:(id)sender; 60- (void)regeneratePassword; 61@end 62 63// Testing interfaces 64 65@interface PasswordGenerationTextField (ExposedForTesting) 66- (void)simulateIconClick; 67@end 68 69#endif // CHROME_BROWSER_UI_COCOA_BROWSER_PASSWORD_GENERATION_BUBBLE_CONTROLLER_H_ 70