OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.ntp.cards; | 5 package org.chromium.chrome.browser.ntp.cards; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.support.annotation.DrawableRes; | 8 import android.support.annotation.DrawableRes; |
9 import android.support.annotation.Nullable; | 9 import android.support.annotation.Nullable; |
10 import android.support.annotation.StringRes; | 10 import android.support.annotation.StringRes; |
(...skipping 24 matching lines...) Expand all Loading... |
35 * Whether the user has seen the promo and dismissed it at some point. When
this is set, | 35 * Whether the user has seen the promo and dismissed it at some point. When
this is set, |
36 * the promo will never be shown. | 36 * the promo will never be shown. |
37 */ | 37 */ |
38 private boolean mDismissed; | 38 private boolean mDismissed; |
39 | 39 |
40 private final ImpressionTracker mImpressionTracker = new ImpressionTracker(n
ull, this); | 40 private final ImpressionTracker mImpressionTracker = new ImpressionTracker(n
ull, this); |
41 | 41 |
42 @Nullable | 42 @Nullable |
43 private final SigninObserver mObserver; | 43 private final SigninObserver mObserver; |
44 | 44 |
45 public SignInPromo(NodeParent parent) { | 45 public SignInPromo(NodeParent parent, NewTabPageManager newTabPageManager) { |
46 super(parent); | 46 super(parent); |
47 mDismissed = ChromePreferenceManager.getInstance(ContextUtils.getApplica
tionContext()) | 47 mDismissed = ChromePreferenceManager.getInstance(ContextUtils.getApplica
tionContext()) |
48 .getNewTabPageSigninPromoDismissed(); | 48 .getNewTabPageSigninPromoDismissed(); |
49 | 49 |
50 final SigninManager signinManager = SigninManager.get(ContextUtils.getAp
plicationContext()); | 50 SigninManager signinManager = SigninManager.get(ContextUtils.getApplicat
ionContext()); |
51 mObserver = mDismissed ? null : new SigninObserver(signinManager); | 51 if (mDismissed) { |
| 52 mObserver = null; |
| 53 } else { |
| 54 mObserver = new SigninObserver(signinManager); |
| 55 newTabPageManager.addDestructionObserver(mObserver); |
| 56 } |
| 57 } |
| 58 |
| 59 @Override |
| 60 public void init() { |
| 61 super.init(); |
| 62 SigninManager signinManager = SigninManager.get(ContextUtils.getApplicat
ionContext()); |
52 setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInO
nNative()); | 63 setVisible(signinManager.isSignInAllowed() && !signinManager.isSignedInO
nNative()); |
53 } | 64 } |
54 | 65 |
55 @Override | 66 @Override |
56 @ItemViewType | 67 @ItemViewType |
57 public int getItemViewType() { | 68 public int getItemViewType() { |
58 return ItemViewType.PROMO; | 69 return ItemViewType.PROMO; |
59 } | 70 } |
60 | 71 |
61 /** | 72 /** |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 getParams().topMargin = 0; | 217 getParams().topMargin = 0; |
207 } | 218 } |
208 } | 219 } |
209 | 220 |
210 @Override | 221 @Override |
211 public boolean isDismissable() { | 222 public boolean isDismissable() { |
212 return true; | 223 return true; |
213 } | 224 } |
214 } | 225 } |
215 } | 226 } |
OLD | NEW |