| 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 #include "chrome/browser/rlz/rlz.h" | 5 #include "chrome/browser/rlz/rlz.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "base/time/time.h" | 9 #include "base/time/time.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 10 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 | 99 |
| 100 bool was_ping_sent_for_brand(const std::string& brand) const { | 100 bool was_ping_sent_for_brand(const std::string& brand) const { |
| 101 return pinged_brands_.count(brand) > 0; | 101 return pinged_brands_.count(brand) > 0; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void set_assume_not_ui_thread(bool assume_not_ui_thread) { | 104 void set_assume_not_ui_thread(bool assume_not_ui_thread) { |
| 105 assume_not_ui_thread_ = assume_not_ui_thread; | 105 assume_not_ui_thread_ = assume_not_ui_thread; |
| 106 } | 106 } |
| 107 | 107 |
| 108 private: | 108 private: |
| 109 virtual void ScheduleDelayedInit(base::TimeDelta delay) OVERRIDE { | 109 virtual void ScheduleDelayedInit(base::TimeDelta delay) override { |
| 110 // If the delay is 0, invoke the delayed init now. Otherwise, | 110 // If the delay is 0, invoke the delayed init now. Otherwise, |
| 111 // don't schedule anything, it will be manually called during tests. | 111 // don't schedule anything, it will be manually called during tests. |
| 112 if (delay == base::TimeDelta()) | 112 if (delay == base::TimeDelta()) |
| 113 DelayedInit(); | 113 DelayedInit(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual void ScheduleFinancialPing() OVERRIDE { | 116 virtual void ScheduleFinancialPing() override { |
| 117 PingNowImpl(); | 117 PingNowImpl(); |
| 118 } | 118 } |
| 119 | 119 |
| 120 virtual bool ScheduleRecordProductEvent(rlz_lib::Product product, | 120 virtual bool ScheduleRecordProductEvent(rlz_lib::Product product, |
| 121 rlz_lib::AccessPoint point, | 121 rlz_lib::AccessPoint point, |
| 122 rlz_lib::Event event_id) OVERRIDE { | 122 rlz_lib::Event event_id) override { |
| 123 return !assume_not_ui_thread_; | 123 return !assume_not_ui_thread_; |
| 124 } | 124 } |
| 125 | 125 |
| 126 virtual bool ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) OVERRIDE { | 126 virtual bool ScheduleGetAccessPointRlz(rlz_lib::AccessPoint point) override { |
| 127 return !assume_not_ui_thread_; | 127 return !assume_not_ui_thread_; |
| 128 } | 128 } |
| 129 | 129 |
| 130 virtual bool ScheduleRecordFirstSearch(rlz_lib::AccessPoint point) OVERRIDE { | 130 virtual bool ScheduleRecordFirstSearch(rlz_lib::AccessPoint point) override { |
| 131 return !assume_not_ui_thread_; | 131 return !assume_not_ui_thread_; |
| 132 } | 132 } |
| 133 | 133 |
| 134 #if defined(OS_CHROMEOS) | 134 #if defined(OS_CHROMEOS) |
| 135 virtual bool ScheduleClearRlzState() OVERRIDE { | 135 virtual bool ScheduleClearRlzState() override { |
| 136 return !assume_not_ui_thread_; | 136 return !assume_not_ui_thread_; |
| 137 } | 137 } |
| 138 #endif | 138 #endif |
| 139 | 139 |
| 140 virtual bool SendFinancialPing(const std::string& brand, | 140 virtual bool SendFinancialPing(const std::string& brand, |
| 141 const base::string16& lang, | 141 const base::string16& lang, |
| 142 const base::string16& referral) OVERRIDE { | 142 const base::string16& referral) override { |
| 143 // Don't ping the server during tests, just pretend as if we did. | 143 // Don't ping the server during tests, just pretend as if we did. |
| 144 EXPECT_FALSE(brand.empty()); | 144 EXPECT_FALSE(brand.empty()); |
| 145 pinged_brands_.insert(brand); | 145 pinged_brands_.insert(brand); |
| 146 | 146 |
| 147 // Set new access points RLZ string, like the actual server ping would have | 147 // Set new access points RLZ string, like the actual server ping would have |
| 148 // done. | 148 // done. |
| 149 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeOmnibox(), | 149 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeOmnibox(), |
| 150 kNewOmniboxRlzString); | 150 kNewOmniboxRlzString); |
| 151 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeHomePage(), | 151 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeHomePage(), |
| 152 kNewHomepageRlzString); | 152 kNewHomepageRlzString); |
| 153 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeAppList(), | 153 rlz_lib::SetAccessPointRlz(RLZTracker::ChromeAppList(), |
| 154 kNewAppListRlzString); | 154 kNewAppListRlzString); |
| 155 return true; | 155 return true; |
| 156 } | 156 } |
| 157 | 157 |
| 158 std::set<std::string> pinged_brands_; | 158 std::set<std::string> pinged_brands_; |
| 159 bool assume_not_ui_thread_; | 159 bool assume_not_ui_thread_; |
| 160 | 160 |
| 161 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); | 161 DISALLOW_COPY_AND_ASSIGN(TestRLZTracker); |
| 162 }; | 162 }; |
| 163 | 163 |
| 164 class RlzLibTest : public RlzLibTestNoMachineState { | 164 class RlzLibTest : public RlzLibTestNoMachineState { |
| 165 protected: | 165 protected: |
| 166 virtual void SetUp() OVERRIDE; | 166 virtual void SetUp() override; |
| 167 | 167 |
| 168 void SetMainBrand(const char* brand); | 168 void SetMainBrand(const char* brand); |
| 169 void SetReactivationBrand(const char* brand); | 169 void SetReactivationBrand(const char* brand); |
| 170 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
| 171 void SetRegistryBrandValue(const wchar_t* name, const char* brand); | 171 void SetRegistryBrandValue(const wchar_t* name, const char* brand); |
| 172 #endif | 172 #endif |
| 173 | 173 |
| 174 void SimulateOmniboxUsage(); | 174 void SimulateOmniboxUsage(); |
| 175 void SimulateHomepageUsage(); | 175 void SimulateHomepageUsage(); |
| 176 void SimulateAppListUsage(); | 176 void SimulateAppListUsage(); |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 887 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::ChromeOmnibox(), | 887 RLZTracker::RecordProductEvent(rlz_lib::CHROME, RLZTracker::ChromeOmnibox(), |
| 888 rlz_lib::FIRST_SEARCH); | 888 rlz_lib::FIRST_SEARCH); |
| 889 | 889 |
| 890 ExpectEventRecorded(kOmniboxFirstSearch, true); | 890 ExpectEventRecorded(kOmniboxFirstSearch, true); |
| 891 | 891 |
| 892 RLZTracker::ClearRlzState(); | 892 RLZTracker::ClearRlzState(); |
| 893 | 893 |
| 894 ExpectEventRecorded(kOmniboxFirstSearch, false); | 894 ExpectEventRecorded(kOmniboxFirstSearch, false); |
| 895 } | 895 } |
| 896 #endif // defined(OS_CHROMEOS) | 896 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |