OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h
" | 5 #import "chrome/browser/ui/cocoa/browser/password_generation_bubble_controller.h
" |
6 | 6 |
7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
8 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
9 #include "chrome/browser/password_manager/password_manager.h" | 9 #include "chrome/browser/password_manager/password_manager.h" |
10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 const CGFloat kIconSize = 26.0; | 62 const CGFloat kIconSize = 26.0; |
63 | 63 |
64 } // namespace | 64 } // namespace |
65 | 65 |
66 // Customized StyledTextFieldCell to display one button decoration that changes | 66 // Customized StyledTextFieldCell to display one button decoration that changes |
67 // on hover. | 67 // on hover. |
68 @interface PasswordGenerationTextFieldCell : StyledTextFieldCell { | 68 @interface PasswordGenerationTextFieldCell : StyledTextFieldCell { |
69 @private | 69 @private |
70 PasswordGenerationBubbleController* controller_; | 70 PasswordGenerationBubbleController* controller_; |
71 BOOL hovering_; | 71 BOOL hovering_; |
72 scoped_nsobject<NSImage> normalImage_; | 72 base::scoped_nsobject<NSImage> normalImage_; |
73 scoped_nsobject<NSImage> hoverImage_; | 73 base::scoped_nsobject<NSImage> hoverImage_; |
74 } | 74 } |
75 | 75 |
76 - (void)setUpWithController:(PasswordGenerationBubbleController*)controller | 76 - (void)setUpWithController:(PasswordGenerationBubbleController*)controller |
77 normalImage:(NSImage*)normalImage | 77 normalImage:(NSImage*)normalImage |
78 hoverImage:(NSImage*)hoverImage; | 78 hoverImage:(NSImage*)hoverImage; |
79 - (void)mouseEntered:(NSEvent*)theEvent | 79 - (void)mouseEntered:(NSEvent*)theEvent |
80 inView:(PasswordGenerationTextField*)controlView; | 80 inView:(PasswordGenerationTextField*)controlView; |
81 - (void)mouseExited:(NSEvent*)theEvent | 81 - (void)mouseExited:(NSEvent*)theEvent |
82 inView:(PasswordGenerationTextField*)controlView; | 82 inView:(PasswordGenerationTextField*)controlView; |
83 - (BOOL)mouseDown:(NSEvent*)theEvent | 83 - (BOOL)mouseDown:(NSEvent*)theEvent |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 fraction:1.0 | 253 fraction:1.0 |
254 respectFlipped:YES | 254 respectFlipped:YES |
255 hints:nil]; | 255 hints:nil]; |
256 | 256 |
257 [super drawInteriorWithFrame:cellFrame inView:controlView]; | 257 [super drawInteriorWithFrame:cellFrame inView:controlView]; |
258 } | 258 } |
259 | 259 |
260 - (void)setUpTrackingAreaInRect:(NSRect)frame | 260 - (void)setUpTrackingAreaInRect:(NSRect)frame |
261 ofView:(PasswordGenerationTextField*)view { | 261 ofView:(PasswordGenerationTextField*)view { |
262 NSRect iconFrame = [self getIconFrame:frame]; | 262 NSRect iconFrame = [self getIconFrame:frame]; |
263 scoped_nsobject<CrTrackingArea> area( | 263 base::scoped_nsobject<CrTrackingArea> area( |
264 [[CrTrackingArea alloc] initWithRect:iconFrame | 264 [[CrTrackingArea alloc] initWithRect:iconFrame |
265 options:NSTrackingMouseEnteredAndExited | | 265 options:NSTrackingMouseEnteredAndExited | |
266 NSTrackingActiveAlways | 266 NSTrackingActiveAlways owner:view userInfo:nil]); |
267 owner:view | |
268 userInfo:nil]); | |
269 [view addTrackingArea:area]; | 267 [view addTrackingArea:area]; |
270 } | 268 } |
271 | 269 |
272 - (CGFloat)topTextFrameOffset { | 270 - (CGFloat)topTextFrameOffset { |
273 return 1.0; | 271 return 1.0; |
274 } | 272 } |
275 | 273 |
276 - (CGFloat)bottomTextFrameOffset { | 274 - (CGFloat)bottomTextFrameOffset { |
277 return 1.0; | 275 return 1.0; |
278 } | 276 } |
(...skipping 22 matching lines...) Expand all Loading... |
301 kTextFieldWidth + | 299 kTextFieldWidth + |
302 kHorizontalSpacing + | 300 kHorizontalSpacing + |
303 kButtonWidth); | 301 kButtonWidth); |
304 CGFloat height = (kBorderSize*2 + | 302 CGFloat height = (kBorderSize*2 + |
305 kTextFieldHeight + | 303 kTextFieldHeight + |
306 kVerticalSpacing + | 304 kVerticalSpacing + |
307 kTitleHeight - | 305 kTitleHeight - |
308 kTopBorderOffset + | 306 kTopBorderOffset + |
309 info_bubble::kBubbleArrowHeight); | 307 info_bubble::kBubbleArrowHeight); |
310 NSRect contentRect = NSMakeRect(0, 0, width, height); | 308 NSRect contentRect = NSMakeRect(0, 0, width, height); |
311 scoped_nsobject<InfoBubbleWindow> window( | 309 base::scoped_nsobject<InfoBubbleWindow> window( |
312 [[InfoBubbleWindow alloc] initWithContentRect:contentRect | 310 [[InfoBubbleWindow alloc] initWithContentRect:contentRect |
313 styleMask:NSBorderlessWindowMask | 311 styleMask:NSBorderlessWindowMask |
314 backing:NSBackingStoreBuffered | 312 backing:NSBackingStoreBuffered |
315 defer:NO]); | 313 defer:NO]); |
316 if (self = [super initWithWindow:window | 314 if (self = [super initWithWindow:window |
317 parentWindow:parentWindow | 315 parentWindow:parentWindow |
318 anchoredAt:point]) { | 316 anchoredAt:point]) { |
319 passwordGenerator_ = passwordGenerator; | 317 passwordGenerator_ = passwordGenerator; |
320 renderViewHost_ = renderViewHost; | 318 renderViewHost_ = renderViewHost; |
321 passwordManager_ = passwordManager; | 319 passwordManager_ = passwordManager; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 buttonX, | 355 buttonX, |
358 buttonY, | 356 buttonY, |
359 kButtonWidth + 2 * kButtonHorizontalPadding, | 357 kButtonWidth + 2 * kButtonHorizontalPadding, |
360 kButtonHeight + 2 * kButtonVerticalPadding)]; | 358 kButtonHeight + 2 * kButtonVerticalPadding)]; |
361 [button setBezelStyle:NSRoundedBezelStyle]; | 359 [button setBezelStyle:NSRoundedBezelStyle]; |
362 [button setTitle:l10n_util::GetNSString(IDS_PASSWORD_GENERATION_BUTTON_TEXT)]; | 360 [button setTitle:l10n_util::GetNSString(IDS_PASSWORD_GENERATION_BUTTON_TEXT)]; |
363 [button setTarget:self]; | 361 [button setTarget:self]; |
364 [button setAction:@selector(fillPassword:)]; | 362 [button setAction:@selector(fillPassword:)]; |
365 [contentView addSubview:button]; | 363 [contentView addSubview:button]; |
366 | 364 |
367 scoped_nsobject<NSTextField> title([[NSTextField alloc] | 365 base::scoped_nsobject<NSTextField> title([[NSTextField alloc] initWithFrame: |
368 initWithFrame:NSMakeRect( | 366 NSMakeRect(kBorderSize, |
369 kBorderSize, | 367 kBorderSize + kTextFieldHeight + kVerticalSpacing, |
370 kBorderSize + kTextFieldHeight + kVerticalSpacing, | 368 kTitleWidth, |
371 kTitleWidth, | 369 kTitleHeight)]); |
372 kTitleHeight)]); | |
373 [title setEditable:NO]; | 370 [title setEditable:NO]; |
374 [title setBordered:NO]; | 371 [title setBordered:NO]; |
375 [title setStringValue:l10n_util::GetNSString( | 372 [title setStringValue:l10n_util::GetNSString( |
376 IDS_PASSWORD_GENERATION_BUBBLE_TITLE)]; | 373 IDS_PASSWORD_GENERATION_BUBBLE_TITLE)]; |
377 [contentView addSubview:title]; | 374 [contentView addSubview:title]; |
378 } | 375 } |
379 | 376 |
380 - (IBAction)fillPassword:(id)sender { | 377 - (IBAction)fillPassword:(id)sender { |
381 if (renderViewHost_) { | 378 if (renderViewHost_) { |
382 renderViewHost_->Send( | 379 renderViewHost_->Send( |
(...skipping 17 matching lines...) Expand all Loading... |
400 - (void)controlTextDidChange:(NSNotification*)notification { | 397 - (void)controlTextDidChange:(NSNotification*)notification { |
401 actions_.password_edited = true; | 398 actions_.password_edited = true; |
402 } | 399 } |
403 | 400 |
404 - (void)windowWillClose:(NSNotification*)notification { | 401 - (void)windowWillClose:(NSNotification*)notification { |
405 autofill::password_generation::LogUserActions(actions_); | 402 autofill::password_generation::LogUserActions(actions_); |
406 [super windowWillClose:notification]; | 403 [super windowWillClose:notification]; |
407 } | 404 } |
408 | 405 |
409 @end | 406 @end |
OLD | NEW |