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_handler2.h" | 5 #include "chrome/browser/ui/webui/sync_promo/sync_promo_handler2.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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 // confirming that they're signed in. | 198 // confirming that they're signed in. |
199 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); | 199 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); |
200 if (!username.empty()) | 200 if (!username.empty()) |
201 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | 201 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); |
202 | 202 |
203 // If the browser window is being closed then don't try to navigate to | 203 // If the browser window is being closed then don't try to navigate to |
204 // another URL. This prevents the browser window from flashing during | 204 // another URL. This prevents the browser window from flashing during |
205 // close. | 205 // close. |
206 Browser* browser = | 206 Browser* browser = |
207 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 207 BrowserList::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
208 if (browser && !browser->IsAttemptingToCloseBrowser()) { | 208 if (!browser || !browser->IsAttemptingToCloseBrowser()) { |
209 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( | 209 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( |
210 web_ui_->tab_contents()->GetURL()); | 210 web_ui_->tab_contents()->GetURL()); |
211 web_ui_->tab_contents()->OpenURL(url, GURL(), CURRENT_TAB, | 211 web_ui_->tab_contents()->OpenURL(url, GURL(), CURRENT_TAB, |
212 content::PAGE_TRANSITION_LINK); | 212 content::PAGE_TRANSITION_LINK); |
213 } | 213 } |
214 } | 214 } |
215 | 215 |
| 216 int SyncPromoHandler2::GetPromoVersion() { |
| 217 switch (SyncPromoUI::GetSyncPromoVersion()) { |
| 218 case SyncPromoUI::VERSION_DEFAULT: |
| 219 return 0; |
| 220 case SyncPromoUI::VERSION_DEVICES: |
| 221 return 1; |
| 222 case SyncPromoUI::VERSION_VERBOSE: |
| 223 return 2; |
| 224 case SyncPromoUI::VERSION_SIMPLE: |
| 225 return 3; |
| 226 case SyncPromoUI::VERSION_DIALOG: |
| 227 // Use the simple sync promo layout for the dialog version. |
| 228 return 3; |
| 229 default: |
| 230 NOTREACHED(); |
| 231 return 0; |
| 232 } |
| 233 } |
| 234 |
216 void SyncPromoHandler2::HandleInitializeSyncPromo(const base::ListValue* args) { | 235 void SyncPromoHandler2::HandleInitializeSyncPromo(const base::ListValue* args) { |
217 base::FundamentalValue version(SyncPromoUI::GetSyncPromoVersion()); | 236 base::FundamentalValue version(GetPromoVersion()); |
218 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", | 237 web_ui_->CallJavascriptFunction("SyncSetupOverlay.showPromoVersion", |
219 version); | 238 version); |
220 | 239 |
221 OpenSyncSetup(); | 240 OpenSyncSetup(); |
222 // We don't need to compute anything for this, just do this every time. | 241 // We don't need to compute anything for this, just do this every time. |
223 RecordUserFlowAction(SYNC_PROMO_VIEWED); | 242 RecordUserFlowAction(SYNC_PROMO_VIEWED); |
224 // Increment view count first and show natural numbers in stats rather than 0 | 243 // Increment view count first and show natural numbers in stats rather than 0 |
225 // based starting point (if it happened to be our first time showing this). | 244 // based starting point (if it happened to be our first time showing this). |
226 IncrementViewCountBy(1); | 245 IncrementViewCountBy(1); |
227 // Record +1 for every view. This is the only thing we record that's not part | 246 // Record +1 for every view. This is the only thing we record that's not part |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // static variables that won't work if the name changes on differnt calls. | 313 // static variables that won't work if the name changes on differnt calls. |
295 if (!histogram_name_.empty()) { | 314 if (!histogram_name_.empty()) { |
296 base::Histogram* histogram = base::LinearHistogram::FactoryGet( | 315 base::Histogram* histogram = base::LinearHistogram::FactoryGet( |
297 histogram_name_, 1, SYNC_PROMO_BUCKET_BOUNDARY, | 316 histogram_name_, 1, SYNC_PROMO_BUCKET_BOUNDARY, |
298 SYNC_PROMO_BUCKET_BOUNDARY + 1, base::Histogram::kNoFlags); | 317 SYNC_PROMO_BUCKET_BOUNDARY + 1, base::Histogram::kNoFlags); |
299 histogram->Add(action); | 318 histogram->Add(action); |
300 } | 319 } |
301 } | 320 } |
302 | 321 |
303 } // namespace options2 | 322 } // namespace options2 |
OLD | NEW |