Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Unified Diff: chrome/browser/cocoa/first_run_bubble_controller.mm

Issue 2822026: Mac: First run bubble. (Closed)
Patch Set: '' Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/first_run_bubble_controller.mm
diff --git a/chrome/browser/cocoa/first_run_bubble_controller.mm b/chrome/browser/cocoa/first_run_bubble_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..6c4ea32c52b0f2223b5be7a4f81a0bc9b96075c9
--- /dev/null
+++ b/chrome/browser/cocoa/first_run_bubble_controller.mm
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "chrome/browser/cocoa/first_run_bubble_controller.h"
+
+#include "app/l10n_util.h"
+#include "base/logging.h"
+#include "base/utf_string_conversions.h"
+#import "chrome/browser/cocoa/l10n_util.h"
+#import "chrome/browser/cocoa/info_bubble_view.h"
+#include "chrome/browser/search_engines/util.h"
+#include "grit/generated_resources.h"
+
+@interface FirstRunBubbleController(Private)
+- (id)initRelativeToView:(NSView*)view
+ offset:(NSPoint)offset
+ profile:(Profile*)profile;
+@end
+
+@implementation FirstRunBubbleController
+
++ (FirstRunBubbleController*) showForView:(NSView*)view
+ offset:(NSPoint)offset
+ profile:(Profile*)profile {
+ // Autoreleases itself on bubble close.
+ return [[FirstRunBubbleController alloc] initRelativeToView:view
+ offset:offset
+ profile:profile];
+}
+
+- (id)initRelativeToView:(NSView*)view
+ offset:(NSPoint)offset
+ profile:(Profile*)profile {
+ if ((self = [super initWithWindowNibPath:@"FirstRunBubble"
+ relativeToView:view
+ offset:offset])) {
+ profile_ = profile;
+ [self showWindow:nil];
+ }
+ return self;
+}
+
+- (void)awakeFromNib {
+ [[self bubble] setBubbleType:info_bubble::kWhiteInfoBubble];
+
+ DCHECK(header_);
+ [header_ setStringValue:cocoa_l10n_util::ReplaceNSStringPlaceholders(
+ [header_ stringValue], GetDefaultSearchEngineName(profile_), NULL)];
+
+ // Adapt window size to bottom buttons. Do this before all other layouting.
+ CGFloat dy = cocoa_l10n_util::VerticallyReflowGroup([[self bubble] subviews]);
+ NSSize ds = NSMakeSize(0, dy);
+ ds = [[self bubble] convertSize:ds toView:nil];
+
+ NSRect frame = [[self window] frame];
+ frame.origin.y -= ds.height;
+ frame.size.height += ds.height;
+ [[self window] setFrame:frame display:YES];
+}
+
+@end // FirstRunBubbleController

Powered by Google App Engine
This is Rietveld 408576698