OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/google/google_util.h" | 26 #include "chrome/browser/google/google_util.h" |
27 #include "chrome/browser/search_engines/template_url.h" | 27 #include "chrome/browser/search_engines/template_url.h" |
28 #include "chrome/browser/search_engines/template_url_service.h" | 28 #include "chrome/browser/search_engines/template_url_service.h" |
29 #include "chrome/browser/search_engines/template_url_service_factory.h" | 29 #include "chrome/browser/search_engines/template_url_service_factory.h" |
30 #include "chrome/common/chrome_notification_types.h" | 30 #include "chrome/common/chrome_notification_types.h" |
31 #include "chrome/common/chrome_paths.h" | 31 #include "chrome/common/chrome_paths.h" |
32 #include "chrome/common/env_vars.h" | 32 #include "chrome/common/env_vars.h" |
33 #include "chrome/installer/util/google_update_settings.h" | 33 #include "chrome/installer/util/google_update_settings.h" |
34 #include "content/browser/browser_thread.h" | 34 #include "content/browser/browser_thread.h" |
35 #include "content/browser/tab_contents/navigation_entry.h" | 35 #include "content/browser/tab_contents/navigation_entry.h" |
36 #include "content/common/notification_service.h" | 36 #include "content/public/browser/notification_service.h" |
37 | 37 |
38 namespace { | 38 namespace { |
39 | 39 |
40 void RecordProductEvents(bool first_run, bool google_default_search, | 40 void RecordProductEvents(bool first_run, bool google_default_search, |
41 bool google_default_homepage, bool already_ran, | 41 bool google_default_homepage, bool already_ran, |
42 bool omnibox_used, bool homepage_used) { | 42 bool omnibox_used, bool homepage_used) { |
43 // Record the installation of chrome. We call this all the time but the rlz | 43 // Record the installation of chrome. We call this all the time but the rlz |
44 // lib should ingore all but the first one. | 44 // lib should ingore all but the first one. |
45 rlz_lib::RecordProductEvent(rlz_lib::CHROME, | 45 rlz_lib::RecordProductEvent(rlz_lib::CHROME, |
46 rlz_lib::CHROME_OMNIBOX, | 46 rlz_lib::CHROME_OMNIBOX, |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 const int kMaxDelay = 200 * 1000; | 172 const int kMaxDelay = 200 * 1000; |
173 const int kMinDelay = 20 * 1000; | 173 const int kMinDelay = 20 * 1000; |
174 | 174 |
175 delay *= 1000; | 175 delay *= 1000; |
176 delay = (delay < kMinDelay) ? kMinDelay : delay; | 176 delay = (delay < kMinDelay) ? kMinDelay : delay; |
177 delay = (delay > kMaxDelay) ? kMaxDelay : delay; | 177 delay = (delay > kMaxDelay) ? kMaxDelay : delay; |
178 | 178 |
179 // Register for notifications from the omnibox so that we can record when | 179 // Register for notifications from the omnibox so that we can record when |
180 // the user performs a first search. | 180 // the user performs a first search. |
181 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 181 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
182 NotificationService::AllSources()); | 182 content::NotificationService::AllSources()); |
183 // If instant is enabled we'll start searching as soon as the user starts | 183 // If instant is enabled we'll start searching as soon as the user starts |
184 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). | 184 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). |
185 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | 185 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, |
186 NotificationService::AllSources()); | 186 content::NotificationService::AllSources()); |
187 | 187 |
188 // Register for notifications from navigations, to see if the user has used | 188 // Register for notifications from navigations, to see if the user has used |
189 // the home page. | 189 // the home page. |
190 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 190 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
191 NotificationService::AllSources()); | 191 content::NotificationService::AllSources()); |
192 | 192 |
193 ScheduleDelayedInit(delay); | 193 ScheduleDelayedInit(delay); |
194 | 194 |
195 return true; | 195 return true; |
196 } | 196 } |
197 | 197 |
198 void RLZTracker::ScheduleDelayedInit(int delay) { | 198 void RLZTracker::ScheduleDelayedInit(int delay) { |
199 BrowserThread::PostDelayedTask( | 199 BrowserThread::PostDelayedTask( |
200 BrowserThread::FILE, | 200 BrowserThread::FILE, |
201 FROM_HERE, | 201 FROM_HERE, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bool call_record = false; | 284 bool call_record = false; |
285 | 285 |
286 switch (type) { | 286 switch (type) { |
287 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: | 287 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: |
288 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED: | 288 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED: |
289 point = rlz_lib::CHROME_OMNIBOX; | 289 point = rlz_lib::CHROME_OMNIBOX; |
290 record_used = &omnibox_used_; | 290 record_used = &omnibox_used_; |
291 call_record = true; | 291 call_record = true; |
292 | 292 |
293 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 293 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
294 NotificationService::AllSources()); | 294 content::NotificationService::AllSources()); |
295 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | 295 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, |
296 NotificationService::AllSources()); | 296 content::NotificationService::AllSources()); |
297 break; | 297 break; |
298 case content::NOTIFICATION_NAV_ENTRY_PENDING: { | 298 case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
299 const NavigationEntry* entry = | 299 const NavigationEntry* entry = |
300 content::Details<NavigationEntry>(details).ptr(); | 300 content::Details<NavigationEntry>(details).ptr(); |
301 if (entry != NULL && | 301 if (entry != NULL && |
302 ((entry->transition_type() & | 302 ((entry->transition_type() & |
303 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { | 303 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { |
304 point = rlz_lib::CHROME_HOME_PAGE; | 304 point = rlz_lib::CHROME_HOME_PAGE; |
305 record_used = &homepage_used_; | 305 record_used = &homepage_used_; |
306 call_record = true; | 306 call_record = true; |
307 | 307 |
308 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 308 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
309 NotificationService::AllSources()); | 309 content::NotificationService::AllSources()); |
310 } | 310 } |
311 break; | 311 break; |
312 } | 312 } |
313 default: | 313 default: |
314 NOTREACHED(); | 314 NOTREACHED(); |
315 break; | 315 break; |
316 } | 316 } |
317 | 317 |
318 if (call_record) { | 318 if (call_record) { |
319 // Try to record event now, else set the flag to try later when we | 319 // Try to record event now, else set the flag to try later when we |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 BrowserThread::FILE, FROM_HERE, | 391 BrowserThread::FILE, FROM_HERE, |
392 NewRunnableFunction(&RLZTracker::GetAccessPointRlz, point, not_used)); | 392 NewRunnableFunction(&RLZTracker::GetAccessPointRlz, point, not_used)); |
393 return true; | 393 return true; |
394 } | 394 } |
395 | 395 |
396 // static | 396 // static |
397 void RLZTracker::CleanupRlz() { | 397 void RLZTracker::CleanupRlz() { |
398 GetInstance()->rlz_cache_.clear(); | 398 GetInstance()->rlz_cache_.clear(); |
399 GetInstance()->registrar_.RemoveAll(); | 399 GetInstance()->registrar_.RemoveAll(); |
400 } | 400 } |
OLD | NEW |