| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #import "chrome/browser/cocoa/first_run_bubble_controller.h" | 
|  | 6 | 
|  | 7 #include "app/l10n_util.h" | 
|  | 8 #include "base/logging.h" | 
|  | 9 #include "base/utf_string_conversions.h" | 
|  | 10 #import "chrome/browser/cocoa/l10n_util.h" | 
|  | 11 #import "chrome/browser/cocoa/info_bubble_view.h" | 
|  | 12 #include "chrome/browser/search_engines/util.h" | 
|  | 13 #include "grit/generated_resources.h" | 
|  | 14 | 
|  | 15 @interface FirstRunBubbleController(Private) | 
|  | 16 - (id)initRelativeToView:(NSView*)view | 
|  | 17                   offset:(NSPoint)offset | 
|  | 18                  profile:(Profile*)profile; | 
|  | 19 @end | 
|  | 20 | 
|  | 21 @implementation FirstRunBubbleController | 
|  | 22 | 
|  | 23 + (FirstRunBubbleController*) showForView:(NSView*)view | 
|  | 24                                    offset:(NSPoint)offset | 
|  | 25                                   profile:(Profile*)profile { | 
|  | 26   // Autoreleases itself on bubble close. | 
|  | 27   return [[FirstRunBubbleController alloc] initRelativeToView:view | 
|  | 28                                                        offset:offset | 
|  | 29                                                       profile:profile]; | 
|  | 30 } | 
|  | 31 | 
|  | 32 - (id)initRelativeToView:(NSView*)view | 
|  | 33                   offset:(NSPoint)offset | 
|  | 34                  profile:(Profile*)profile { | 
|  | 35   if ((self = [super initWithWindowNibPath:@"FirstRunBubble" | 
|  | 36                             relativeToView:view | 
|  | 37                                     offset:offset])) { | 
|  | 38     profile_ = profile; | 
|  | 39     [self showWindow:nil]; | 
|  | 40   } | 
|  | 41   return self; | 
|  | 42 } | 
|  | 43 | 
|  | 44 - (void)awakeFromNib { | 
|  | 45   [[self bubble] setBubbleType:info_bubble::kWhiteInfoBubble]; | 
|  | 46 | 
|  | 47   DCHECK(header_); | 
|  | 48   [header_ setStringValue:cocoa_l10n_util::ReplaceNSStringPlaceholders( | 
|  | 49       [header_ stringValue], GetDefaultSearchEngineName(profile_), NULL)]; | 
|  | 50 | 
|  | 51   // Adapt window size to bottom buttons. Do this before all other layouting. | 
|  | 52   CGFloat dy = cocoa_l10n_util::VerticallyReflowGroup([[self bubble] subviews]); | 
|  | 53   NSSize ds = NSMakeSize(0, dy); | 
|  | 54   ds = [[self bubble] convertSize:ds toView:nil]; | 
|  | 55 | 
|  | 56   NSRect frame = [[self window] frame]; | 
|  | 57   frame.origin.y -= ds.height; | 
|  | 58   frame.size.height += ds.height; | 
|  | 59   [[self window] setFrame:frame display:YES]; | 
|  | 60 } | 
|  | 61 | 
|  | 62 @end  // FirstRunBubbleController | 
| OLD | NEW | 
|---|