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

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

Issue 10829302: rlz: Do not record omnibox events for non-branded builds (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | « no previous file | no next file » | 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 namespace { 52 namespace {
53 53
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 ignore all but the first one.
63 rlz_lib::RecordProductEvent(rlz_lib::CHROME, 63 rlz_lib::RecordProductEvent(rlz_lib::CHROME,
64 RLZTracker::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 RLZTracker::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.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 188
189 // Maximum and minimum delay we would allow to be set through master 189 // Maximum and minimum delay we would allow to be set through master
190 // preferences. Somewhat arbitrary, may need to be adjusted in future. 190 // preferences. Somewhat arbitrary, may need to be adjusted in future.
191 const int kMaxDelay = 200 * 1000; 191 const int kMaxDelay = 200 * 1000;
192 const int kMinDelay = 20 * 1000; 192 const int kMinDelay = 20 * 1000;
193 193
194 delay *= 1000; 194 delay *= 1000;
195 delay = (delay < kMinDelay) ? kMinDelay : delay; 195 delay = (delay < kMinDelay) ? kMinDelay : delay;
196 delay = (delay > kMaxDelay) ? kMaxDelay : delay; 196 delay = (delay > kMaxDelay) ? kMaxDelay : delay;
197 197
198 // Register for notifications from the omnibox so that we can record when 198 std::string brand;
199 // the user performs a first search. 199 if (google_util::GetBrand(&brand) && !IsBrandOrganic(brand)) {
200 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, 200 // Register for notifications from the omnibox so that we can record when
201 content::NotificationService::AllSources()); 201 // the user performs a first search.
202 // If instant is enabled we'll start searching as soon as the user starts 202 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL,
203 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). 203 content::NotificationService::AllSources());
204 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, 204 // If instant is enabled we'll start searching as soon as the user starts
205 content::NotificationService::AllSources()); 205 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED).
206 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED,
207 content::NotificationService::AllSources());
206 208
207 // Register for notifications from navigations, to see if the user has used 209 // Register for notifications from navigations, to see if the user has used
208 // the home page. 210 // the home page.
209 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, 211 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING,
210 content::NotificationService::AllSources()); 212 content::NotificationService::AllSources());
213 }
211 214
212 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); 215 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context());
213 ScheduleDelayedInit(delay); 216 ScheduleDelayedInit(delay);
214 217
215 return true; 218 return true;
216 } 219 }
217 220
218 void RLZTracker::ScheduleDelayedInit(int delay) { 221 void RLZTracker::ScheduleDelayedInit(int delay) {
219 // The RLZTracker is a singleton object that outlives any runnable tasks 222 // The RLZTracker is a singleton object that outlives any runnable tasks
220 // that will be queued up. 223 // that will be queued up.
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, 425 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point,
423 not_used)); 426 not_used));
424 return true; 427 return true;
425 } 428 }
426 429
427 // static 430 // static
428 void RLZTracker::CleanupRlz() { 431 void RLZTracker::CleanupRlz() {
429 GetInstance()->rlz_cache_.clear(); 432 GetInstance()->rlz_cache_.clear();
430 GetInstance()->registrar_.RemoveAll(); 433 GetInstance()->registrar_.RemoveAll();
431 } 434 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698