Chromium Code Reviews| 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/ui/webui/sync_promo/sync_promo_handler.h" | 5 #include "chrome/browser/ui/webui/sync_promo/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 "base/time.h" | 10 #include "base/time.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 194 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 194 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
| 195 if (!browser || !browser->IsAttemptingToCloseBrowser()) { | 195 if (!browser || !browser->IsAttemptingToCloseBrowser()) { |
| 196 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( | 196 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( |
| 197 web_ui()->GetWebContents()->GetURL()); | 197 web_ui()->GetWebContents()->GetURL()); |
| 198 OpenURLParams params( | 198 OpenURLParams params( |
| 199 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 199 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 200 web_ui()->GetWebContents()->OpenURL(params); | 200 web_ui()->GetWebContents()->OpenURL(params); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 | 203 |
| 204 int SyncPromoHandler::GetPromoVersion() { | |
| 205 switch (SyncPromoUI::GetSyncPromoVersion()) { | |
| 206 case SyncPromoUI::VERSION_DEFAULT: | |
| 207 return 0; | |
| 208 case SyncPromoUI::VERSION_DEVICES: | |
| 209 return 1; | |
| 210 case SyncPromoUI::VERSION_VERBOSE: | |
| 211 return 2; | |
| 212 case SyncPromoUI::VERSION_SIMPLE: | |
| 213 return 3; | |
| 214 case SyncPromoUI::VERSION_DIALOG: | |
| 215 // Use the simple sync promo layout for the dialog version. | |
| 216 return 3; | |
| 217 default: | |
| 218 NOTREACHED(); | |
| 219 return 0; | |
| 220 } | |
| 221 } | |
| 222 | |
| 223 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { | 204 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { |
| 224 base::FundamentalValue version(GetPromoVersion()); | 205 // TODO(sail): The version argument is going away, remove this. |
|
Dan Beam
2012/03/20 03:35:10
when is a better time to do this than now?
| |
| 206 base::FundamentalValue version(3); | |
| 225 web_ui()->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", | 207 web_ui()->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", |
| 226 version); | 208 version); |
| 227 | 209 |
| 228 // Open the sync wizard to the login screen. | 210 // Open the sync wizard to the login screen. |
| 229 OpenSyncSetup(true); | 211 OpenSyncSetup(true); |
| 230 // We don't need to compute anything for this, just do this every time. | 212 // We don't need to compute anything for this, just do this every time. |
| 231 RecordUserFlowAction(SYNC_PROMO_VIEWED); | 213 RecordUserFlowAction(SYNC_PROMO_VIEWED); |
| 232 // Increment view count first and show natural numbers in stats rather than 0 | 214 // Increment view count first and show natural numbers in stats rather than 0 |
| 233 // based starting point (if it happened to be our first time showing this). | 215 // based starting point (if it happened to be our first time showing this). |
| 234 IncrementViewCountBy(1); | 216 IncrementViewCountBy(1); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 // The following call does not use the standard UMA macro because the | 282 // The following call does not use the standard UMA macro because the |
| 301 // histogram name is only known at runtime. The standard macros declare | 283 // histogram name is only known at runtime. The standard macros declare |
| 302 // static variables that won't work if the name changes on differnt calls. | 284 // static variables that won't work if the name changes on differnt calls. |
| 303 if (!histogram_name_.empty()) { | 285 if (!histogram_name_.empty()) { |
| 304 base::Histogram* histogram = base::LinearHistogram::FactoryGet( | 286 base::Histogram* histogram = base::LinearHistogram::FactoryGet( |
| 305 histogram_name_, 1, SYNC_PROMO_BUCKET_BOUNDARY, | 287 histogram_name_, 1, SYNC_PROMO_BUCKET_BOUNDARY, |
| 306 SYNC_PROMO_BUCKET_BOUNDARY + 1, base::Histogram::kNoFlags); | 288 SYNC_PROMO_BUCKET_BOUNDARY + 1, base::Histogram::kNoFlags); |
| 307 histogram->Add(action); | 289 histogram->Add(action); |
| 308 } | 290 } |
| 309 } | 291 } |
| OLD | NEW |