Commit 2c40e1bb authored by munjal@chromium.org's avatar munjal@chromium.org

Fix the following issue in app notify login flow:

If the user is already logged in pre M17 and user sets
up notifications, the user will be asked to sign in.
AppNOtifyChannelUI::OnStateChanged is called more than
once before the oauth2 token is generated.

Fix it by:
Remembering if the wizard ever became visible instead of
whether the callback happened once.
Review URL: http://codereview.chromium.org/8787013

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112953 0039d316-1c4b-4281-b951-d872f2087c98
parent 34c6ef8c
...@@ -87,7 +87,7 @@ AppNotifyChannelUIImpl::AppNotifyChannelUIImpl(Browser* browser, ...@@ -87,7 +87,7 @@ AppNotifyChannelUIImpl::AppNotifyChannelUIImpl(Browser* browser,
TabContentsWrapper* wrapper, TabContentsWrapper* wrapper,
const std::string& app_name) const std::string& app_name)
: browser_(browser), wrapper_(wrapper), app_name_(app_name), : browser_(browser), wrapper_(wrapper), app_name_(app_name),
delegate_(NULL), observing_sync_(false), got_first_sync_callback_(false) { delegate_(NULL), observing_sync_(false), wizard_shown_to_user_(false) {
} }
AppNotifyChannelUIImpl::~AppNotifyChannelUIImpl() { AppNotifyChannelUIImpl::~AppNotifyChannelUIImpl() {
...@@ -125,8 +125,14 @@ void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { ...@@ -125,8 +125,14 @@ void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) {
void AppNotifyChannelUIImpl::OnStateChanged() { void AppNotifyChannelUIImpl::OnStateChanged() {
ProfileSyncService* sync_service = ProfileSyncService* sync_service =
browser_->profile()->GetProfileSyncService(); browser_->profile()->GetProfileSyncService();
bool finished = got_first_sync_callback_ && !sync_service->SetupInProgress(); bool wizard_visible = sync_service->WizardIsVisible();
got_first_sync_callback_ = true; // ProfileSyncService raises OnStateChanged many times. Even multiple
// times before the wizard actually becomes visible for the first time.
// So we have to wait for the wizard to become visible once and then we
// wait for it to get dismissed.
bool finished = wizard_shown_to_user_ && !wizard_visible;
if (wizard_visible)
wizard_shown_to_user_ = true;
if (finished) { if (finished) {
StopObservingSync(); StopObservingSync();
......
...@@ -68,10 +68,13 @@ class AppNotifyChannelUIImpl : public AppNotifyChannelUI, ...@@ -68,10 +68,13 @@ class AppNotifyChannelUIImpl : public AppNotifyChannelUI,
// Have we registered ourself as a ProfileSyncServiceObserver? // Have we registered ourself as a ProfileSyncServiceObserver?
bool observing_sync_; bool observing_sync_;
// This is for working around a bug where the first ProfileSyncServiceObserver // This is for working around a bug that ProfileSyncService calls
// callback after starting the sync login process erroneously reports // ProfileSyncServiceObserver::OnStateChanged callback many times
// SetupInProgress as false. See crbug.com/101842. // after ShowLoginDialog is called and before the wizard is
bool got_first_sync_callback_; // actually visible to the user. So we record if the wizard was
// shown to user and then wait for wizard to get dismissed.
// See crbug.com/101842.
bool wizard_shown_to_user_;
DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl); DISALLOW_COPY_AND_ASSIGN(AppNotifyChannelUIImpl);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment