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

Side by Side Diff: chrome/browser/rlz/rlz.cc

Issue 220193005: Add RLZ Access points for the app launcher. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 6 years, 8 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
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 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work 5 // This code glues the RLZ library DLL with Chrome. It allows Chrome to work
6 // with or without the DLL being present. If the DLL is not present the 6 // with or without the DLL being present. If the DLL is not present the
7 // functions do nothing and just return false. 7 // functions do nothing and just return false.
8 8
9 #include "chrome/browser/rlz/rlz.h" 9 #include "chrome/browser/rlz/rlz.h"
10 10
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 bool homepage_used) { 76 bool homepage_used) {
77 TRACE_EVENT0("RLZ", "RecordProductEvents"); 77 TRACE_EVENT0("RLZ", "RecordProductEvents");
78 // Record the installation of chrome. We call this all the time but the rlz 78 // Record the installation of chrome. We call this all the time but the rlz
79 // lib should ignore all but the first one. 79 // lib should ignore all but the first one.
80 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 80 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
81 RLZTracker::CHROME_OMNIBOX, 81 RLZTracker::CHROME_OMNIBOX,
82 rlz_lib::INSTALL); 82 rlz_lib::INSTALL);
83 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 83 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
84 RLZTracker::CHROME_HOME_PAGE, 84 RLZTracker::CHROME_HOME_PAGE,
85 rlz_lib::INSTALL); 85 rlz_lib::INSTALL);
86 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
87 RLZTracker::CHROME_APP_LIST,
88 rlz_lib::INSTALL);
86 89
87 if (!already_ran) { 90 if (!already_ran) {
88 // Do the initial event recording if is the first run or if we have an 91 // Do the initial event recording if is the first run or if we have an
89 // empty rlz which means we haven't got a chance to do it. 92 // empty rlz which means we haven't got a chance to do it.
90 char omnibox_rlz[rlz_lib::kMaxRlzLength + 1]; 93 char omnibox_rlz[rlz_lib::kMaxRlzLength + 1];
91 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, omnibox_rlz, 94 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, omnibox_rlz,
92 rlz_lib::kMaxRlzLength)) { 95 rlz_lib::kMaxRlzLength)) {
93 omnibox_rlz[0] = 0; 96 omnibox_rlz[0] = 0;
94 } 97 }
95 98
96 // Record if google is the initial search provider and/or home page. 99 // Record if google is the initial search provider and/or home page.
97 if ((first_run || omnibox_rlz[0] == 0) && is_google_default_search) { 100 if ((first_run || omnibox_rlz[0] == 0) && is_google_default_search) {
98 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 101 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
99 RLZTracker::CHROME_OMNIBOX, 102 RLZTracker::CHROME_OMNIBOX,
100 rlz_lib::SET_TO_GOOGLE); 103 rlz_lib::SET_TO_GOOGLE);
101 } 104 }
102 105
103 char homepage_rlz[rlz_lib::kMaxRlzLength + 1]; 106 char homepage_rlz[rlz_lib::kMaxRlzLength + 1];
104 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, homepage_rlz, 107 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, homepage_rlz,
105 rlz_lib::kMaxRlzLength)) { 108 rlz_lib::kMaxRlzLength)) {
106 homepage_rlz[0] = 0; 109 homepage_rlz[0] = 0;
107 } 110 }
108 111
109 if ((first_run || homepage_rlz[0] == 0) && 112 if ((first_run || homepage_rlz[0] == 0) &&
110 (is_google_homepage || is_google_in_startpages)) { 113 (is_google_homepage || is_google_in_startpages)) {
111 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 114 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
112 RLZTracker::CHROME_HOME_PAGE, 115 RLZTracker::CHROME_HOME_PAGE,
113 rlz_lib::SET_TO_GOOGLE); 116 rlz_lib::SET_TO_GOOGLE);
114 } 117 }
118
119 char app_list_rlz[rlz_lib::kMaxRlzLength + 1];
120 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, app_list_rlz,
121 rlz_lib::kMaxRlzLength)) {
122 app_list_rlz[0] = 0;
123 }
124
125 // Record if google is the initial search provider and/or home page.
126 if ((first_run || app_list_rlz[0] == 0) && is_google_default_search) {
127 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
128 RLZTracker::CHROME_APP_LIST,
129 rlz_lib::SET_TO_GOOGLE);
130 }
115 } 131 }
116 132
117 // Record first user interaction with the omnibox. We call this all the 133 // Record first user interaction with the omnibox. We call this all the
118 // time but the rlz lib should ingore all but the first one. 134 // time but the rlz lib should ingore all but the first one.
119 if (omnibox_used) { 135 if (omnibox_used) {
120 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 136 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
121 RLZTracker::CHROME_OMNIBOX, 137 RLZTracker::CHROME_OMNIBOX,
122 rlz_lib::FIRST_SEARCH); 138 rlz_lib::FIRST_SEARCH);
123 } 139 }
124 140
125 // Record first user interaction with the home page. We call this all the 141 // Record first user interaction with the home page. We call this all the
126 // time but the rlz lib should ingore all but the first one. 142 // time but the rlz lib should ingore all but the first one.
127 if (homepage_used || is_google_in_startpages) { 143 if (homepage_used || is_google_in_startpages) {
128 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 144 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
129 RLZTracker::CHROME_HOME_PAGE, 145 RLZTracker::CHROME_HOME_PAGE,
130 rlz_lib::FIRST_SEARCH); 146 rlz_lib::FIRST_SEARCH);
131 } 147 }
132 } 148 }
133 149
134 bool SendFinancialPing(const std::string& brand, 150 bool SendFinancialPing(const std::string& brand,
135 const base::string16& lang, 151 const base::string16& lang,
136 const base::string16& referral) { 152 const base::string16& referral) {
137 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, 153 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX,
138 RLZTracker::CHROME_HOME_PAGE, 154 RLZTracker::CHROME_HOME_PAGE,
155 RLZTracker::CHROME_APP_LIST,
139 rlz_lib::NO_ACCESS_POINT}; 156 rlz_lib::NO_ACCESS_POINT};
140 std::string lang_ascii(base::UTF16ToASCII(lang)); 157 std::string lang_ascii(base::UTF16ToASCII(lang));
141 std::string referral_ascii(base::UTF16ToASCII(referral)); 158 std::string referral_ascii(base::UTF16ToASCII(referral));
142 std::string product_signature; 159 std::string product_signature;
143 #if defined(OS_CHROMEOS) 160 #if defined(OS_CHROMEOS)
144 product_signature = "chromeos"; 161 product_signature = "chromeos";
145 #else 162 #else
146 product_signature = "chrome"; 163 product_signature = "chrome";
147 #endif 164 #endif
148 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, 165 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points,
149 product_signature.c_str(), 166 product_signature.c_str(),
150 brand.c_str(), referral_ascii.c_str(), 167 brand.c_str(), referral_ascii.c_str(),
151 lang_ascii.c_str(), false, true); 168 lang_ascii.c_str(), false, true);
152 } 169 }
153 170
154 } // namespace 171 } // namespace
155 172
156 #if defined(OS_WIN) 173 #if defined(OS_WIN)
157 // static 174 // static
158 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 175 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
159 rlz_lib::CHROME_OMNIBOX; 176 rlz_lib::CHROME_OMNIBOX;
160 // static 177 // static
161 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 178 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
162 rlz_lib::CHROME_HOME_PAGE; 179 rlz_lib::CHROME_HOME_PAGE;
180 // static
181 const rlz_lib::AccessPoint RLZTracker::CHROME_APP_LIST =
182 rlz_lib::CHROME_APP_LIST;
163 #elif defined(OS_IOS) 183 #elif defined(OS_IOS)
164 // static 184 // static
165 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 185 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
166 rlz_lib::CHROME_IOS_OMNIBOX; 186 rlz_lib::CHROME_IOS_OMNIBOX;
167 // static 187 // static
168 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 188 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
169 rlz_lib::CHROME_IOS_HOME_PAGE; 189 rlz_lib::CHROME_IOS_HOME_PAGE;
190 // static
191 const rlz_lib::AccessPoint RLZTracker::CHROME_APP_LIST =
192 rlz_lib::NO_ACCESS_POINT;
Roger Tawa OOO till Jul 10th 2014/04/01 14:20:18 Hmm, this is brittle. Makes the order of the acce
Sam McNally 2014/04/02 01:27:28 Done.
170 #elif defined(OS_MACOSX) 193 #elif defined(OS_MACOSX)
171 // static 194 // static
172 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 195 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
173 rlz_lib::CHROME_MAC_OMNIBOX; 196 rlz_lib::CHROME_MAC_OMNIBOX;
174 // static 197 // static
175 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 198 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
176 rlz_lib::CHROME_MAC_HOME_PAGE; 199 rlz_lib::CHROME_MAC_HOME_PAGE;
200 // static
201 const rlz_lib::AccessPoint RLZTracker::CHROME_APP_LIST =
202 rlz_lib::CHROME_MAC_APP_LIST;
177 #elif defined(OS_CHROMEOS) 203 #elif defined(OS_CHROMEOS)
178 // static 204 // static
179 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX = 205 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
180 rlz_lib::CHROMEOS_OMNIBOX; 206 rlz_lib::CHROMEOS_OMNIBOX;
181 // static 207 // static
182 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE = 208 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
183 rlz_lib::CHROMEOS_HOME_PAGE; 209 rlz_lib::CHROMEOS_HOME_PAGE;
210 // static
211 const rlz_lib::AccessPoint RLZTracker::CHROME_APP_LIST =
212 rlz_lib::CHROMEOS_APP_LIST;
184 #endif 213 #endif
185 214
186 RLZTracker* RLZTracker::tracker_ = NULL; 215 RLZTracker* RLZTracker::tracker_ = NULL;
187 216
188 // static 217 // static
189 RLZTracker* RLZTracker::GetInstance() { 218 RLZTracker* RLZTracker::GetInstance() {
190 return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); 219 return tracker_ ? tracker_ : Singleton<RLZTracker>::get();
191 } 220 }
192 221
193 RLZTracker::RLZTracker() 222 RLZTracker::RLZTracker()
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 GoogleUpdateSettings::ClearReferral(); 396 GoogleUpdateSettings::ClearReferral();
368 397
369 { 398 {
370 base::AutoLock lock(cache_lock_); 399 base::AutoLock lock(cache_lock_);
371 rlz_cache_.clear(); 400 rlz_cache_.clear();
372 } 401 }
373 402
374 // Prime the RLZ cache for the access points we are interested in. 403 // Prime the RLZ cache for the access points we are interested in.
375 GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL); 404 GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL);
376 GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL); 405 GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL);
406 GetAccessPointRlz(RLZTracker::CHROME_APP_LIST, NULL);
377 } 407 }
378 408
379 if (!IsBrandOrganic(reactivation_brand_)) { 409 if (!IsBrandOrganic(reactivation_brand_)) {
380 rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str()); 410 rlz_lib::SupplementaryBranding branding(reactivation_brand_.c_str());
381 SendFinancialPing(reactivation_brand_, lang, referral); 411 SendFinancialPing(reactivation_brand_, lang, referral);
382 } 412 }
383 } 413 }
384 414
385 bool RLZTracker::SendFinancialPing(const std::string& brand, 415 bool RLZTracker::SendFinancialPing(const std::string& brand,
386 const base::string16& lang, 416 const base::string16& lang,
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 void RLZTracker::CleanupRlz() { 616 void RLZTracker::CleanupRlz() {
587 GetInstance()->rlz_cache_.clear(); 617 GetInstance()->rlz_cache_.clear();
588 GetInstance()->registrar_.RemoveAll(); 618 GetInstance()->registrar_.RemoveAll();
589 rlz_lib::SetURLRequestContext(NULL); 619 rlz_lib::SetURLRequestContext(NULL);
590 } 620 }
591 621
592 // static 622 // static
593 void RLZTracker::EnableZeroDelayForTesting() { 623 void RLZTracker::EnableZeroDelayForTesting() {
594 GetInstance()->min_init_delay_ = base::TimeDelta(); 624 GetInstance()->min_init_delay_ = base::TimeDelta();
595 } 625 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698