Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1280)

Unified Diff: chrome/browser/ui/sync/one_click_signin_helper.cc

Issue 217883004: [Signin] Factor out a helper class to load a continue URL once Sync is configured. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Update a #include location Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/sync/one_click_signin_helper.cc
diff --git a/chrome/browser/ui/sync/one_click_signin_helper.cc b/chrome/browser/ui/sync/one_click_signin_helper.cc
index c3136ce33c7445fe64b346bcb878e874c6300155..d5bd95f528676d604205e3bd378cdbfebd6ee8ec 100644
--- a/chrome/browser/ui/sync/one_click_signin_helper.cc
+++ b/chrome/browser/ui/sync/one_click_signin_helper.cc
@@ -49,6 +49,7 @@
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/chrome_pages.h"
#include "chrome/browser/ui/sync/one_click_signin_histogram.h"
+#include "chrome/browser/ui/sync/one_click_signin_sync_observer.h"
#include "chrome/browser/ui/sync/one_click_signin_sync_starter.h"
#include "chrome/browser/ui/sync/signin_histogram.h"
#include "chrome/browser/ui/tab_modal_confirm_dialog.h"
@@ -484,12 +485,6 @@ void CurrentHistoryCleaner::WebContentsDestroyed(
delete this; // Failure.
}
-void CloseTab(content::WebContents* tab) {
- content::WebContentsDelegate* tab_delegate = tab->GetDelegate();
- if (tab_delegate)
- tab_delegate->CloseContents(tab);
-}
-
} // namespace
@@ -700,11 +695,7 @@ OneClickSigninHelper::OneClickSigninHelper(content::WebContents* web_contents,
}
}
-OneClickSigninHelper::~OneClickSigninHelper() {
- // WebContentsDestroyed() should always be called before the object is
- // deleted.
- DCHECK(!web_contents());
-}
+OneClickSigninHelper::~OneClickSigninHelper() {}
// static
void OneClickSigninHelper::LogHistogramValue(
@@ -1570,10 +1561,8 @@ void OneClickSigninHelper::DidStopLoading(
if (original_source == signin::SOURCE_SETTINGS ||
(original_source == signin::SOURCE_WEBSTORE_INSTALL &&
source_ == signin::SOURCE_SETTINGS)) {
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(profile);
- if (sync_service)
- sync_service->AddObserver(this);
+ // The observer deletes itself once it's done.
+ new OneClickSigninSyncObserver(contents, original_continue_url_);
}
break;
}
@@ -1589,60 +1578,6 @@ void OneClickSigninHelper::DidStopLoading(
CleanTransientState();
}
-// It is guaranteed that this method is called before the object is deleted.
-void OneClickSigninHelper::WebContentsDestroyed(
- content::WebContents* contents) {
- Profile* profile =
- Profile::FromBrowserContext(contents->GetBrowserContext());
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(profile);
- if (sync_service)
- sync_service->RemoveObserver(this);
-}
-
-void OneClickSigninHelper::OnStateChanged() {
- // We only add observer for ProfileSyncService when original_continue_url_ is
- // not empty.
- DCHECK(!original_continue_url_.is_empty());
-
- content::WebContents* contents = web_contents();
- Profile* profile =
- Profile::FromBrowserContext(contents->GetBrowserContext());
- ProfileSyncService* sync_service =
- ProfileSyncServiceFactory::GetForProfile(profile);
-
- // At this point, the sign in process is complete, and control has been handed
- // back to the sync engine. Close the gaia sign in tab if
- // |original_continue_url_| contains the |auto_close| parameter. Otherwise,
- // wait for sync setup to complete and then navigate to
- // |original_continue_url_|.
- if (signin::IsAutoCloseEnabledInURL(original_continue_url_)) {
- // Close the gaia sign in tab via a task to make sure we aren't in the
- // middle of any webui handler code.
- base::MessageLoop::current()->PostTask(
- FROM_HERE,
- base::Bind(&CloseTab, base::Unretained(contents)));
- } else {
- // Sync setup not completed yet.
- if (sync_service->FirstSetupInProgress())
- return;
-
- if (sync_service->sync_initialized() &&
- signin::GetSourceForPromoURL(original_continue_url_)
- != signin::SOURCE_SETTINGS) {
- contents->GetController().LoadURL(original_continue_url_,
- content::Referrer(),
- content::PAGE_TRANSITION_AUTO_TOPLEVEL,
- std::string());
- }
- }
-
- // Clears |original_continue_url_| here instead of in CleanTransientState,
- // because it is used in OnStateChanged which occurs later.
- original_continue_url_ = GURL();
- sync_service->RemoveObserver(this);
-}
-
OneClickSigninSyncStarter::Callback
OneClickSigninHelper::CreateSyncStarterCallback() {
// The callback will only be invoked if this object is still alive when sync
« no previous file with comments | « chrome/browser/ui/sync/one_click_signin_helper.h ('k') | chrome/browser/ui/sync/one_click_signin_helper_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698