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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 forButtonState:image_button_cell::kDefaultState]; | 106 forButtonState:image_button_cell::kDefaultState]; |
107 [[closeButton_ cell] setImageID:IDR_CLOSE_1_H | 107 [[closeButton_ cell] setImageID:IDR_CLOSE_1_H |
108 forButtonState:image_button_cell::kHoverState]; | 108 forButtonState:image_button_cell::kHoverState]; |
109 [[closeButton_ cell] setImageID:IDR_CLOSE_1_P | 109 [[closeButton_ cell] setImageID:IDR_CLOSE_1_P |
110 forButtonState:image_button_cell::kPressedState]; | 110 forButtonState:image_button_cell::kPressedState]; |
111 [[closeButton_ cell] setImageID:IDR_CLOSE_1 | 111 [[closeButton_ cell] setImageID:IDR_CLOSE_1 |
112 forButtonState:image_button_cell::kDisabledState]; | 112 forButtonState:image_button_cell::kDisabledState]; |
113 | 113 |
114 [findBarView_ setFrame:[self hiddenFindBarFrame]]; | 114 [findBarView_ setFrame:[self hiddenFindBarFrame]]; |
115 defaultWidth_ = NSWidth([findBarView_ frame]); | 115 defaultWidth_ = NSWidth([findBarView_ frame]); |
| 116 [[self view] setHidden:YES]; |
116 | 117 |
117 [self prepopulateText:[[FindPasteboard sharedInstance] findText]]; | 118 [self prepopulateText:[[FindPasteboard sharedInstance] findText]]; |
118 } | 119 } |
119 | 120 |
120 - (IBAction)close:(id)sender { | 121 - (IBAction)close:(id)sender { |
121 if (findBarBridge_) | 122 if (findBarBridge_) |
122 findBarBridge_->GetFindBarController()->EndFindSession( | 123 findBarBridge_->GetFindBarController()->EndFindSession( |
123 FindBarController::kKeepSelectionOnPage, | 124 FindBarController::kKeepSelectionOnPage, |
124 FindBarController::kKeepResultsInFindBox); | 125 FindBarController::kKeepResultsInFindBox); |
125 | 126 |
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 if (animation == showHideAnimation_.get()) { | 443 if (animation == showHideAnimation_.get()) { |
443 [showHideAnimation_.release() autorelease]; | 444 [showHideAnimation_.release() autorelease]; |
444 } else if (animation == moveAnimation_.get()) { | 445 } else if (animation == moveAnimation_.get()) { |
445 [moveAnimation_.release() autorelease]; | 446 [moveAnimation_.release() autorelease]; |
446 } else { | 447 } else { |
447 NOTREACHED(); | 448 NOTREACHED(); |
448 } | 449 } |
449 | 450 |
450 // If the find bar is not visible, make it actually hidden, so it'll no longer | 451 // If the find bar is not visible, make it actually hidden, so it'll no longer |
451 // respond to key events. | 452 // respond to key events. |
452 [findBarView_ setHidden:![self isFindBarVisible]]; | 453 [[self view] setHidden:![self isFindBarVisible]]; |
453 [[self browserWindowController] onFindBarVisibilityChanged]; | 454 [[self browserWindowController] onFindBarVisibilityChanged]; |
454 } | 455 } |
455 | 456 |
456 - (gfx::Point)findBarWindowPosition { | 457 - (gfx::Point)findBarWindowPosition { |
457 gfx::Rect viewRect(NSRectToCGRect([[self view] frame])); | 458 gfx::Rect viewRect(NSRectToCGRect([[self view] frame])); |
458 // Convert Cocoa coordinates (Y growing up) to Y growing down. | 459 // Convert Cocoa coordinates (Y growing up) to Y growing down. |
459 // Offset from |maxY_|, which represents the content view's top, instead | 460 // Offset from |maxY_|, which represents the content view's top, instead |
460 // of from the superview, which represents the whole browser window. | 461 // of from the superview, which represents the whole browser window. |
461 viewRect.set_y(maxY_ - viewRect.bottom()); | 462 viewRect.set_y(maxY_ - viewRect.bottom()); |
462 return viewRect.origin(); | 463 return viewRect.origin(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 animate:(BOOL)animate | 499 animate:(BOOL)animate |
499 duration:(float)duration { | 500 duration:(float)duration { |
500 // Save the current frame. | 501 // Save the current frame. |
501 NSRect startFrame = [findBarView_ frame]; | 502 NSRect startFrame = [findBarView_ frame]; |
502 | 503 |
503 // Stop any existing animations. | 504 // Stop any existing animations. |
504 [showHideAnimation_ stopAnimation]; | 505 [showHideAnimation_ stopAnimation]; |
505 | 506 |
506 if (!animate) { | 507 if (!animate) { |
507 [findBarView_ setFrame:endFrame]; | 508 [findBarView_ setFrame:endFrame]; |
508 [findBarView_ setHidden:![self isFindBarVisible]]; | 509 [[self view] setHidden:![self isFindBarVisible]]; |
509 [[self browserWindowController] onFindBarVisibilityChanged]; | 510 [[self browserWindowController] onFindBarVisibilityChanged]; |
510 showHideAnimation_.reset(nil); | 511 showHideAnimation_.reset(nil); |
511 return; | 512 return; |
512 } | 513 } |
513 | 514 |
514 // If animating, ensure that the find bar is not hidden. Hidden status will be | 515 // If animating, ensure that the find bar is not hidden. Hidden status will be |
515 // updated at the end of the animation. | 516 // updated at the end of the animation. |
516 [findBarView_ setHidden:NO]; | 517 [[self view] setHidden:NO]; |
517 //[[self browserWindowController] onFindBarVisibilityChanged]; | 518 //[[self browserWindowController] onFindBarVisibilityChanged]; |
518 | 519 |
519 // Reset the frame to what was saved above. | 520 // Reset the frame to what was saved above. |
520 [findBarView_ setFrame:startFrame]; | 521 [findBarView_ setFrame:startFrame]; |
521 | 522 |
522 [[self browserWindowController] onFindBarVisibilityChanged]; | 523 [[self browserWindowController] onFindBarVisibilityChanged]; |
523 | 524 |
524 showHideAnimation_.reset([self createAnimationForView:findBarView_ | 525 showHideAnimation_.reset([self createAnimationForView:findBarView_ |
525 toFrame:endFrame | 526 toFrame:endFrame |
526 duration:duration]); | 527 duration:duration]); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 } | 621 } |
621 | 622 |
622 - (BrowserWindowController*)browserWindowController { | 623 - (BrowserWindowController*)browserWindowController { |
623 if (!browser_) | 624 if (!browser_) |
624 return nil; | 625 return nil; |
625 return [BrowserWindowController | 626 return [BrowserWindowController |
626 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; | 627 browserWindowControllerForWindow:browser_->window()->GetNativeWindow()]; |
627 } | 628 } |
628 | 629 |
629 @end | 630 @end |
OLD | NEW |