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_setup_handler.h" | 5 #include "chrome/browser/ui/webui/sync_setup_handler.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 1184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 void SyncSetupHandler::DidStopLoading( | 1195 void SyncSetupHandler::DidStopLoading( |
1196 content::RenderViewHost* render_view_host) { | 1196 content::RenderViewHost* render_view_host) { |
1197 DCHECK(active_gaia_signin_tab_); | 1197 DCHECK(active_gaia_signin_tab_); |
1198 | 1198 |
1199 // If the user lands on a page outside of Gaia, assume they have navigated | 1199 // If the user lands on a page outside of Gaia, assume they have navigated |
1200 // away and are no longer thinking about signing in with this tab. Treat | 1200 // away and are no longer thinking about signing in with this tab. Treat |
1201 // this as if the user closed the tab. However, don't actually close the tab | 1201 // this as if the user closed the tab. However, don't actually close the tab |
1202 // since the user is doing something with it. Disconnect and forget about it | 1202 // since the user is doing something with it. Disconnect and forget about it |
1203 // before closing down the sync setup. | 1203 // before closing down the sync setup. |
1204 // The one exception is the expected continue URL. If the user lands there, | 1204 // The one exception is the expected continue URL. If the user lands there, |
1205 // this means sign in was successful. | 1205 // this means sign in was successful. Ignore the source parameter in the |
| 1206 // continue URL since this user may have changed the state of the |
| 1207 // "Let me choose what to sync" checkbox. |
1206 const GURL& url = active_gaia_signin_tab_->GetURL(); | 1208 const GURL& url = active_gaia_signin_tab_->GetURL(); |
1207 const GURL continue_url = | 1209 const GURL continue_url = |
1208 SyncPromoUI::GetNextPageURLForSyncPromoURL( | 1210 SyncPromoUI::GetNextPageURLForSyncPromoURL( |
1209 SyncPromoUI::GetSyncPromoURL(GURL(), | 1211 SyncPromoUI::GetSyncPromoURL(GURL(), |
1210 SyncPromoUI::SOURCE_SETTINGS, | 1212 SyncPromoUI::SOURCE_SETTINGS, |
1211 false)); | 1213 false)); |
| 1214 GURL::Replacements replacements; |
| 1215 replacements.ClearQuery(); |
1212 | 1216 |
1213 if (url != continue_url && !gaia::IsGaiaSignonRealm(url.GetOrigin())) { | 1217 if (!gaia::IsGaiaSignonRealm(url.GetOrigin()) && |
| 1218 url.ReplaceComponents(replacements) != |
| 1219 continue_url.ReplaceComponents(replacements)) { |
1214 content::WebContentsObserver::Observe(NULL); | 1220 content::WebContentsObserver::Observe(NULL); |
1215 active_gaia_signin_tab_ = NULL; | 1221 active_gaia_signin_tab_ = NULL; |
1216 CloseSyncSetup(); | 1222 CloseSyncSetup(); |
1217 } | 1223 } |
1218 } | 1224 } |
1219 | 1225 |
1220 void SyncSetupHandler::WebContentsDestroyed( | 1226 void SyncSetupHandler::WebContentsDestroyed( |
1221 content::WebContents* web_contents) { | 1227 content::WebContents* web_contents) { |
1222 DCHECK(active_gaia_signin_tab_); | 1228 DCHECK(active_gaia_signin_tab_); |
1223 CloseSyncSetup(); | 1229 CloseSyncSetup(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1295 if (i != current_profile_index && AreUserNamesEqual( | 1301 if (i != current_profile_index && AreUserNamesEqual( |
1296 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { | 1302 cache.GetUserNameOfProfileAtIndex(i), username_utf16)) { |
1297 *error_message = l10n_util::GetStringUTF16( | 1303 *error_message = l10n_util::GetStringUTF16( |
1298 IDS_SYNC_USER_NAME_IN_USE_ERROR); | 1304 IDS_SYNC_USER_NAME_IN_USE_ERROR); |
1299 return false; | 1305 return false; |
1300 } | 1306 } |
1301 } | 1307 } |
1302 | 1308 |
1303 return true; | 1309 return true; |
1304 } | 1310 } |
OLD | NEW |