| 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/extensions/app_notify_channel_ui.h" | 5 #include "chrome/browser/extensions/app_notify_channel_ui_impl.h" |
| 6 | 6 |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/infobars/infobar_tab_helper.h" | 8 #include "chrome/browser/infobars/infobar_tab_helper.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/signin/signin_manager.h" | 10 #include "chrome/browser/signin/signin_manager.h" |
| 11 #include "chrome/browser/signin/signin_manager_factory.h" | 11 #include "chrome/browser/signin/signin_manager_factory.h" |
| 12 #include "chrome/browser/sync/profile_sync_service.h" | 12 #include "chrome/browser/sync/profile_sync_service.h" |
| 13 #include "chrome/browser/sync/profile_sync_service_factory.h" | 13 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" | 14 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" |
| 15 #include "chrome/browser/ui/browser.h" | 15 #include "chrome/browser/ui/browser.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 DCHECK(!login_ui_service->current_login_ui()); | 157 DCHECK(!login_ui_service->current_login_ui()); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 // Any existing UI is now closed - display new login UI. | 160 // Any existing UI is now closed - display new login UI. |
| 161 Browser* browser = browser::FindBrowserWithWebContents( | 161 Browser* browser = browser::FindBrowserWithWebContents( |
| 162 tab_contents_->web_contents()); | 162 tab_contents_->web_contents()); |
| 163 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupForceLoginSubPage); | 163 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupForceLoginSubPage); |
| 164 } | 164 } |
| 165 | 165 |
| 166 void AppNotifyChannelUIImpl::OnStateChanged() { | 166 void AppNotifyChannelUIImpl::OnStateChanged() { |
| 167 #if !defined(OS_ANDROID) | |
| 168 ProfileSyncService* sync_service = | 167 ProfileSyncService* sync_service = |
| 169 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 168 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
| 170 LoginUIService* login_service = | 169 LoginUIService* login_service = |
| 171 LoginUIServiceFactory::GetForProfile(profile_); | 170 LoginUIServiceFactory::GetForProfile(profile_); |
| 172 | 171 |
| 173 bool wizard_visible = (login_service->current_login_ui() != NULL); | 172 bool wizard_visible = (login_service->current_login_ui() != NULL); |
| 174 // ProfileSyncService raises OnStateChanged many times. Even multiple | 173 // ProfileSyncService raises OnStateChanged many times. Even multiple |
| 175 // times before the wizard actually becomes visible for the first time. | 174 // times before the wizard actually becomes visible for the first time. |
| 176 // So we have to wait for the wizard to become visible once and then we | 175 // So we have to wait for the wizard to become visible once and then we |
| 177 // wait for it to get dismissed. | 176 // wait for it to get dismissed. |
| 178 bool finished = wizard_shown_to_user_ && !wizard_visible; | 177 bool finished = wizard_shown_to_user_ && !wizard_visible; |
| 179 if (wizard_visible) | 178 if (wizard_visible) |
| 180 wizard_shown_to_user_ = true; | 179 wizard_shown_to_user_ = true; |
| 181 | 180 |
| 182 if (finished) { | 181 if (finished) { |
| 183 StopObservingSync(); | 182 StopObservingSync(); |
| 184 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); | 183 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); |
| 185 } | 184 } |
| 186 #endif // !defined(OS_ANDROID) | |
| 187 } | 185 } |
| 188 | 186 |
| 189 void AppNotifyChannelUIImpl::StartObservingSync() { | 187 void AppNotifyChannelUIImpl::StartObservingSync() { |
| 190 CHECK(!observing_sync_); | 188 CHECK(!observing_sync_); |
| 191 observing_sync_ = true; | 189 observing_sync_ = true; |
| 192 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 190 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 193 profile_)->AddObserver(this); | 191 profile_)->AddObserver(this); |
| 194 } | 192 } |
| 195 | 193 |
| 196 void AppNotifyChannelUIImpl::StopObservingSync() { | 194 void AppNotifyChannelUIImpl::StopObservingSync() { |
| 197 CHECK(observing_sync_); | 195 CHECK(observing_sync_); |
| 198 observing_sync_ = false; | 196 observing_sync_ = false; |
| 199 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 197 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
| 200 profile_)->RemoveObserver(this); | 198 profile_)->RemoveObserver(this); |
| 201 } | 199 } |
| OLD | NEW |