| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #ifndef CHROME_BROWSER_RLZ_RLZ_H_ | 5 #ifndef CHROME_BROWSER_RLZ_RLZ_H_ |
| 6 #define CHROME_BROWSER_RLZ_RLZ_H_ | 6 #define CHROME_BROWSER_RLZ_RLZ_H_ |
| 7 | 7 |
| 8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
| 9 | 9 |
| 10 #if defined(ENABLE_RLZ) | 10 #if defined(ENABLE_RLZ) |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 // Records an RLZ event. Some events can be access point independent. | 55 // Records an RLZ event. Some events can be access point independent. |
| 56 // Returns false it the event could not be recorded. Requires write access | 56 // Returns false it the event could not be recorded. Requires write access |
| 57 // to the HKCU registry hive on windows. | 57 // to the HKCU registry hive on windows. |
| 58 static bool RecordProductEvent(rlz_lib::Product product, | 58 static bool RecordProductEvent(rlz_lib::Product product, |
| 59 rlz_lib::AccessPoint point, | 59 rlz_lib::AccessPoint point, |
| 60 rlz_lib::Event event_id); | 60 rlz_lib::Event event_id); |
| 61 | 61 |
| 62 // For the point parameter of RecordProductEvent. | 62 // For the point parameter of RecordProductEvent. |
| 63 static const rlz_lib::AccessPoint CHROME_OMNIBOX; | 63 static const rlz_lib::AccessPoint CHROME_OMNIBOX; |
| 64 static const rlz_lib::AccessPoint CHROME_HOME_PAGE; | 64 static const rlz_lib::AccessPoint CHROME_HOME_PAGE; |
| 65 #if !defined(OS_IOS) |
| 66 static const rlz_lib::AccessPoint CHROME_APP_LIST; |
| 67 #endif |
| 65 | 68 |
| 66 // Gets the HTTP header value that can be added to requests from the | 69 // Gets the HTTP header value that can be added to requests from the |
| 67 // specific access point. The string returned is of the form: | 70 // specific access point. The string returned is of the form: |
| 68 // | 71 // |
| 69 // "X-Rlz-String: <access-point-rlz>\r\n" | 72 // "X-Rlz-String: <access-point-rlz>\r\n" |
| 70 // | 73 // |
| 71 static std::string GetAccessPointHttpHeader(rlz_lib::AccessPoint point); | 74 static std::string GetAccessPointHttpHeader(rlz_lib::AccessPoint point); |
| 72 | 75 |
| 73 // Gets the RLZ value of the access point. | 76 // Gets the RLZ value of the access point. |
| 74 // Returns false if the rlz string could not be obtained. In some cases | 77 // Returns false if the rlz string could not be obtained. In some cases |
| 75 // an empty string can be returned which is not an error. | 78 // an empty string can be returned which is not an error. |
| 76 static bool GetAccessPointRlz(rlz_lib::AccessPoint point, | 79 static bool GetAccessPointRlz(rlz_lib::AccessPoint point, |
| 77 base::string16* rlz); | 80 base::string16* rlz); |
| 78 | 81 |
| 79 // Invoked during shutdown to clean up any state created by RLZTracker. | 82 // Invoked during shutdown to clean up any state created by RLZTracker. |
| 80 static void CleanupRlz(); | 83 static void CleanupRlz(); |
| 81 | 84 |
| 82 #if defined(OS_CHROMEOS) | 85 #if defined(OS_CHROMEOS) |
| 83 // Clears all product state. Should be called when turning RLZ off. On other | 86 // Clears all product state. Should be called when turning RLZ off. On other |
| 84 // platforms, this is done by product uninstaller. | 87 // platforms, this is done by product uninstaller. |
| 85 static void ClearRlzState(); | 88 static void ClearRlzState(); |
| 86 #endif | 89 #endif |
| 87 | 90 |
| 88 // This method is public for use by the Singleton class. | 91 // This method is public for use by the Singleton class. |
| 89 static RLZTracker* GetInstance(); | 92 static RLZTracker* GetInstance(); |
| 90 | 93 |
| 91 // Enables zero delay for InitRlzFromProfileDelayed. For testing only. | 94 // Enables zero delay for InitRlzFromProfileDelayed. For testing only. |
| 92 static void EnableZeroDelayForTesting(); | 95 static void EnableZeroDelayForTesting(); |
| 93 | 96 |
| 97 #if !defined(OS_IOS) |
| 98 // Records that the app list search has been used. |
| 99 static void RecordAppListSearch(); |
| 100 #endif |
| 101 |
| 94 // The following methods are made protected so that they can be used for | 102 // The following methods are made protected so that they can be used for |
| 95 // testing purposes. Production code should never need to call these. | 103 // testing purposes. Production code should never need to call these. |
| 96 protected: | 104 protected: |
| 97 RLZTracker(); | 105 RLZTracker(); |
| 98 virtual ~RLZTracker(); | 106 virtual ~RLZTracker(); |
| 99 | 107 |
| 100 // Called by InitRlzFromProfileDelayed with values taken from |profile|. | 108 // Called by InitRlzFromProfileDelayed with values taken from |profile|. |
| 101 static bool InitRlzDelayed(bool first_run, | 109 static bool InitRlzDelayed(bool first_run, |
| 102 bool send_ping_immediately, | 110 bool send_ping_immediately, |
| 103 base::TimeDelta delay, | 111 base::TimeDelta delay, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 | 188 |
| 181 #if defined(OS_CHROMEOS) | 189 #if defined(OS_CHROMEOS) |
| 182 // Implementation called from ClearRlzState static method. | 190 // Implementation called from ClearRlzState static method. |
| 183 void ClearRlzStateImpl(); | 191 void ClearRlzStateImpl(); |
| 184 | 192 |
| 185 // Schedules a call to ClearRlzStateImpl(). This method is virtual | 193 // Schedules a call to ClearRlzStateImpl(). This method is virtual |
| 186 // to allow tests to override how the scheduling is done. | 194 // to allow tests to override how the scheduling is done. |
| 187 virtual bool ScheduleClearRlzState(); | 195 virtual bool ScheduleClearRlzState(); |
| 188 #endif | 196 #endif |
| 189 | 197 |
| 198 // Returns a pointer to the bool corresponding to whether |point| has been |
| 199 // used but not reported. |
| 200 bool* GetAccessPointRecord(rlz_lib::AccessPoint point); |
| 201 |
| 190 // Tracker used for testing purposes only. If this value is non-NULL, it | 202 // Tracker used for testing purposes only. If this value is non-NULL, it |
| 191 // will be returned from GetInstance() instead of the regular singleton. | 203 // will be returned from GetInstance() instead of the regular singleton. |
| 192 static RLZTracker* tracker_; | 204 static RLZTracker* tracker_; |
| 193 | 205 |
| 194 // Configuation data for RLZ tracker. Set by call to Init(). | 206 // Configuation data for RLZ tracker. Set by call to Init(). |
| 195 bool first_run_; | 207 bool first_run_; |
| 196 bool send_ping_immediately_; | 208 bool send_ping_immediately_; |
| 197 bool is_google_default_search_; | 209 bool is_google_default_search_; |
| 198 bool is_google_homepage_; | 210 bool is_google_homepage_; |
| 199 bool is_google_in_startpages_; | 211 bool is_google_in_startpages_; |
| 200 | 212 |
| 201 // Unique sequence token so that tasks posted by RLZTracker are executed | 213 // Unique sequence token so that tasks posted by RLZTracker are executed |
| 202 // sequentially in the blocking pool. | 214 // sequentially in the blocking pool. |
| 203 base::SequencedWorkerPool::SequenceToken worker_pool_token_; | 215 base::SequencedWorkerPool::SequenceToken worker_pool_token_; |
| 204 | 216 |
| 205 // Keeps track if the RLZ tracker has already performed its delayed | 217 // Keeps track if the RLZ tracker has already performed its delayed |
| 206 // initialization. | 218 // initialization. |
| 207 bool already_ran_; | 219 bool already_ran_; |
| 208 | 220 |
| 209 // Keeps a cache of RLZ access point strings, since they rarely change. | 221 // Keeps a cache of RLZ access point strings, since they rarely change. |
| 210 // The cache must be protected by a lock since it may be accessed from | 222 // The cache must be protected by a lock since it may be accessed from |
| 211 // the UI thread for reading and the IO thread for reading and/or writing. | 223 // the UI thread for reading and the IO thread for reading and/or writing. |
| 212 base::Lock cache_lock_; | 224 base::Lock cache_lock_; |
| 213 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; | 225 std::map<rlz_lib::AccessPoint, base::string16> rlz_cache_; |
| 214 | 226 |
| 215 // Keeps track of whether the omnibox or host page have been used. | 227 // Keeps track of whether the omnibox, home page or app list have been used. |
| 216 bool omnibox_used_; | 228 bool omnibox_used_; |
| 217 bool homepage_used_; | 229 bool homepage_used_; |
| 230 bool app_list_used_; |
| 218 | 231 |
| 219 // Main and (optionally) reactivation brand codes, assigned on UI thread. | 232 // Main and (optionally) reactivation brand codes, assigned on UI thread. |
| 220 std::string brand_; | 233 std::string brand_; |
| 221 std::string reactivation_brand_; | 234 std::string reactivation_brand_; |
| 222 | 235 |
| 223 content::NotificationRegistrar registrar_; | 236 content::NotificationRegistrar registrar_; |
| 224 | 237 |
| 225 // Minimum delay before sending financial ping after initialization. | 238 // Minimum delay before sending financial ping after initialization. |
| 226 base::TimeDelta min_init_delay_; | 239 base::TimeDelta min_init_delay_; |
| 227 | 240 |
| 228 DISALLOW_COPY_AND_ASSIGN(RLZTracker); | 241 DISALLOW_COPY_AND_ASSIGN(RLZTracker); |
| 229 }; | 242 }; |
| 230 | 243 |
| 231 #endif // defined(ENABLE_RLZ) | 244 #endif // defined(ENABLE_RLZ) |
| 232 | 245 |
| 233 #endif // CHROME_BROWSER_RLZ_RLZ_H_ | 246 #endif // CHROME_BROWSER_RLZ_RLZ_H_ |
| OLD | NEW |