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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
44 // functions on non-Win platforms. | 44 // functions on non-Win platforms. |
45 static bool GetReferral(string16* referral) { | 45 static bool GetReferral(string16* referral) { |
46 return true; | 46 return true; |
47 } | 47 } |
48 static bool ClearReferral() { | 48 static bool ClearReferral() { |
49 return true; | 49 return true; |
50 } | 50 } |
51 } // namespace GoogleUpdateSettings | 51 } // namespace GoogleUpdateSettings |
52 #endif | 52 #endif |
53 | 53 |
54 // There is no corresponding header for content/browser/browser_main_runner.cc | |
55 // to export this global but it is used in other places as well (also defined | |
56 // as "extern"). | |
57 extern bool g_exited_main_message_loop; | |
jam
2012/12/03 15:46:05
this is wrong. internal variables of content shoul
| |
58 | |
54 using content::BrowserThread; | 59 using content::BrowserThread; |
55 using content::NavigationEntry; | 60 using content::NavigationEntry; |
56 | 61 |
57 namespace { | 62 namespace { |
58 | 63 |
59 const char kRlzThreadName[] = "RLZ_thread"; | 64 const char kRlzThreadName[] = "RLZ_thread"; |
60 | 65 |
61 bool IsBrandOrganic(const std::string& brand) { | 66 bool IsBrandOrganic(const std::string& brand) { |
62 return brand.empty() || google_util::IsOrganic(brand); | 67 return brand.empty() || google_util::IsOrganic(brand); |
63 } | 68 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 if (homepage_used || is_google_in_startpages) { | 127 if (homepage_used || is_google_in_startpages) { |
123 rlz_lib::RecordProductEvent(rlz_lib::CHROME, | 128 rlz_lib::RecordProductEvent(rlz_lib::CHROME, |
124 RLZTracker::CHROME_HOME_PAGE, | 129 RLZTracker::CHROME_HOME_PAGE, |
125 rlz_lib::FIRST_SEARCH); | 130 rlz_lib::FIRST_SEARCH); |
126 } | 131 } |
127 } | 132 } |
128 | 133 |
129 bool SendFinancialPing(const std::string& brand, | 134 bool SendFinancialPing(const std::string& brand, |
130 const string16& lang, | 135 const string16& lang, |
131 const string16& referral) { | 136 const string16& referral) { |
137 // It's possible for the user to close Chrome just before the time that this | |
138 // ping is due to go out. Detect that condition and abort. | |
139 if (g_exited_main_message_loop) | |
140 return false; | |
Glenn Wilson
2012/11/27 01:17:49
is SendFinancialPing the right depth for this? Sh
| |
141 | |
132 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, | 142 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, |
133 RLZTracker::CHROME_HOME_PAGE, | 143 RLZTracker::CHROME_HOME_PAGE, |
134 rlz_lib::NO_ACCESS_POINT}; | 144 rlz_lib::NO_ACCESS_POINT}; |
135 std::string lang_ascii(UTF16ToASCII(lang)); | 145 std::string lang_ascii(UTF16ToASCII(lang)); |
136 std::string referral_ascii(UTF16ToASCII(referral)); | 146 std::string referral_ascii(UTF16ToASCII(referral)); |
137 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", | 147 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", |
138 brand.c_str(), referral_ascii.c_str(), | 148 brand.c_str(), referral_ascii.c_str(), |
139 lang_ascii.c_str(), false, true); | 149 lang_ascii.c_str(), false, true); |
140 } | 150 } |
141 | 151 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
527 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, | 537 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, |
528 not_used)); | 538 not_used)); |
529 return true; | 539 return true; |
530 } | 540 } |
531 | 541 |
532 // static | 542 // static |
533 void RLZTracker::CleanupRlz() { | 543 void RLZTracker::CleanupRlz() { |
534 GetInstance()->rlz_cache_.clear(); | 544 GetInstance()->rlz_cache_.clear(); |
535 GetInstance()->registrar_.RemoveAll(); | 545 GetInstance()->registrar_.RemoveAll(); |
536 } | 546 } |
OLD | NEW |