OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/webui/sync_promo_handler.h" | 5 #include "chrome/browser/ui/webui/sync_promo_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 void SyncPromoHandler::ShowSetupUI() { | 118 void SyncPromoHandler::ShowSetupUI() { |
119 ProfileSyncService* service = | 119 ProfileSyncService* service = |
120 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); | 120 Profile::FromWebUI(web_ui_)->GetProfileSyncService(); |
121 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); | 121 service->get_wizard().Step(SyncSetupWizard::GetLoginState()); |
122 } | 122 } |
123 | 123 |
124 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { | 124 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { |
125 CloseSyncSetup(); | 125 CloseSyncSetup(); |
126 web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUINewTabURL), | 126 web_ui_->tab_contents()->OpenURL(GURL(chrome::kChromeUINewTabURL), |
127 GURL(), CURRENT_TAB, | 127 GURL(), CURRENT_TAB, |
128 PageTransition::LINK); | 128 content::PAGE_TRANSITION_LINK); |
129 } | 129 } |
130 | 130 |
131 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { | 131 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { |
132 OpenSyncSetup(); | 132 OpenSyncSetup(); |
133 // We don't need to compute anything for this, just do this every time. | 133 // We don't need to compute anything for this, just do this every time. |
134 RecordUserFlowAction(extension_misc::SYNC_PROMO_VIEWED); | 134 RecordUserFlowAction(extension_misc::SYNC_PROMO_VIEWED); |
135 // Increment view count first and show natural numbers in stats rather than 0 | 135 // Increment view count first and show natural numbers in stats rather than 0 |
136 // based starting point (if it happened to be our first time showing this). | 136 // based starting point (if it happened to be our first time showing this). |
137 IncrementViewCountBy(1); | 137 IncrementViewCountBy(1); |
138 // Record +1 for every view. This is the only thing we record that's not part | 138 // Record +1 for every view. This is the only thing we record that's not part |
139 // of the user flow histogram. | 139 // of the user flow histogram. |
140 UMA_HISTOGRAM_COUNTS("SyncPromo.NumTimesViewed", GetViewCount()); | 140 UMA_HISTOGRAM_COUNTS("SyncPromo.NumTimesViewed", GetViewCount()); |
141 } | 141 } |
142 | 142 |
143 void SyncPromoHandler::HandleShowAdvancedSettings( | 143 void SyncPromoHandler::HandleShowAdvancedSettings( |
144 const base::ListValue* args) { | 144 const base::ListValue* args) { |
145 CloseSyncSetup(); | 145 CloseSyncSetup(); |
146 std::string url(chrome::kChromeUISettingsURL); | 146 std::string url(chrome::kChromeUISettingsURL); |
147 url += chrome::kSyncSetupSubPage; | 147 url += chrome::kSyncSetupSubPage; |
148 web_ui_->tab_contents()->OpenURL(GURL(url), GURL(), CURRENT_TAB, | 148 web_ui_->tab_contents()->OpenURL(GURL(url), GURL(), CURRENT_TAB, |
149 PageTransition::LINK); | 149 content::PAGE_TRANSITION_LINK); |
150 } | 150 } |
151 | 151 |
152 void SyncPromoHandler::HandleUserFlowAction(const base::ListValue* args) { | 152 void SyncPromoHandler::HandleUserFlowAction(const base::ListValue* args) { |
153 double action_double; | 153 double action_double; |
154 CHECK(args->GetDouble(0, &action_double)); | 154 CHECK(args->GetDouble(0, &action_double)); |
155 int action = static_cast<int>(action_double); | 155 int action = static_cast<int>(action_double); |
156 if (action >= extension_misc::SYNC_PROMO_FIRST_VALID_JS_ACTION && | 156 if (action >= extension_misc::SYNC_PROMO_FIRST_VALID_JS_ACTION && |
157 action <= extension_misc::SYNC_PROMO_LAST_VALID_JS_ACTION) { | 157 action <= extension_misc::SYNC_PROMO_LAST_VALID_JS_ACTION) { |
158 RecordUserFlowAction(action); | 158 RecordUserFlowAction(action); |
159 } else { | 159 } else { |
(...skipping 15 matching lines...) Expand all Loading... |
175 int adjusted = GetViewCount() + amount; | 175 int adjusted = GetViewCount() + amount; |
176 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); | 176 prefs_->SetInteger(prefs::kSyncPromoViewCount, adjusted); |
177 return adjusted; | 177 return adjusted; |
178 } | 178 } |
179 | 179 |
180 void SyncPromoHandler::RecordUserFlowAction(int action) { | 180 void SyncPromoHandler::RecordUserFlowAction(int action) { |
181 // Send an enumeration to our single user flow histogram. | 181 // Send an enumeration to our single user flow histogram. |
182 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 182 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
183 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY); | 183 extension_misc::SYNC_PROMO_BUCKET_BOUNDARY); |
184 } | 184 } |
OLD | NEW |