OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 |
11 #include <algorithm> | 11 #include <algorithm> |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) | 267 if (CommandLine::ForCurrentProcess()->HasSwitch(::switches::kTestType)) |
268 EnableZeroDelayForTesting(); | 268 EnableZeroDelayForTesting(); |
269 | 269 |
270 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); | 270 delay = std::min(kMaxInitDelay, std::max(min_init_delay_, delay)); |
271 | 271 |
272 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { | 272 if (google_util::GetBrand(&brand_) && !IsBrandOrganic(brand_)) { |
273 // Register for notifications from the omnibox so that we can record when | 273 // Register for notifications from the omnibox so that we can record when |
274 // the user performs a first search. | 274 // the user performs a first search. |
275 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 275 registrar_.Add(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
276 content::NotificationService::AllSources()); | 276 content::NotificationService::AllSources()); |
277 // If instant is enabled we'll start searching as soon as the user starts | 277 // If Instant is enabled we'll start searching as soon as the user starts |
278 // typing in the omnibox (which triggers INSTANT_CONTROLLER_UPDATED). | 278 // typing in the omnibox (which triggers INSTANT_UPDATED). |
279 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | 279 registrar_.Add(this, chrome::NOTIFICATION_INSTANT_UPDATED, |
280 content::NotificationService::AllSources()); | 280 content::NotificationService::AllSources()); |
281 | 281 |
282 // 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 |
283 // the home page. | 283 // the home page. |
284 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 284 registrar_.Add(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
285 content::NotificationService::AllSources()); | 285 content::NotificationService::AllSources()); |
286 } | 286 } |
287 google_util::GetReactivationBrand(&reactivation_brand_); | 287 google_util::GetReactivationBrand(&reactivation_brand_); |
288 | 288 |
289 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); | 289 rlz_lib::SetURLRequestContext(g_browser_process->system_request_context()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
369 const string16& lang, | 369 const string16& lang, |
370 const string16& referral) { | 370 const string16& referral) { |
371 return ::SendFinancialPing(brand, lang, referral); | 371 return ::SendFinancialPing(brand, lang, referral); |
372 } | 372 } |
373 | 373 |
374 void RLZTracker::Observe(int type, | 374 void RLZTracker::Observe(int type, |
375 const content::NotificationSource& source, | 375 const content::NotificationSource& source, |
376 const content::NotificationDetails& details) { | 376 const content::NotificationDetails& details) { |
377 switch (type) { | 377 switch (type) { |
378 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: | 378 case chrome::NOTIFICATION_OMNIBOX_OPENED_URL: |
379 case chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED: | 379 case chrome::NOTIFICATION_INSTANT_UPDATED: |
380 RecordFirstSearch(CHROME_OMNIBOX); | 380 RecordFirstSearch(CHROME_OMNIBOX); |
381 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, | 381 registrar_.Remove(this, chrome::NOTIFICATION_OMNIBOX_OPENED_URL, |
382 content::NotificationService::AllSources()); | 382 content::NotificationService::AllSources()); |
383 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_CONTROLLER_UPDATED, | 383 registrar_.Remove(this, chrome::NOTIFICATION_INSTANT_UPDATED, |
384 content::NotificationService::AllSources()); | 384 content::NotificationService::AllSources()); |
385 break; | 385 break; |
386 case content::NOTIFICATION_NAV_ENTRY_PENDING: { | 386 case content::NOTIFICATION_NAV_ENTRY_PENDING: { |
387 const NavigationEntry* entry = | 387 const NavigationEntry* entry = |
388 content::Details<content::NavigationEntry>(details).ptr(); | 388 content::Details<content::NavigationEntry>(details).ptr(); |
389 if (entry != NULL && | 389 if (entry != NULL && |
390 ((entry->GetTransitionType() & | 390 ((entry->GetTransitionType() & |
391 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { | 391 content::PAGE_TRANSITION_HOME_PAGE) != 0)) { |
392 RecordFirstSearch(CHROME_HOME_PAGE); | 392 RecordFirstSearch(CHROME_HOME_PAGE); |
393 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, | 393 registrar_.Remove(this, content::NOTIFICATION_NAV_ENTRY_PENDING, |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 // static | 567 // static |
568 void RLZTracker::CleanupRlz() { | 568 void RLZTracker::CleanupRlz() { |
569 GetInstance()->rlz_cache_.clear(); | 569 GetInstance()->rlz_cache_.clear(); |
570 GetInstance()->registrar_.RemoveAll(); | 570 GetInstance()->registrar_.RemoveAll(); |
571 } | 571 } |
572 | 572 |
573 // static | 573 // static |
574 void RLZTracker::EnableZeroDelayForTesting() { | 574 void RLZTracker::EnableZeroDelayForTesting() { |
575 GetInstance()->min_init_delay_ = base::TimeDelta(); | 575 GetInstance()->min_init_delay_ = base::TimeDelta(); |
576 } | 576 } |
OLD | NEW |