| 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/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "chrome/browser/autofill/password_generator.h" | 9 #include "chrome/browser/autofill/password_generator.h" |
| 10 #include "chrome/browser/password_manager/password_manager.h" | 10 #include "chrome/browser/password_manager/password_manager.h" |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 [self performLayout]; | 320 [self performLayout]; |
| 321 } | 321 } |
| 322 | 322 |
| 323 return self; | 323 return self; |
| 324 } | 324 } |
| 325 | 325 |
| 326 - (void)performLayout { | 326 - (void)performLayout { |
| 327 NSView* contentView = [[self window] contentView]; | 327 NSView* contentView = [[self window] contentView]; |
| 328 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 328 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 329 | 329 |
| 330 textField_ = | 330 textField_ = [[[PasswordGenerationTextField alloc] |
| 331 [[PasswordGenerationTextField alloc] | 331 initWithFrame:NSMakeRect(kBorderSize, |
| 332 initWithFrame:NSMakeRect(kBorderSize, | 332 kBorderSize, |
| 333 kBorderSize, | 333 kTextFieldWidth, |
| 334 kTextFieldWidth, | 334 kTextFieldHeight + kTextFieldTopPadding) |
| 335 kTextFieldHeight + kTextFieldTopPadding) | 335 withController:self |
| 336 withController:self | 336 normalImage:rb.GetNativeImageNamed(IDR_RELOAD_DIMMED).ToNSImage() |
| 337 normalImage:rb.GetNativeImageNamed(IDR_RELOAD_DIMMED).ToNSImage() | 337 hoverImage:rb.GetNativeImageNamed(IDR_RELOAD) |
| 338 hoverImage:rb.GetNativeImageNamed(IDR_RELOAD).ToNSImage()]; | 338 .ToNSImage()] autorelease]; |
| 339 gfx::Font smallBoldFont = | 339 gfx::Font smallBoldFont = |
| 340 rb.GetFont(ResourceBundle::SmallFont).DeriveFont(0, gfx::Font::BOLD); | 340 rb.GetFont(ResourceBundle::SmallFont).DeriveFont(0, gfx::Font::BOLD); |
| 341 [textField_ setFont:smallBoldFont.GetNativeFont()]; | 341 [textField_ setFont:smallBoldFont.GetNativeFont()]; |
| 342 [textField_ | 342 [textField_ |
| 343 setStringValue:base::SysUTF8ToNSString(passwordGenerator_->Generate())]; | 343 setStringValue:base::SysUTF8ToNSString(passwordGenerator_->Generate())]; |
| 344 [textField_ setDelegate:self]; | 344 [textField_ setDelegate:self]; |
| 345 [contentView addSubview:textField_]; | 345 [contentView addSubview:textField_]; |
| 346 | 346 |
| 347 CGFloat buttonX = (NSMaxX([textField_ frame]) + | 347 CGFloat buttonX = (NSMaxX([textField_ frame]) + |
| 348 kHorizontalSpacing - | 348 kHorizontalSpacing - |
| 349 kButtonHorizontalPadding); | 349 kButtonHorizontalPadding); |
| 350 CGFloat buttonY = kBorderSize - kButtonVerticalPadding; | 350 CGFloat buttonY = kBorderSize - kButtonVerticalPadding; |
| 351 NSButton* button = | 351 NSButton* button = |
| 352 [[NSButton alloc] initWithFrame:NSMakeRect( | 352 [[NSButton alloc] initWithFrame:NSMakeRect( |
| 353 buttonX, | 353 buttonX, |
| 354 buttonY, | 354 buttonY, |
| 355 kButtonWidth + 2 * kButtonHorizontalPadding, | 355 kButtonWidth + 2 * kButtonHorizontalPadding, |
| 356 kButtonHeight + 2 * kButtonVerticalPadding)]; | 356 kButtonHeight + 2 * kButtonVerticalPadding)]; |
| 357 [button setBezelStyle:NSRoundedBezelStyle]; | 357 [button setBezelStyle:NSRoundedBezelStyle]; |
| 358 [button setTitle:l10n_util::GetNSString(IDS_PASSWORD_GENERATION_BUTTON_TEXT)]; | 358 [button setTitle:l10n_util::GetNSString(IDS_PASSWORD_GENERATION_BUTTON_TEXT)]; |
| 359 [button setTarget:self]; | 359 [button setTarget:self]; |
| 360 [button setAction:@selector(fillPassword:)]; | 360 [button setAction:@selector(fillPassword:)]; |
| 361 [contentView addSubview:button]; | 361 [contentView addSubview:button]; |
| 362 | 362 |
| 363 NSTextField* title = [[NSTextField alloc] | 363 scoped_nsobject<NSTextField> title([[NSTextField alloc] |
| 364 initWithFrame:NSMakeRect( | 364 initWithFrame:NSMakeRect( |
| 365 kBorderSize, | 365 kBorderSize, |
| 366 kBorderSize + kTextFieldHeight + kVerticalSpacing, | 366 kBorderSize + kTextFieldHeight + kVerticalSpacing, |
| 367 kTitleWidth, | 367 kTitleWidth, |
| 368 kTitleHeight)]; | 368 kTitleHeight)]); |
| 369 [title setEditable:NO]; | 369 [title setEditable:NO]; |
| 370 [title setBordered:NO]; | 370 [title setBordered:NO]; |
| 371 [title setStringValue:l10n_util::GetNSString( | 371 [title setStringValue:l10n_util::GetNSString( |
| 372 IDS_PASSWORD_GENERATION_BUBBLE_TITLE)]; | 372 IDS_PASSWORD_GENERATION_BUBBLE_TITLE)]; |
| 373 [contentView addSubview:title]; | 373 [contentView addSubview:title]; |
| 374 } | 374 } |
| 375 | 375 |
| 376 - (IBAction)fillPassword:(id)sender { | 376 - (IBAction)fillPassword:(id)sender { |
| 377 if (renderViewHost_) { | 377 if (renderViewHost_) { |
| 378 renderViewHost_->Send( | 378 renderViewHost_->Send( |
| (...skipping 17 matching lines...) Expand all Loading... |
| 396 - (void)controlTextDidChange:(NSNotification*)notification { | 396 - (void)controlTextDidChange:(NSNotification*)notification { |
| 397 actions_.password_edited = true; | 397 actions_.password_edited = true; |
| 398 } | 398 } |
| 399 | 399 |
| 400 - (void)windowWillClose:(NSNotification*)notification { | 400 - (void)windowWillClose:(NSNotification*)notification { |
| 401 password_generation::LogUserActions(actions_); | 401 password_generation::LogUserActions(actions_); |
| 402 [super windowWillClose:notification]; | 402 [super windowWillClose:notification]; |
| 403 } | 403 } |
| 404 | 404 |
| 405 @end | 405 @end |
| OLD | NEW |