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 29 matching lines...) Expand all Loading... |
40 // functions on non-Win platforms. | 40 // functions on non-Win platforms. |
41 static bool GetReferral(string16* referral) { | 41 static bool GetReferral(string16* referral) { |
42 return true; | 42 return true; |
43 } | 43 } |
44 static bool ClearReferral() { | 44 static bool ClearReferral() { |
45 return true; | 45 return true; |
46 } | 46 } |
47 } // namespace GoogleUpdateSettings | 47 } // namespace GoogleUpdateSettings |
48 #endif | 48 #endif |
49 | 49 |
50 // There is no corresponding header for content/browser/browser_main_runner.cc | |
51 // to export this global but it is used in other places as well (also defined | |
52 // as "extern"). | |
53 extern bool g_exited_main_message_loop; | |
54 | |
55 using content::BrowserThread; | 50 using content::BrowserThread; |
56 using content::NavigationEntry; | 51 using content::NavigationEntry; |
57 | 52 |
58 namespace { | 53 namespace { |
59 | 54 |
60 bool IsBrandOrganic(const std::string& brand) { | 55 bool IsBrandOrganic(const std::string& brand) { |
61 return brand.empty() || google_util::IsOrganic(brand); | 56 return brand.empty() || google_util::IsOrganic(brand); |
62 } | 57 } |
63 | 58 |
64 void RecordProductEvents(bool first_run, | 59 void RecordProductEvents(bool first_run, |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 if (homepage_used || is_google_in_startpages) { | 116 if (homepage_used || is_google_in_startpages) { |
122 rlz_lib::RecordProductEvent(rlz_lib::CHROME, | 117 rlz_lib::RecordProductEvent(rlz_lib::CHROME, |
123 RLZTracker::CHROME_HOME_PAGE, | 118 RLZTracker::CHROME_HOME_PAGE, |
124 rlz_lib::FIRST_SEARCH); | 119 rlz_lib::FIRST_SEARCH); |
125 } | 120 } |
126 } | 121 } |
127 | 122 |
128 bool SendFinancialPing(const std::string& brand, | 123 bool SendFinancialPing(const std::string& brand, |
129 const string16& lang, | 124 const string16& lang, |
130 const string16& referral) { | 125 const string16& referral) { |
131 // It's possible for the user to close Chrome just before the time that this | |
132 // ping is due to go out. Detect that condition and abort. | |
133 if (g_exited_main_message_loop) | |
134 return false; | |
135 | |
136 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, | 126 rlz_lib::AccessPoint points[] = {RLZTracker::CHROME_OMNIBOX, |
137 RLZTracker::CHROME_HOME_PAGE, | 127 RLZTracker::CHROME_HOME_PAGE, |
138 rlz_lib::NO_ACCESS_POINT}; | 128 rlz_lib::NO_ACCESS_POINT}; |
139 std::string lang_ascii(UTF16ToASCII(lang)); | 129 std::string lang_ascii(UTF16ToASCII(lang)); |
140 std::string referral_ascii(UTF16ToASCII(referral)); | 130 std::string referral_ascii(UTF16ToASCII(referral)); |
141 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", | 131 return rlz_lib::SendFinancialPing(rlz_lib::CHROME, points, "chrome", |
142 brand.c_str(), referral_ascii.c_str(), | 132 brand.c_str(), referral_ascii.c_str(), |
143 lang_ascii.c_str(), false, true); | 133 lang_ascii.c_str(), false, true); |
144 } | 134 } |
145 | 135 |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
508 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, | 498 base::Bind(base::IgnoreResult(&RLZTracker::GetAccessPointRlz), point, |
509 not_used)); | 499 not_used)); |
510 return true; | 500 return true; |
511 } | 501 } |
512 | 502 |
513 // static | 503 // static |
514 void RLZTracker::CleanupRlz() { | 504 void RLZTracker::CleanupRlz() { |
515 GetInstance()->rlz_cache_.clear(); | 505 GetInstance()->rlz_cache_.clear(); |
516 GetInstance()->registrar_.RemoveAll(); | 506 GetInstance()->registrar_.RemoveAll(); |
517 } | 507 } |
OLD | NEW |