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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { | 183 void SyncPromoHandler::HandleCloseSyncPromo(const base::ListValue* args) { |
184 CloseSyncSetup(); | 184 CloseSyncSetup(); |
185 | 185 |
186 // If the user has signed in then set the pref to show them NTP bubble | 186 // If the user has signed in then set the pref to show them NTP bubble |
187 // confirming that they're signed in. | 187 // confirming that they're signed in. |
188 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); | 188 std::string username = prefs_->GetString(prefs::kGoogleServicesUsername); |
189 if (!username.empty()) | 189 if (!username.empty()) |
190 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); | 190 prefs_->SetBoolean(prefs::kSyncPromoShowNTPBubble, true); |
191 | 191 |
192 // If the browser window is being closed then don't try to navigate to another | 192 // If the browser window is being closed then don't try to navigate to |
193 // URL. This prevents the browser window from flashing during close. | 193 // another URL. This prevents the browser window from flashing during |
| 194 // close. |
194 Browser* browser = | 195 Browser* browser = |
195 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 196 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
196 if (!browser || !browser->IsAttemptingToCloseBrowser()) { | 197 if (!browser || !browser->IsAttemptingToCloseBrowser()) { |
197 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL( | 198 // Close the window if it was opened in auto-close mode. |
198 web_ui()->GetWebContents()->GetURL()); | 199 const GURL& sync_url = web_ui()->GetWebContents()->GetURL(); |
199 OpenURLParams params( | 200 if (SyncPromoUI::GetAutoCloseForSyncPromoURL(sync_url)) { |
200 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 201 web_ui()->GetWebContents()->Close(); |
201 web_ui()->GetWebContents()->OpenURL(params); | 202 } else { |
| 203 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL(sync_url); |
| 204 OpenURLParams params( |
| 205 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
| 206 web_ui()->GetWebContents()->OpenURL(params); |
| 207 } |
202 } | 208 } |
203 } | 209 } |
204 | 210 |
205 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { | 211 void SyncPromoHandler::HandleInitializeSyncPromo(const base::ListValue* args) { |
206 // Open the sync wizard to the login screen. | 212 // Open the sync wizard to the login screen. |
207 OpenSyncSetup(true); | 213 OpenSyncSetup(true); |
208 // We don't need to compute anything for this, just do this every time. | 214 // We don't need to compute anything for this, just do this every time. |
209 RecordUserFlowAction(SYNC_PROMO_VIEWED); | 215 RecordUserFlowAction(SYNC_PROMO_VIEWED); |
210 // Increment view count first and show natural numbers in stats rather than 0 | 216 // Increment view count first and show natural numbers in stats rather than 0 |
211 // based starting point (if it happened to be our first time showing this). | 217 // based starting point (if it happened to be our first time showing this). |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 // Send an enumeration to our single user flow histogram. | 280 // Send an enumeration to our single user flow histogram. |
275 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 281 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
276 SYNC_PROMO_BUCKET_BOUNDARY); | 282 SYNC_PROMO_BUCKET_BOUNDARY); |
277 } | 283 } |
278 | 284 |
279 void SyncPromoHandler::CloseUI() { | 285 void SyncPromoHandler::CloseUI() { |
280 // Callers should not ever try to close the promo UI (should only call | 286 // Callers should not ever try to close the promo UI (should only call |
281 // CloseUI() if the user is already logged in). | 287 // CloseUI() if the user is already logged in). |
282 NOTREACHED() << "Cannot close the promo UI"; | 288 NOTREACHED() << "Cannot close the promo UI"; |
283 } | 289 } |
OLD | NEW |