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

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

Issue 10698024: rlz: Change omnibox / homepage access points from C1/C2 to C5/C6 on mac (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comments Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/rlz/rlz.h ('k') | chrome/browser/rlz/rlz_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 bool IsBrandOrganic(const std::string& brand) { 54 bool IsBrandOrganic(const std::string& brand) {
55 return brand.empty() || google_util::IsOrganic(brand); 55 return brand.empty() || google_util::IsOrganic(brand);
56 } 56 }
57 57
58 void RecordProductEvents(bool first_run, bool google_default_search, 58 void RecordProductEvents(bool first_run, bool google_default_search,
59 bool google_default_homepage, bool already_ran, 59 bool google_default_homepage, bool already_ran,
60 bool omnibox_used, bool homepage_used) { 60 bool omnibox_used, bool homepage_used) {
61 // Record the installation of chrome. We call this all the time but the rlz 61 // Record the installation of chrome. We call this all the time but the rlz
62 // lib should ingore all but the first one. 62 // lib should ingore all but the first one.
63 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 63 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
64 rlz_lib::CHROME_OMNIBOX, 64 RLZTracker::CHROME_OMNIBOX,
65 rlz_lib::INSTALL); 65 rlz_lib::INSTALL);
66 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 66 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
67 rlz_lib::CHROME_HOME_PAGE, 67 RLZTracker::CHROME_HOME_PAGE,
68 rlz_lib::INSTALL); 68 rlz_lib::INSTALL);
69 69
70 if (!already_ran) { 70 if (!already_ran) {
71 // Do the initial event recording if is the first run or if we have an 71 // Do the initial event recording if is the first run or if we have an
72 // empty rlz which means we haven't got a chance to do it. 72 // empty rlz which means we haven't got a chance to do it.
73 char omnibox_rlz[rlz_lib::kMaxRlzLength + 1]; 73 char omnibox_rlz[rlz_lib::kMaxRlzLength + 1];
74 if (!rlz_lib::GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, omnibox_rlz, 74 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, omnibox_rlz,
75 rlz_lib::kMaxRlzLength)) { 75 rlz_lib::kMaxRlzLength)) {
76 omnibox_rlz[0] = 0; 76 omnibox_rlz[0] = 0;
77 } 77 }
78 78
79 // Record if google is the initial search provider and/or home page. 79 // Record if google is the initial search provider and/or home page.
80 if ((first_run || omnibox_rlz[0] == 0) && google_default_search) { 80 if ((first_run || omnibox_rlz[0] == 0) && google_default_search) {
81 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 81 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
82 rlz_lib::CHROME_OMNIBOX, 82 RLZTracker::CHROME_OMNIBOX,
83 rlz_lib::SET_TO_GOOGLE); 83 rlz_lib::SET_TO_GOOGLE);
84 } 84 }
85 85
86 char homepage_rlz[rlz_lib::kMaxRlzLength + 1]; 86 char homepage_rlz[rlz_lib::kMaxRlzLength + 1];
87 if (!rlz_lib::GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, homepage_rlz, 87 if (!rlz_lib::GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, homepage_rlz,
88 rlz_lib::kMaxRlzLength)) { 88 rlz_lib::kMaxRlzLength)) {
89 homepage_rlz[0] = 0; 89 homepage_rlz[0] = 0;
90 } 90 }
91 91
92 if ((first_run || homepage_rlz[0] == 0) && google_default_homepage) { 92 if ((first_run || homepage_rlz[0] == 0) && google_default_homepage) {
93 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 93 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
94 rlz_lib::CHROME_HOME_PAGE, 94 RLZTracker::CHROME_HOME_PAGE,
95 rlz_lib::SET_TO_GOOGLE); 95 rlz_lib::SET_TO_GOOGLE);
96 } 96 }
97 } 97 }
98 98
99 // Record first user interaction with the omnibox. We call this all the 99 // Record first user interaction with the omnibox. We call this all the
100 // time but the rlz lib should ingore all but the first one. 100 // time but the rlz lib should ingore all but the first one.
101 if (omnibox_used) { 101 if (omnibox_used) {
102 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 102 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
103 rlz_lib::CHROME_OMNIBOX, 103 RLZTracker::CHROME_OMNIBOX,
104 rlz_lib::FIRST_SEARCH); 104 rlz_lib::FIRST_SEARCH);
105 } 105 }
106 106
107 // Record first user interaction with the home page. We call this all the 107 // Record first user interaction with the home page. We call this all the
108 // time but the rlz lib should ingore all but the first one. 108 // time but the rlz lib should ingore all but the first one.
109 if (homepage_used) { 109 if (homepage_used) {
110 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 110 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
111 rlz_lib::CHROME_HOME_PAGE, 111 RLZTracker::CHROME_HOME_PAGE,
112 rlz_lib::FIRST_SEARCH); 112 rlz_lib::FIRST_SEARCH);
113 } 113 }
114 } 114 }
115 115
116 bool SendFinancialPing(const std::string& brand, 116 bool SendFinancialPing(const std::string& brand,
117 const string16& lang, 117 const string16& lang,
118 const string16& referral) { 118 const string16& referral) {
119 rlz_lib::AccessPoint points[] = {rlz_lib::CHROME_OMNIBOX, 119 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX,
120 rlz_lib::CHROME_HOME_PAGE, 120 RLZTracker::CHROME_HOME_PAGE,
121 rlz_lib::NO_ACCESS_POINT}; 121 rlz_lib::NO_ACCESS_POINT};
122 std::string lang_ascii(UTF16ToASCII(lang)); 122 std::string lang_ascii(UTF16ToASCII(lang));
123 std::string referral_ascii(UTF16ToASCII(referral)); 123 std::string referral_ascii(UTF16ToASCII(referral));
124 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", 124 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome",
125 brand.c_str(), referral_ascii.c_str(), 125 brand.c_str(), referral_ascii.c_str(),
126 lang_ascii.c_str(), false, true); 126 lang_ascii.c_str(), false, true);
127 } 127 }
128 128
129 } // namespace 129 } // namespace
130 130
131 #if !defined(OS_MACOSX)
132 // static
133 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
134 rlz_lib::CHROME_OMNIBOX;
135 // static
136 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
137 rlz_lib::CHROME_HOME_PAGE;
138 #else
139 // static
140 const rlz_lib::AccessPoint RLZTracker::CHROME_OMNIBOX =
141 rlz_lib::CHROME_MAC_OMNIBOX;
142 // static
143 const rlz_lib::AccessPoint RLZTracker::CHROME_HOME_PAGE =
144 rlz_lib::CHROME_MAC_HOME_PAGE;
145 #endif
146
131 RLZTracker* RLZTracker::tracker_ = NULL; 147 RLZTracker* RLZTracker::tracker_ = NULL;
132 148
133 // static 149 // static
134 RLZTracker* RLZTracker::GetInstance() { 150 RLZTracker* RLZTracker::GetInstance() {
135 return tracker_ ? tracker_ : Singleton<RLZTracker>::get(); 151 return tracker_ ? tracker_ : Singleton<RLZTracker>::get();
136 } 152 }
137 153
138 RLZTracker::RLZTracker() 154 RLZTracker::RLZTracker()
139 : first_run_(false), 155 : first_run_(false),
140 send_ping_immediately_(false), 156 send_ping_immediately_(false),
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand) && 278 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand) &&
263 SendFinancialPing(brand, lang, referral)) { 279 SendFinancialPing(brand, lang, referral)) {
264 GoogleUpdateSettings::ClearReferral(); 280 GoogleUpdateSettings::ClearReferral();
265 281
266 { 282 {
267 base::AutoLock lock(cache_lock_); 283 base::AutoLock lock(cache_lock_);
268 rlz_cache_.clear(); 284 rlz_cache_.clear();
269 } 285 }
270 286
271 // Prime the RLZ cache for the access points we are interested in. 287 // Prime the RLZ cache for the access points we are interested in.
272 GetAccessPointRlz(rlz_lib::CHROME_OMNIBOX, NULL); 288 GetAccessPointRlz(RLZTracker::CHROME_OMNIBOX, NULL);
273 GetAccessPointRlz(rlz_lib::CHROME_HOME_PAGE, NULL); 289 GetAccessPointRlz(RLZTracker::CHROME_HOME_PAGE, NULL);
274 } 290 }
275 291
276 std::string reactivation_brand; 292 std::string reactivation_brand;
277 if (google_util::GetReactivationBrand(&reactivation_brand) && 293 if (google_util::GetReactivationBrand(&reactivation_brand) &&
278 !IsBrandOrganic(reactivation_brand)) { 294 !IsBrandOrganic(reactivation_brand)) {
279 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str()); 295 rlz_lib::SupplementaryBranding branding(reactivation_brand.c_str());
280 SendFinancialPing(reactivation_brand, lang, referral); 296 SendFinancialPing(reactivation_brand, lang, referral);
281 } 297 }
282 } 298 }
283 299
284 bool RLZTracker::SendFinancialPing(const std::string& brand, 300 bool RLZTracker::SendFinancialPing(const std::string& brand,
285 const string16& lang, 301 const string16& lang,
286 const string16& referral) { 302 const string16& referral) {
287 return ::SendFinancialPing(brand, lang, referral); 303 return ::SendFinancialPing(brand, lang, referral);
288 } 304 }
289 305
290 void RLZTracker::Observe(int type, 306 void RLZTracker::Observe(int type,
291 const content::NotificationSource& source, 307 const content::NotificationSource& source,
292 const content::NotificationDetails& details) { 308 const content::NotificationDetails& details) {
293 // Needs to be evaluated. See http://crbug.com/62328. 309 // Needs to be evaluated. See http://crbug.com/62328.
294 base::ThreadRestrictions::ScopedAllowIO allow_io; 310 base::ThreadRestrictions::ScopedAllowIO allow_io;
295 311
296 rlz_lib::AccessPoint point; 312 rlz_lib::AccessPoint point;
297 bool* record_used = NULL; 313 bool* record_used = NULL;
298 bool call_record = false; 314 bool call_record = false;
299 315
300 switch (type) { 316 switch (type) {
301 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: 317 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL:
302 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED: 318 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED:
303 point = rlz_lib::CHROME_OMNIBOX; 319 point = RLZTracker::CHROME_OMNIBOX;
304 record_used = &omnibox_used_; 320 record_used = &omnibox_used_;
305 call_record = true; 321 call_record = true;
306 322
307 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 323 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
308 content::NotificationService::AllSources()); 324 content::NotificationService::AllSources());
309 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, 325 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED,
310 content::NotificationService::AllSources()); 326 content::NotificationService::AllSources());
311 break; 327 break;
312 case content::NOTIFICATION_NAV_ENTRY_PENDING: { 328 case content::NOTIFICATION_NAV_ENTRY_PENDING: {
313 const NavigationEntry* entry = 329 const NavigationEntry* entry =
314 content::Details<content::NavigationEntry>(details).ptr(); 330 content::Details<content::NavigationEntry>(details).ptr();
315 if (entry != NULL && 331 if (entry != NULL &&
316 ((entry->GetTransitionType() & 332 ((entry->GetTransitionType() &
317 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { 333 content::PAGE_TRANSITION_HOME_PAGE) != 0)) {
318 point = rlz_lib::CHROME_HOME_PAGE; 334 point = RLZTracker::CHROME_HOME_PAGE;
319 record_used = &homepage_used_; 335 record_used = &homepage_used_;
320 call_record = true; 336 call_record = true;
321 337
322 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 338 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
323 content::NotificationService::AllSources()); 339 content::NotificationService::AllSources());
324 } 340 }
325 break; 341 break;
326 } 342 }
327 default: 343 default:
328 NOTREACHED(); 344 NOTREACHED();
329 break; 345 break;
330 } 346 }
331 347
332 if (call_record) { 348 if (call_record) {
333 // Try to record event now, else set the flag to try later when we 349 // Try to record event now, else set the flag to try later when we
334 // attempt the ping. 350 // attempt the ping.
335 if (!RecordProductEvent(rlz_lib::CHROME, point, rlz_lib::FIRST_SEARCH)) 351 if (!RecordProductEvent(rlz_lib::CHROME, point, rlz_lib::FIRST_SEARCH))
336 *record_used = true; 352 *record_used = true;
337 else if (send_ping_immediately_ && point == rlz_lib::CHROME_OMNIBOX) { 353 else if (send_ping_immediately_ && point == RLZTracker::CHROME_OMNIBOX) {
338 ScheduleDelayedInit(0); 354 ScheduleDelayedInit(0);
339 } 355 }
340 } 356 }
341 } 357 }
342 358
343 bool RLZTracker::RecordProductEvent(rlz_lib::Product product, 359 bool RLZTracker::RecordProductEvent(rlz_lib::Product product,
344 rlz_lib::AccessPoint point, 360 rlz_lib::AccessPoint point,
345 rlz_lib::Event event_id) { 361 rlz_lib::Event event_id) {
346 bool ret = rlz_lib::RecordProductEvent(product, point, event_id); 362 bool ret = rlz_lib::RecordProductEvent(product, point, event_id);
347 363
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
406 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, 422 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point,
407 not_used)); 423 not_used));
408 return true; 424 return true;
409 } 425 }
410 426
411 // static 427 // static
412 void RLZTracker::CleanupRlz() { 428 void RLZTracker::CleanupRlz() {
413 GetInstance()->rlz_cache_.clear(); 429 GetInstance()->rlz_cache_.clear();
414 GetInstance()->registrar_.RemoveAll(); 430 GetInstance()->registrar_.RemoveAll();
415 } 431 }
OLDNEW
« no previous file with comments | « chrome/browser/rlz/rlz.h ('k') | chrome/browser/rlz/rlz_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698