| Index: chrome/browser/cocoa/find_bar_cocoa_controller.mm
|
| ===================================================================
|
| --- chrome/browser/cocoa/find_bar_cocoa_controller.mm (revision 52179)
|
| +++ chrome/browser/cocoa/find_bar_cocoa_controller.mm (working copy)
|
| @@ -19,11 +19,50 @@
|
| #include "chrome/browser/tab_contents/tab_contents.h"
|
| #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
|
|
|
| +#include "chrome/browser/browser_theme_provider.h"
|
| +#import "chrome/browser/cocoa/themed_window.h"
|
| +
|
| namespace {
|
| const float kFindBarOpenDuration = 0.2;
|
| const float kFindBarCloseDuration = 0.15;
|
| }
|
|
|
| +@interface FindBarWindow : NSPanel
|
| +@end
|
| +
|
| +@implementation FindBarWindow
|
| +- (BOOL)canBecomeKeyWindow {
|
| + return YES;
|
| +}
|
| +
|
| +- (ThemeProvider*)themeProvider {
|
| + id delegate = [self parentWindow];
|
| + if (![delegate respondsToSelector:@selector(themeProvider)])
|
| + return NULL;
|
| + return [delegate themeProvider];
|
| +}
|
| +
|
| +- (ThemedWindowStyle)themedWindowStyle {
|
| + id delegate = [self parentWindow];
|
| + if (![delegate respondsToSelector:@selector(themedWindowStyle)])
|
| + return THEMED_NORMAL;
|
| + return [delegate themedWindowStyle];
|
| +}
|
| +
|
| +- (NSPoint)themePatternPhase {
|
| + id delegate = [self parentWindow];
|
| + if (![delegate respondsToSelector:@selector(themePatternPhase)])
|
| + return NSMakePoint(0, 0);
|
| + NSPoint phase = [delegate themePatternPhase];
|
| + NSPoint origin = [self frame].origin;
|
| + NSPoint parentOrigin = [[self parentWindow] frame].origin;
|
| + phase.x += (parentOrigin.x - origin.x);
|
| + phase.y += (parentOrigin.y - origin.y);
|
| + return phase;
|
| +}
|
| +@end
|
| +
|
| +
|
| @interface FindBarCocoaController (PrivateMethods)
|
| // Returns the appropriate frame for a hidden find bar.
|
| - (NSRect)hiddenFindBarFrame;
|
| @@ -43,6 +82,20 @@
|
| - (id)init {
|
| if ((self = [super initWithNibName:@"FindBar"
|
| bundle:mac_util::MainAppBundle()])) {
|
| + NSRect windowFrame = [[self view] frame];
|
| + window_.reset([[FindBarWindow alloc] initWithContentRect:windowFrame
|
| + styleMask:NSBorderlessWindowMask|NSNonactivatingPanelMask
|
| + backing:NSBackingStoreBuffered
|
| + defer:YES]);
|
| + [window_ setMovableByWindowBackground:NO];
|
| + [window_ setBackgroundColor:[NSColor clearColor]];
|
| + [window_ setLevel:NSNormalWindowLevel];
|
| + [window_ setOpaque:NO];
|
| + [window_ setHasShadow:NO];
|
| +
|
| + //[[window_ contentView] addSubview:[self view]];
|
| + [window_ setContentView:[self view]];
|
| +
|
| [[NSNotificationCenter defaultCenter]
|
| addObserver:self
|
| selector:@selector(findPboardUpdated:)
|
| @@ -56,10 +109,15 @@
|
| // All animations should be explicitly stopped by the TabContents before a tab
|
| // is closed.
|
| DCHECK(!currentAnimation_.get());
|
| + [[window_ parentWindow] removeChildWindow:window_];
|
| [[NSNotificationCenter defaultCenter] removeObserver:self];
|
| [super dealloc];
|
| }
|
|
|
| +- (NSWindow*)window {
|
| + return window_.get();
|
| +}
|
| +
|
| - (void)setFindBarBridge:(FindBarBridge*)findBarBridge {
|
| DCHECK(!findBarBridge_); // should only be called once.
|
| findBarBridge_ = findBarBridge;
|
| @@ -102,6 +160,8 @@
|
| }
|
|
|
| - (void)positionFindBarViewAtMaxY:(CGFloat)maxY maxWidth:(CGFloat)maxWidth {
|
| + NSWindow* parent = [window_ parentWindow];
|
| +
|
| static const CGFloat kRightEdgeOffset = 25;
|
| NSView* containerView = [self view];
|
| CGFloat containerHeight = NSHeight([containerView frame]);
|
| @@ -114,6 +174,11 @@
|
|
|
| NSRect newFrame = NSMakeRect(maxX - containerWidth, maxY - containerHeight,
|
| containerWidth, containerHeight);
|
| + NSPoint screenOrigin = [parent convertBaseToScreen:newFrame.origin];
|
| + newFrame.origin = screenOrigin;
|
| + [window_ setFrame:newFrame display:YES];
|
| + return;
|
| +
|
| [containerView setFrame:newFrame];
|
| }
|
|
|
| @@ -227,6 +292,7 @@
|
|
|
| - (void)setFocusAndSelection {
|
| [[findText_ window] makeFirstResponder:findText_];
|
| + [[findText_ window] makeKeyWindow];
|
|
|
| // Enable the buttons if the find text is non-empty.
|
| BOOL buttonsEnabled = ([[findText_ stringValue] length] > 0) ? YES : NO;
|
|
|