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

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: pre-review 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 {
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 // Perform checks if the promo should be displayed to this profile.
53 bool CheckPromoEligibility();
54
55 // User elects to opt out of this promo.
56 void OptOut();
57
58 // Called whenever the Last Active Time changes. This is used to determine
59 // when a new browsing session occurs.
60 void UpdateLastActiveTime(const base::Time& previous_last_active);
61
62 private:
63 // Load configuration parameters from the Variations Seed.
64 void Init();
65
66 // Set whether the promo is active or inactive.
67 void MarkPromoActive();
68 void MarkPromoInactive();
69
70 // Perform checks if the promo should be displayed to this profile. This will
71 // not write any prefs or initiate any checks that are otherwise called in
72 // CheckPromoEligibility. Records no metrics. Used for DCHECKs.
73 bool VerifyPromoEligibleReadOnly();
74
75 // Track that there is exactly one account in the cookie jar for a period
76 // of time in order to activate the promo.
77 void RegisterForCookieChanges();
78 void UnregisterForCookieChanges();
79
80 // Begin authenticating and then fetching the devices with the same account.
81 void GetDevicesActivityForAccountInCookie();
82
83 SigninManager* signin_manager_;
84 GaiaCookieManagerService* cookie_manager_service_;
85 PrefService* prefs_;
86 SigninClient* signin_client_;
87
88 scoped_ptr<DeviceActivityFetcher> device_activity_fetcher_;
89 ObserverList<CrossDevicePromo::Observer> observer_list_;
90
91 // Maximum time since activity seen on another device that activity is
92 // considered within a context switch.
93 base::TimeDelta context_switch_duration_;
94
95 // Max time until the next Device Activity check. For the first test, this
96 // will be a uniformly random time between now and the max delay specified
97 // from Variations; otherwise we use the max delay as read from variations.
98 base::TimeDelta delay_until_next_list_devices_;
99
100 // Minimum time a single account must be in the cookie jar to consider the
101 // machine as used by only one person.
102 base::TimeDelta single_account_in_profile_;
103
104 // Time between noted browsing activity to determine when a new Browsing
105 // Session has started.
106 base::TimeDelta inactivity_between_browsing_sessions_;
107
108 // Throttles some portion of RPCs so they never get executed. 100 = throttled.
109 uint64 rpc_throttle_;
110
111 // Metric to help us track how long a browsing session is. Useful for
112 // configurigng the promo.
113 base::Time start_last_browsing_session_;
114
115 // Has the service been initialized. If false, the promo is inactive.
116 bool initialized_;
117
118 // Some parts of the flow we want to ignore towards our metrics so we don't
119 // double count.
120 bool track_metrics_;
121
122 // Used to delay the check of Device Activity.
123 base::OneShotTimer<CrossDevicePromo> device_activity_timer_;
124
125 DISALLOW_COPY_AND_ASSIGN(CrossDevicePromo);
126 };
127
128 #endif // CHROME_BROWSER_SIGNIN_CROSS_DEVICE_PROMO_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698