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

Side by Side Diff: ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.mm

Issue 2589803002: Upstream Chrome on iOS source code [6/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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 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 "ios/chrome/browser/ui/ntp/recent_tabs/views/signed_out_view.h"
6
7 #include "base/logging.h"
8 #include "base/metrics/user_metrics.h"
9 #import "ios/chrome/browser/ui/commands/UIKit+ChromeExecuteCommand.h"
10 #import "ios/chrome/browser/ui/commands/generic_chrome_command.h"
11 #import "ios/chrome/browser/ui/commands/show_signin_command.h"
12 #import "ios/chrome/browser/ui/fancy_ui/primary_action_button.h"
13 #import "ios/chrome/browser/ui/ntp/recent_tabs/views/views_utils.h"
14 #include "ios/chrome/browser/ui/rtl_geometry.h"
15 #import "ios/chrome/browser/ui/uikit_ui_util.h"
16 #include "ios/chrome/grit/ios_chromium_strings.h"
17 #include "ios/chrome/grit/ios_strings.h"
18 #import "ui/base/l10n/l10n_util.h"
19
20 #if !defined(__has_feature) || !__has_feature(objc_arc)
21 #error "This file requires ARC support."
22 #endif
23
24 namespace {
25
26 // Desired height of the view.
27 const CGFloat kDesiredHeight = 180;
28
29 } // namespace
30
31 @implementation SignedOutView
32
33 - (instancetype)initWithFrame:(CGRect)aRect {
34 self = [super initWithFrame:CGRectZero];
35 if (self) {
36 // Create and add sign in label.
37 UILabel* signInLabel = recent_tabs::CreateMultilineLabel(
38 l10n_util::GetNSString(IDS_IOS_RECENT_TABS_SIGNIN_PROMO));
39 [self addSubview:signInLabel];
40
41 // Create and add sign in button.
42 PrimaryActionButton* signInButton = [[PrimaryActionButton alloc] init];
43 [signInButton setTranslatesAutoresizingMaskIntoConstraints:NO];
44 [signInButton
45 setTitle:l10n_util::GetNSString(IDS_IOS_RECENT_TABS_SIGNIN_BUTTON)
46 forState:UIControlStateNormal];
47 [signInButton addTarget:self
48 action:@selector(showSignIn)
49 forControlEvents:UIControlEventTouchUpInside];
50 [self addSubview:signInButton];
51
52 // Set constraints on label and button.
53 NSDictionary* viewsDictionary = @{
54 @"label" : signInLabel,
55 @"button" : signInButton,
56 };
57
58 // clang-format off
59 NSArray* constraints = @[
60 @"V:|-16-[label]-16-[button]-(>=16)-|",
61 @"H:|-16-[label]-16-|",
62 @"H:|-(>=16)-[button]-16-|"
63 ];
64 // clang-format on
65 ApplyVisualConstraintsWithOptions(constraints, viewsDictionary,
66 LayoutOptionForRTLSupport(), self);
67
68 // SignedOutView is always shown directly when created, and its parent view
69 // |reloadData| isn't called when the user is not signed-in.
70 base::RecordAction(
71 base::UserMetricsAction("Signin_Impression_FromRecentTabs"));
72 }
73 return self;
74 }
75
76 + (CGFloat)desiredHeightInUITableViewCell {
77 return kDesiredHeight;
78 }
79
80 - (void)showSignIn {
81 base::RecordAction(base::UserMetricsAction("Signin_Signin_FromRecentTabs"));
82 ShowSigninCommand* command = [[ShowSigninCommand alloc]
83 initWithOperation:AUTHENTICATION_OPERATION_SIGNIN
84 signInAccessPoint:signin_metrics::AccessPoint::ACCESS_POINT_RECENT_TABS];
85 [self chromeExecuteCommand:command];
86 }
87
88 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698