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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
51 return true; | 51 return true; |
52 } | 52 } |
53 } // namespace GoogleUpdateSettings | 53 } // namespace GoogleUpdateSettings |
54 #endif | 54 #endif |
55 | 55 |
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 bool chrome_is_exiting = false; | |
62 | |
61 // Maximum and minimum delay for financial ping we would allow to be set through | 63 // 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. | 64 // master preferences. Somewhat arbitrary, may need to be adjusted in future. |
63 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); | 65 const base::TimeDelta kMaxInitDelay = base::TimeDelta::FromSeconds(200); |
64 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); | 66 const base::TimeDelta kMinInitDelay = base::TimeDelta::FromSeconds(20); |
65 | 67 |
66 bool IsGoogleUrl(const GURL& url) { | 68 bool IsGoogleUrl(const GURL& url) { |
67 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); | 69 return google_util::IsGoogleHomePageUrl(url.possibly_invalid_spec()); |
68 } | 70 } |
69 | 71 |
70 bool IsBrandOrganic(const std::string& brand) { | 72 bool IsBrandOrganic(const std::string& brand) { |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
131 if (homepage_used || is_google_in_startpages) { | 133 if (homepage_used || is_google_in_startpages) { |
132 rlz_lib::RecordProductEvent(rlz_lib::CHROME, | 134 rlz_lib::RecordProductEvent(rlz_lib::CHROME, |
133 RLZTracker::CHROME_HOME_PAGE, | 135 RLZTracker::CHROME_HOME_PAGE, |
134 rlz_lib::FIRST_SEARCH); | 136 rlz_lib::FIRST_SEARCH); |
135 } | 137 } |
136 } | 138 } |
137 | 139 |
138 bool SendFinancialPing(const std::string& brand, | 140 bool SendFinancialPing(const std::string& brand, |
139 const string16& lang, | 141 const string16& lang, |
140 const string16& referral) { | 142 const string16& referral) { |
143 // It's possible for the user to close Chrome just before the time that this | |
144 // ping is due to go out. Detect that condition and abort. | |
145 if (chrome_is_exiting) | |
146 return false; | |
147 | |
141 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, | 148 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, |
142 RLZTracker::CHROME_HOME_PAGE, | 149 RLZTracker::CHROME_HOME_PAGE, |
143 rlz_lib::NO_ACCESS_POINT}; | 150 rlz_lib::NO_ACCESS_POINT}; |
144 std::string lang_ascii(UTF16ToASCII(lang)); | 151 std::string lang_ascii(UTF16ToASCII(lang)); |
145 std::string referral_ascii(UTF16ToASCII(referral)); | 152 std::string referral_ascii(UTF16ToASCII(referral)); |
146 std::string product_signature; | 153 std::string product_signature; |
147 #if defined(OS_CHROMEOS) | 154 #if defined(OS_CHROMEOS) |
148 product_signature = "chromeos"; | 155 product_signature = "chromeos"; |
149 #else | 156 #else |
150 product_signature = "chrome"; | 157 product_signature = "chrome"; |
(...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
580 // static | 587 // static |
581 void RLZTracker::CleanupRlz() { | 588 void RLZTracker::CleanupRlz() { |
582 GetInstance()->rlz_cache_.clear(); | 589 GetInstance()->rlz_cache_.clear(); |
583 GetInstance()->registrar_.RemoveAll(); | 590 GetInstance()->registrar_.RemoveAll(); |
584 } | 591 } |
585 | 592 |
586 // static | 593 // static |
587 void RLZTracker::EnableZeroDelayForTesting() { | 594 void RLZTracker::EnableZeroDelayForTesting() { |
588 GetInstance()->min_init_delay_ = base::TimeDelta(); | 595 GetInstance()->min_init_delay_ = base::TimeDelta(); |
589 } | 596 } |
597 | |
598 // static | |
599 void RLZTracker::PostMainMessageLoopRun() { | |
600 chrome_is_exiting = true; | |
Roger Tawa OOO till Jul 10th
2013/04/29 16:56:45
Instead of a new global variable, I think we shoul
bcwhite
2013/04/29 19:21:34
The financial_ping code uses this value without ch
| |
601 } | |
OLD | NEW |