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 // 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 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) | 271 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) |
272 EnableZeroDelayForTesting(); | 272 EnableZeroDelayForTesting(); |
273 | 273 |
274 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); | 274 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); |
275 | 275 |
276 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { | 276 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { |
277 // Register for notifications from the omnibox so that we can record when | 277 // Register for notifications from the omnibox so that we can record when |
278 // the user performs a first search. | 278 // the user performs a first search. |
279 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 279 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
280 content::NotificationService::AllSources()); | 280 content::NotificationService::AllSources()); |
281 // If instant is enabled we'll start searching as soon as the user starts | |
282 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). | |
283 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | |
284 content::NotificationService::AllSources()); | |
285 | 281 |
286 // Register for notifications from navigations, to see if the user has used | 282 // Register for notifications from navigations, to see if the user has used |
287 // the home page. | 283 // the home page. |
288 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 284 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
289 content::NotificationService::AllSources()); | 285 content::NotificationService::AllSources()); |
290 } | 286 } |
291 google_util::GetReactivationBrand(&reactivation_brand_); | 287 google_util::GetReactivationBrand(&reactivation_brand_); |
292 | 288 |
293 net::URLRequestContextGetter* context_getter = | 289 net::URLRequestContextGetter* context_getter = |
294 g_browser_process->system_request_context(); | 290 g_browser_process->system_request_context(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 const string16& lang, | 375 const string16& lang, |
380 const string16& referral) { | 376 const string16& referral) { |
381 return ::SendFinancialPing(brand, lang, referral); | 377 return ::SendFinancialPing(brand, lang, referral); |
382 } | 378 } |
383 | 379 |
384 void RLZTracker::Observe(int type, | 380 void RLZTracker::Observe(int type, |
385 const content::NotificationSource& source, | 381 const content::NotificationSource& source, |
386 const content::NotificationDetails& details) { | 382 const content::NotificationDetails& details) { |
387 switch (type) { | 383 switch (type) { |
388 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: | 384 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: |
389 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED: | |
390 RecordFirstSearch(CHROME_OMNIBOX); | 385 RecordFirstSearch(CHROME_OMNIBOX); |
391 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 386 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
392 content::NotificationService::AllSources()); | 387 content::NotificationService::AllSources()); |
393 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | |
394 content::NotificationService::AllSources()); | |
395 break; | 388 break; |
396 case content::NOTIFICATION_NAV_ENTRY_PENDING: { | 389 case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
397 const NavigationEntry* entry = | 390 const NavigationEntry* entry = |
398 content::Details<content::NavigationEntry>(details).ptr(); | 391 content::Details<content::NavigationEntry>(details).ptr(); |
399 if (entry != NULL && | 392 if (entry != NULL && |
400 ((entry->GetTransitionType() & | 393 ((entry->GetTransitionType() & |
401 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { | 394 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { |
402 RecordFirstSearch(CHROME_HOME_PAGE); | 395 RecordFirstSearch(CHROME_HOME_PAGE); |
403 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 396 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
404 content::NotificationService::AllSources()); | 397 content::NotificationService::AllSources()); |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 void RLZTracker::CleanupRlz() { | 571 void RLZTracker::CleanupRlz() { |
579 GetInstance()->rlz_cache_.clear(); | 572 GetInstance()->rlz_cache_.clear(); |
580 GetInstance()->registrar_.RemoveAll(); | 573 GetInstance()->registrar_.RemoveAll(); |
581 rlz_lib::SetURLRequestContext(NULL); | 574 rlz_lib::SetURLRequestContext(NULL); |
582 } | 575 } |
583 | 576 |
584 // static | 577 // static |
585 void RLZTracker::EnableZeroDelayForTesting() { | 578 void RLZTracker::EnableZeroDelayForTesting() { |
586 GetInstance()->min_init_delay_ = base::TimeDelta(); | 579 GetInstance()->min_init_delay_ = base::TimeDelta(); |
587 } | 580 } |
OLD | NEW |