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

Unified Diff: chrome/browser/ui/cocoa/autofill/autofill_error_bubble_controller.mm

Issue 49063012: [rAC, OSX] Use bubble windows for error messages. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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/ui/cocoa/autofill/autofill_error_bubble_controller.mm
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_error_bubble_controller.mm b/chrome/browser/ui/cocoa/autofill/autofill_error_bubble_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..4a6d40f2ff6ee3b26b38a08069b939ae31edbdd5
--- /dev/null
+++ b/chrome/browser/ui/cocoa/autofill/autofill_error_bubble_controller.mm
@@ -0,0 +1,63 @@
+// Copyright (c) 2013 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/ui/cocoa/autofill/autofill_error_bubble_controller.h"
+
+#import "chrome/browser/ui/cocoa/info_bubble_view.h"
+#import "chrome/browser/ui/cocoa/info_bubble_window.h"
+#include "skia/ext/skia_utils_mac.h"
+
+namespace {
+
+// Border inset for error label.
+const CGFloat kLabelInset = 3.0;
+
+// Imported constant from Views version. TODO(groby): Share.
+SkColor const kWarningColor = 0xffde4932; // SkColorSetRGB(0xde, 0x49, 0x32);
+
+} // namespace
+
+
+@implementation AutofillErrorBubbleController
+
+- (id)initWithParentWindow:(NSWindow*)parentWindow
+ message:(NSString*)message {
+ base::scoped_nsobject<InfoBubbleWindow> window(
+ [[InfoBubbleWindow alloc] initWithContentRect:NSMakeRect(0, 0, 200, 100)
+ styleMask:NSBorderlessWindowMask
+ backing:NSBackingStoreBuffered
+ defer:NO]);
+ [window setAllowedAnimations:info_bubble::kAnimateNone];
+ if ((self = [super initWithWindow:window
+ parentWindow:parentWindow
+ anchoredAt:NSZeroPoint])) {
+ [self setShouldOpenAsKeyWindow:NO];
+ [[self bubble] setBackgroundColor:
+ gfx::SkColorToCalibratedNSColor(kWarningColor)];
Robert Sesek 2013/11/04 23:49:18 nit: indent 2 more spaces
groby-ooo-7-16 2013/11/05 00:51:48 Done.
+ [[self bubble] setArrowLocation:info_bubble::kTopCenter];
+ [[self bubble] setAlignment:info_bubble::kAlignArrowToAnchor];
+
+ label_.reset([[NSTextField alloc] init]);
+ [label_ setEditable:NO];
+ [label_ setBordered:NO];
+ [label_ setDrawsBackground:NO];
+ [label_ setTextColor:[NSColor whiteColor]];
+ [label_ setStringValue:message];
+ [label_ sizeToFit];
+ [label_ setFrameOrigin:NSMakePoint(kLabelInset, kLabelInset)];
+
+ [[self bubble] addSubview:label_];
+
+ NSRect windowFrame = [[self window] frame];
+ windowFrame.size = NSMakeSize(
+ NSMaxX([label_ frame]),
+ NSHeight([label_ frame]) + info_bubble::kBubbleArrowHeight);
+ windowFrame = NSInsetRect(windowFrame, -kLabelInset, -kLabelInset);
+ [[self window] setFrame:windowFrame display:NO];
+ }
+ return self;
+}
+
+@end
+
Robert Sesek 2013/11/04 23:49:18 nit: remove blank line
groby-ooo-7-16 2013/11/05 00:51:48 Done.

Powered by Google App Engine
This is Rietveld 408576698