| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 base::Bind(&AutofillDialogCocoa::CloseNow, | 73 base::Bind(&AutofillDialogCocoa::CloseNow, |
| 74 close_weak_ptr_factory_.GetWeakPtr())); | 74 close_weak_ptr_factory_.GetWeakPtr())); |
| 75 } | 75 } |
| 76 } | 76 } |
| 77 | 77 |
| 78 void AutofillDialogCocoa::CloseNow() { | 78 void AutofillDialogCocoa::CloseNow() { |
| 79 constrained_window_->CloseWebContentsModalDialog(); | 79 constrained_window_->CloseWebContentsModalDialog(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 void AutofillDialogCocoa::UpdatesStarted() { | 82 void AutofillDialogCocoa::UpdatesStarted() { |
| 83 // TODO(estade): implement if it makes sense to. | |
| 84 } | 83 } |
| 85 | 84 |
| 86 void AutofillDialogCocoa::UpdatesFinished() { | 85 void AutofillDialogCocoa::UpdatesFinished() { |
| 87 // TODO(estade): implement if it makes sense to. | |
| 88 } | 86 } |
| 89 | 87 |
| 90 void AutofillDialogCocoa::UpdateAccountChooser() { | 88 void AutofillDialogCocoa::UpdateAccountChooser() { |
| 91 [sheet_delegate_ updateAccountChooser]; | 89 [sheet_delegate_ updateAccountChooser]; |
| 92 } | 90 } |
| 93 | 91 |
| 94 void AutofillDialogCocoa::UpdateButtonStrip() { | 92 void AutofillDialogCocoa::UpdateButtonStrip() { |
| 95 [sheet_delegate_ updateButtonStrip]; | 93 [sheet_delegate_ updateButtonStrip]; |
| 96 } | 94 } |
| 97 | 95 |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 328 } | 326 } |
| 329 return self; | 327 return self; |
| 330 } | 328 } |
| 331 | 329 |
| 332 - (void)dealloc { | 330 - (void)dealloc { |
| 333 [[NSNotificationCenter defaultCenter] removeObserver:self]; | 331 [[NSNotificationCenter defaultCenter] removeObserver:self]; |
| 334 [super dealloc]; | 332 [super dealloc]; |
| 335 } | 333 } |
| 336 | 334 |
| 337 - (void)onContentViewFrameDidChange:(NSNotification*)notification { | 335 - (void)onContentViewFrameDidChange:(NSNotification*)notification { |
| 338 [self performLayout]; | 336 [self requestRelayout]; |
| 339 } | 337 } |
| 340 | 338 |
| 341 - (void)requestRelayout { | 339 - (void)requestRelayout { |
| 342 [self performLayout]; | 340 SEL sel = @selector(performLayout); |
| 341 [NSObject cancelPreviousPerformRequestsWithTarget:self |
| 342 selector:sel |
| 343 object:nil]; |
| 344 [self performSelector:sel withObject:nil afterDelay:0.0]; |
| 343 } | 345 } |
| 344 | 346 |
| 345 - (NSSize)preferredSize { | 347 - (NSSize)preferredSize { |
| 346 NSSize contentSize; | 348 NSSize contentSize; |
| 347 // TODO(groby): Currently, keep size identical to main container. | 349 // TODO(groby): Currently, keep size identical to main container. |
| 348 // Change to allow autoresize of web contents. | 350 // Change to allow autoresize of web contents. |
| 349 contentSize = [mainContainer_ preferredSize]; | 351 contentSize = [mainContainer_ preferredSize]; |
| 350 | 352 |
| 351 NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); | 353 NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); |
| 352 NSSize size = NSMakeSize( | 354 NSSize size = NSMakeSize( |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 // Observe that to allow resizes based on browser size. | 445 // Observe that to allow resizes based on browser size. |
| 444 // NOTE: This MUST come last after all initial setup is done, because there | 446 // NOTE: This MUST come last after all initial setup is done, because there |
| 445 // is an immediate notification post registration. | 447 // is an immediate notification post registration. |
| 446 DCHECK([self window]); | 448 DCHECK([self window]); |
| 447 [[NSNotificationCenter defaultCenter] | 449 [[NSNotificationCenter defaultCenter] |
| 448 addObserver:self | 450 addObserver:self |
| 449 selector:@selector(onContentViewFrameDidChange:) | 451 selector:@selector(onContentViewFrameDidChange:) |
| 450 name:NSWindowDidMoveNotification | 452 name:NSWindowDidMoveNotification |
| 451 object:[self window]]; | 453 object:[self window]]; |
| 452 | 454 |
| 455 [self updateAccountChooser]; |
| 456 [self updateNotificationArea]; |
| 453 [self requestRelayout]; | 457 [self requestRelayout]; |
| 454 } | 458 } |
| 455 | 459 |
| 456 - (void)hide { | 460 - (void)hide { |
| 457 autofillDialog_->delegate()->OnCancel(); | 461 autofillDialog_->delegate()->OnCancel(); |
| 458 autofillDialog_->PerformClose(); | 462 autofillDialog_->PerformClose(); |
| 459 } | 463 } |
| 460 | 464 |
| 461 - (void)updateNotificationArea { | 465 - (void)updateNotificationArea { |
| 462 [mainContainer_ updateNotificationArea]; | 466 [mainContainer_ updateNotificationArea]; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 500 | 504 |
| 501 - (void)fillSection:(autofill::DialogSection)section | 505 - (void)fillSection:(autofill::DialogSection)section |
| 502 forInput:(const autofill::DetailInput&)input { | 506 forInput:(const autofill::DetailInput&)input { |
| 503 [[mainContainer_ sectionForId:section] fillForInput:input]; | 507 [[mainContainer_ sectionForId:section] fillForInput:input]; |
| 504 } | 508 } |
| 505 | 509 |
| 506 - (content::NavigationController*)showSignIn { | 510 - (content::NavigationController*)showSignIn { |
| 507 [signInContainer_ loadSignInPage]; | 511 [signInContainer_ loadSignInPage]; |
| 508 [[mainContainer_ view] setHidden:YES]; | 512 [[mainContainer_ view] setHidden:YES]; |
| 509 [[signInContainer_ view] setHidden:NO]; | 513 [[signInContainer_ view] setHidden:NO]; |
| 510 [self performLayout]; | 514 [self requestRelayout]; |
| 511 | 515 |
| 512 return [signInContainer_ navigationController]; | 516 return [signInContainer_ navigationController]; |
| 513 } | 517 } |
| 514 | 518 |
| 515 - (void)getInputs:(autofill::DetailOutputMap*)output | 519 - (void)getInputs:(autofill::DetailOutputMap*)output |
| 516 forSection:(autofill::DialogSection)section { | 520 forSection:(autofill::DialogSection)section { |
| 517 [[mainContainer_ sectionForId:section] getInputs:output]; | 521 [[mainContainer_ sectionForId:section] getInputs:output]; |
| 518 } | 522 } |
| 519 | 523 |
| 520 - (BOOL)saveDetailsLocally { | 524 - (BOOL)saveDetailsLocally { |
| 521 return [mainContainer_ saveDetailsLocally]; | 525 return [mainContainer_ saveDetailsLocally]; |
| 522 } | 526 } |
| 523 | 527 |
| 524 - (void)hideSignIn { | 528 - (void)hideSignIn { |
| 525 [[signInContainer_ view] setHidden:YES]; | 529 [[signInContainer_ view] setHidden:YES]; |
| 526 [[mainContainer_ view] setHidden:NO]; | 530 [[mainContainer_ view] setHidden:NO]; |
| 527 [self performLayout]; | 531 [self requestRelayout]; |
| 528 } | 532 } |
| 529 | 533 |
| 530 - (void)modelChanged { | 534 - (void)modelChanged { |
| 531 [mainContainer_ modelChanged]; | 535 [mainContainer_ modelChanged]; |
| 532 } | 536 } |
| 533 | 537 |
| 534 @end | 538 @end |
| 535 | 539 |
| 536 | 540 |
| 537 @implementation AutofillDialogWindowController (TestableAutofillDialogView) | 541 @implementation AutofillDialogWindowController (TestableAutofillDialogView) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 551 } | 555 } |
| 552 | 556 |
| 553 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 557 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
| 554 for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { | 558 for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { |
| 555 autofill::DialogSection section = static_cast<autofill::DialogSection>(i); | 559 autofill::DialogSection section = static_cast<autofill::DialogSection>(i); |
| 556 [[mainContainer_ sectionForId:section] activateFieldForInput:input]; | 560 [[mainContainer_ sectionForId:section] activateFieldForInput:input]; |
| 557 } | 561 } |
| 558 } | 562 } |
| 559 | 563 |
| 560 @end | 564 @end |
| OLD | NEW |