| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 using content::BrowserThread; | 56 using content::BrowserThread; |
| 57 using content::NavigationEntry; | 57 using content::NavigationEntry; |
| 58 | 58 |
| 59 namespace { | 59 namespace { |
| 60 | 60 |
| 61 // Maximum and minimum delay for financial ping we would allow to be set through | 61 // Maximum and minimum delay for financial ping we would allow to be set through |
| 62 // master preferences. Somewhat arbitrary, may need to be adjusted in future. | 62 // master preferences. Somewhat arbitrary, may need to be adjusted in future. |
| 63 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); | 63 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); |
| 64 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); | 64 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); |
| 65 | 65 |
| 66 bool IsGoogleUrl(const GURL& url) { | |
| 67 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); | |
| 68 } | |
| 69 | |
| 70 bool IsBrandOrganic(const std::string& brand) { | 66 bool IsBrandOrganic(const std::string& brand) { |
| 71 return brand.empty() || google_util::IsOrganic(brand); | 67 return brand.empty() || google_util::IsOrganic(brand); |
| 72 } | 68 } |
| 73 | 69 |
| 74 void RecordProductEvents(bool first_run, | 70 void RecordProductEvents(bool first_run, |
| 75 bool is_google_default_search, | 71 bool is_google_default_search, |
| 76 bool is_google_homepage, | 72 bool is_google_homepage, |
| 77 bool is_google_in_startpages, | 73 bool is_google_in_startpages, |
| 78 bool already_ran, | 74 bool already_ran, |
| 79 bool omnibox_used, | 75 bool omnibox_used, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 TemplateURLServiceFactory::GetForProfile(profile); | 221 TemplateURLServiceFactory::GetForProfile(profile); |
| 226 if (template_url_service) { | 222 if (template_url_service) { |
| 227 const TemplateURL* url_template = | 223 const TemplateURL* url_template = |
| 228 template_url_service->GetDefaultSearchProvider(); | 224 template_url_service->GetDefaultSearchProvider(); |
| 229 is_google_default_search = | 225 is_google_default_search = |
| 230 url_template && url_template->url_ref().HasGoogleBaseURLs(); | 226 url_template && url_template->url_ref().HasGoogleBaseURLs(); |
| 231 } | 227 } |
| 232 | 228 |
| 233 PrefService* pref_service = profile->GetPrefs(); | 229 PrefService* pref_service = profile->GetPrefs(); |
| 234 bool is_google_homepage = google_util::IsGoogleHomePageUrl( | 230 bool is_google_homepage = google_util::IsGoogleHomePageUrl( |
| 235 pref_service->GetString(prefs::kHomePage)); | 231 GURL(pref_service->GetString(prefs::kHomePage))); |
| 236 | 232 |
| 237 bool is_google_in_startpages = false; | 233 bool is_google_in_startpages = false; |
| 238 SessionStartupPref session_startup_prefs = | 234 SessionStartupPref session_startup_prefs = |
| 239 StartupBrowserCreator::GetSessionStartupPref( | 235 StartupBrowserCreator::GetSessionStartupPref( |
| 240 *CommandLine::ForCurrentProcess(), profile); | 236 *CommandLine::ForCurrentProcess(), profile); |
| 241 if (session_startup_prefs.type == SessionStartupPref::URLS) { | 237 if (session_startup_prefs.type == SessionStartupPref::URLS) { |
| 242 is_google_in_startpages = std::count_if(session_startup_prefs.urls.begin(), | 238 is_google_in_startpages = |
| 243 session_startup_prefs.urls.end(), | 239 std::count_if(session_startup_prefs.urls.begin(), |
| 244 IsGoogleUrl) > 0; | 240 session_startup_prefs.urls.end(), |
| 241 google_util::IsGoogleHomePageUrl) > 0; |
| 245 } | 242 } |
| 246 | 243 |
| 247 if (!InitRlzDelayed(first_run, send_ping_immediately, delay, | 244 if (!InitRlzDelayed(first_run, send_ping_immediately, delay, |
| 248 is_google_default_search, is_google_homepage, | 245 is_google_default_search, is_google_homepage, |
| 249 is_google_in_startpages)) { | 246 is_google_in_startpages)) { |
| 250 return false; | 247 return false; |
| 251 } | 248 } |
| 252 | 249 |
| 253 // Prime the RLZ cache for the home page access point so that its avaiable | 250 // Prime the RLZ cache for the home page access point so that its avaiable |
| 254 // for the startup page if needed (i.e., when the startup page is set to | 251 // for the startup page if needed (i.e., when the startup page is set to |
| (...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 void RLZTracker::CleanupRlz() { | 578 void RLZTracker::CleanupRlz() { |
| 582 GetInstance()->rlz_cache_.clear(); | 579 GetInstance()->rlz_cache_.clear(); |
| 583 GetInstance()->registrar_.RemoveAll(); | 580 GetInstance()->registrar_.RemoveAll(); |
| 584 rlz_lib::SetURLRequestContext(NULL); | 581 rlz_lib::SetURLRequestContext(NULL); |
| 585 } | 582 } |
| 586 | 583 |
| 587 // static | 584 // static |
| 588 void RLZTracker::EnableZeroDelayForTesting() { | 585 void RLZTracker::EnableZeroDelayForTesting() { |
| 589 GetInstance()->min_init_delay_ = base::TimeDelta(); | 586 GetInstance()->min_init_delay_ = base::TimeDelta(); |
| 590 } | 587 } |
| OLD | NEW |