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

Side by Side Diff: chrome/browser/signin/cross_device_promo.h

Issue 1087933002: Cross Device Promo - Main Eligibility Flow (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: first set of anthony's comments Created 5 years, 7 months 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 2015 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 #ifndef CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_
6 #define CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_
7
8 #include "base/observer_list.h"
9 #include "base/timer/timer.h"
10 #include "components/keyed_service/core/keyed_service.h"
11 #include "components/signin/core/browser/device_activity_fetcher.h"
12 #include "components/signin/core/browser/gaia_cookie_manager_service.h"
13
14 class PrefService;
15 class SigninClient;
16 class SigninManager;
17
18 class CrossDevicePromo : public KeyedService,
19 public GaiaCookieManagerService::Observer,
20 public DeviceActivityFetcher::Observer {
Roger Tawa OOO till Jul 10th 2015/05/15 16:01:40 Should have a class description comment.
Mike Lerman 2015/05/15 20:47:34 Done.
21 public:
22 class Observer {
23 public:
24 // Called if the state changes.
25 virtual void OnPromoActivationChanged(bool active) = 0;
26 };
27
28 explicit CrossDevicePromo(SigninManager* signin_manager,
29 GaiaCookieManagerService* cookie_manager_service,
30 SigninClient* signin_client,
31 PrefService* pref_service);
32 ~CrossDevicePromo() override;
33 void Shutdown() override;
34
35 void AddObserver(CrossDevicePromo::Observer* observer);
36 void RemoveObserver(CrossDevicePromo::Observer* observer);
37
38 // Overriden from GaiaCookieManagerService::Observer
39 void OnGaiaAccountsInCookieUpdated(
40 const std::vector<std::pair<std::string, bool> >& accounts,
41 const GoogleServiceAuthError& error) override;
42
43 // Overriden from DeviceActivityFetcher::Observer
44 void OnFetchDeviceActivitySuccess(
45 const std::vector<DeviceActivityFetcher::DeviceActivity>& devices)
46 override;
47 void OnFetchDeviceActivityFailure() override;
48
49 // Profile should be shown the promo.
50 bool IsPromoActive();
51
52 // User elects to opt out of this promo.
53 void OptOut();
54
55 // Called whenever the Last Active Time changes. This is used to determine
56 // when a new browsing session occurs.
57 void UpdateLastActiveTime(const base::Time& previous_last_active);
58
59 // Call this only in tests, please!
60 bool CheckPromoEligibilityForTesting() {
61 return CheckPromoEligibility();
62 }
63
64 private:
65 // Load configuration parameters from the Variations Seed.
66 void Init();
67
68 // Set whether the promo is active or inactive.
69 void MarkPromoActive();
70 void MarkPromoInactive();
71
72 // Perform checks if the promo should be displayed to this profile.
73 bool CheckPromoEligibility();
74
75 // Perform checks if the promo should be displayed to this profile. This will
76 // not write any prefs or initiate any checks that are otherwise called in
77 // CheckPromoEligibility. Records no metrics. Used for DCHECKs.
78 bool VerifyPromoEligibleReadOnly();
79
80 // Track that there is exactly one account in the cookie jar for a period
81 // of time in order to activate the promo.
82 void RegisterForCookieChanges();
83 void UnregisterForCookieChanges();
84
85 // Begin authenticating and then fetching the devices with the same account.
86 void GetDevicesActivityForAccountInCookie();
87
88 SigninManager* signin_manager_;
89 GaiaCookieManagerService* cookie_manager_service_;
90 PrefService* prefs_;
91 SigninClient* signin_client_;
92
93 scoped_ptr<DeviceActivityFetcher> device_activity_fetcher_;
94 ObserverList<CrossDevicePromo::Observer> observer_list_;
95
96 // Maximum time since activity seen on another device that activity is
97 // considered within a context switch.
98 base::TimeDelta context_switch_duration_;
99
100 // Max time until the next Device Activity check. For the first test, this
101 // will be a uniformly random time between now and the max delay specified
102 // from Variations; otherwise we use the max delay as read from variations.
103 base::TimeDelta delay_until_next_list_devices_;
104
105 // Minimum time a single account must be in the cookie jar to consider the
106 // machine as used by only one person.
107 base::TimeDelta single_account_duration_threshold_;
108
109 // Time between noted browsing activity to determine when a new Browsing
110 // Session has started.
111 base::TimeDelta inactivity_between_browsing_sessions_;
112
113 // Throttles some portion of RPCs so they never get executed. 100 = throttled.
114 uint64 rpc_throttle_;
115
116 // Metric to help us track how long a browsing session is. Useful for
117 // configurigng the promo.
118 base::Time start_last_browsing_session_;
119
120 // Has the service been initialized. If false, the promo is inactive.
121 bool initialized_;
122
123 // Some parts of the flow we want to ignore towards our metrics so we don't
124 // double count.
125 bool track_metrics_;
126
127 // Used to delay the check of Device Activity.
128 base::OneShotTimer<CrossDevicePromo> device_activity_timer_;
129
130 DISALLOW_COPY_AND_ASSIGN(CrossDevicePromo);
131 };
132
133 #endif // CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698