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

Unified Diff: ios/chrome/browser/ui/autofill/storage_switch_tooltip.mm

Issue 2586993002: Upstream Chrome on iOS source code [3/11]. (Closed)
Patch Set: Created 4 years 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: ios/chrome/browser/ui/autofill/storage_switch_tooltip.mm
diff --git a/ios/chrome/browser/ui/autofill/storage_switch_tooltip.mm b/ios/chrome/browser/ui/autofill/storage_switch_tooltip.mm
new file mode 100644
index 0000000000000000000000000000000000000000..ea6e9a297e9cf7b0a2c1640af9b4b8f8ad505826
--- /dev/null
+++ b/ios/chrome/browser/ui/autofill/storage_switch_tooltip.mm
@@ -0,0 +1,70 @@
+// Copyright 2015 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 "ios/chrome/browser/ui/autofill/storage_switch_tooltip.h"
+
+#include "base/logging.h"
+#include "components/strings/grit/components_strings.h"
+#import "ios/third_party/material_roboto_font_loader_ios/src/src/MaterialRobotoFontLoader.h"
+#include "ui/base/l10n/l10n_util.h"
+
+namespace {
+
+const CGFloat kCornerRadius = 2.0f;
+const CGFloat kFontSize = 12.0f;
+const CGFloat kInset = 8.0f;
+
+} // namespace
+
+@implementation StorageSwitchTooltip
+
+- (instancetype)initWithFrame:(CGRect)frame {
+ self = [super initWithFrame:frame];
+ if (self) {
+ NSString* tooltipText =
+ l10n_util::GetNSString(IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP);
+ [self setText:tooltipText];
+ [self setTextColor:[UIColor whiteColor]];
+ [self setBackgroundColor:[UIColor colorWithWhite:0.0 alpha:0.9]];
+ [[self layer] setCornerRadius:kCornerRadius];
+ [[self layer] setMasksToBounds:YES];
+ [self setFont:[[MDFRobotoFontLoader sharedInstance]
+ regularFontOfSize:kFontSize]];
+ [self setNumberOfLines:0]; // Allows multi-line layout.
+ }
+ return self;
+}
+
+- (instancetype)init {
+ return [self initWithFrame:CGRectZero];
+}
+
+- (instancetype)initWithCoder:(NSCoder*)aDecoder {
+ NOTREACHED();
+ return nil;
+}
+
+// The logic in textRectForBounds:limitedToNumberOfLines: and drawTextInRect:
+// adds an inset. Based on
+// http://stackoverflow.com/questions/21167226/resizing-a-uilabel-to-accomodate-insets/21267507#21267507
+- (CGRect)textRectForBounds:(CGRect)bounds
+ limitedToNumberOfLines:(NSInteger)numberOfLines {
+ UIEdgeInsets insets = {kInset, kInset, kInset, kInset};
+ CGRect rect = [super textRectForBounds:UIEdgeInsetsInsetRect(bounds, insets)
+ limitedToNumberOfLines:numberOfLines];
+
+ rect.origin.x -= insets.left;
+ rect.origin.y -= insets.top;
+ rect.size.width += (insets.left + insets.right);
+ rect.size.height += (insets.top + insets.bottom);
+
+ return rect;
+}
+
+- (void)drawTextInRect:(CGRect)rect {
+ UIEdgeInsets insets = {kInset, kInset, kInset, kInset};
+ [super drawTextInRect:UIEdgeInsetsInsetRect(rect, insets)];
+}
+
+@end
« no previous file with comments | « ios/chrome/browser/ui/autofill/storage_switch_tooltip.h ('k') | ios/chrome/browser/ui/bookmarks/bars/bookmark_editing_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698