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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 | 192 // If the browser window is being closed then don't try to navigate to |
193 // another URL. This prevents the browser window from flashing during | 193 // another URL. This prevents the browser window from flashing during |
194 // close. | 194 // close. |
195 Browser* browser = | 195 Browser* browser = |
196 browser::FindBrowserWithWebContents(web_ui()->GetWebContents()); | 196 chrome::FindBrowserWithWebContents(web_ui()->GetWebContents()); |
197 if (!browser || !browser->IsAttemptingToCloseBrowser()) { | 197 if (!browser || !browser->IsAttemptingToCloseBrowser()) { |
198 // Close the window if it was opened in auto-close mode. | 198 // Close the window if it was opened in auto-close mode. |
199 const GURL& sync_url = web_ui()->GetWebContents()->GetURL(); | 199 const GURL& sync_url = web_ui()->GetWebContents()->GetURL(); |
200 if (SyncPromoUI::GetAutoCloseForSyncPromoURL(sync_url)) { | 200 if (SyncPromoUI::GetAutoCloseForSyncPromoURL(sync_url)) { |
201 web_ui()->GetWebContents()->Close(); | 201 web_ui()->GetWebContents()->Close(); |
202 } else { | 202 } else { |
203 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL(sync_url); | 203 GURL url = SyncPromoUI::GetNextPageURLForSyncPromoURL(sync_url); |
204 OpenURLParams params( | 204 OpenURLParams params( |
205 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); | 205 url, Referrer(), CURRENT_TAB, content::PAGE_TRANSITION_LINK, false); |
206 web_ui()->GetWebContents()->OpenURL(params); | 206 web_ui()->GetWebContents()->OpenURL(params); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 // Send an enumeration to our single user flow histogram. | 280 // Send an enumeration to our single user flow histogram. |
281 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, | 281 UMA_HISTOGRAM_ENUMERATION("SyncPromo.UserFlow", action, |
282 SYNC_PROMO_BUCKET_BOUNDARY); | 282 SYNC_PROMO_BUCKET_BOUNDARY); |
283 } | 283 } |
284 | 284 |
285 void SyncPromoHandler::CloseUI() { | 285 void SyncPromoHandler::CloseUI() { |
286 // 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 |
287 // CloseUI() if the user is already logged in). | 287 // CloseUI() if the user is already logged in). |
288 NOTREACHED() << "Cannot close the promo UI"; | 288 NOTREACHED() << "Cannot close the promo UI"; |
289 } | 289 } |
OLD | NEW |