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

Unified Diff: ios/chrome/today_extension/url_table_cell.mm

Issue 2586713002: Upstream code and resources for Chrome on iOS extensions. (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
« no previous file with comments | « ios/chrome/today_extension/url_table_cell.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/today_extension/url_table_cell.mm
diff --git a/ios/chrome/today_extension/url_table_cell.mm b/ios/chrome/today_extension/url_table_cell.mm
new file mode 100644
index 0000000000000000000000000000000000000000..7517718434293492f98834a446ce0abcc52cd593
--- /dev/null
+++ b/ios/chrome/today_extension/url_table_cell.mm
@@ -0,0 +1,69 @@
+// 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/today_extension/url_table_cell.h"
+
+#include "base/mac/foundation_util.h"
+#include "base/mac/scoped_block.h"
+#import "base/mac/scoped_nsobject.h"
+#include "base/strings/sys_string_conversions.h"
+#import "ios/chrome/common/physical_web/physical_web_device.h"
+#import "ios/chrome/today_extension/notification_center_url_button.h"
+#include "ios/chrome/today_extension/ui_util.h"
+#include "net/base/escape.h"
+#include "ui/base/l10n/l10n_util.h"
+
+@implementation URLTableCell {
+ base::scoped_nsobject<NotificationCenterURLButton> _button;
+}
+
+- (instancetype)initWithTitle:(NSString*)title
+ url:(NSString*)url
+ icon:(NSString*)icon
+ leftInset:(CGFloat)leftInset
+ reuseIdentifier:(NSString*)reuseIdentifier
+ block:(URLActionBlock)block {
+ self = [super initWithStyle:UITableViewCellStyleDefault
+ reuseIdentifier:reuseIdentifier];
+ if (self) {
+ _button.reset([[NotificationCenterURLButton alloc] initWithTitle:title
+ url:url
+ icon:icon
+ leftInset:leftInset
+ block:block]);
+ [[self contentView] addSubview:_button];
+
+ // The button takes the whole frame.
+ self.contentView.translatesAutoresizingMaskIntoConstraints = NO;
+ _button.get().translatesAutoresizingMaskIntoConstraints = NO;
+ [NSLayoutConstraint activateConstraints:@[
+ [_button.get().leadingAnchor
+ constraintEqualToAnchor:[self contentView].leadingAnchor],
+ [_button.get().trailingAnchor
+ constraintEqualToAnchor:[self contentView].trailingAnchor],
+ [_button.get().topAnchor
+ constraintEqualToAnchor:[self contentView].topAnchor],
+ [_button.get().bottomAnchor
+ constraintEqualToAnchor:[self contentView].bottomAnchor],
+ [self.leadingAnchor
+ constraintEqualToAnchor:[self contentView].leadingAnchor],
+ [self.trailingAnchor
+ constraintEqualToAnchor:[self contentView].trailingAnchor],
+ [self.topAnchor constraintEqualToAnchor:[self contentView].topAnchor],
+ [self.bottomAnchor
+ constraintEqualToAnchor:[self contentView].bottomAnchor]
+ ]];
+ }
+ return self;
+}
+
+- (void)setTitle:(NSString*)title url:(NSString*)url {
+ [_button setTitle:title url:url];
+}
+
+- (void)setSeparatorVisible:(BOOL)visible {
+ [_button setSeparatorVisible:visible];
+}
+
+@end
« no previous file with comments | « ios/chrome/today_extension/url_table_cell.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698