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.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/sync/profile_sync_service.h" | 10 #include "chrome/browser/sync/profile_sync_service.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { | 128 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { |
129 if (accepted) { | 129 if (accepted) { |
130 StartObservingSync(); | 130 StartObservingSync(); |
131 LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(true); | 131 LoginUIServiceFactory::GetForProfile(profile_)->ShowLoginUI(true); |
132 } else { | 132 } else { |
133 delegate_->OnSyncSetupResult(false); | 133 delegate_->OnSyncSetupResult(false); |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 void AppNotifyChannelUIImpl::OnStateChanged() { | 137 void AppNotifyChannelUIImpl::OnStateChanged() { |
| 138 #if !defined(OS_ANDROID) |
138 ProfileSyncService* sync_service = | 139 ProfileSyncService* sync_service = |
139 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 140 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
140 LoginUIService* login_service = | 141 LoginUIService* login_service = |
141 LoginUIServiceFactory::GetForProfile(profile_); | 142 LoginUIServiceFactory::GetForProfile(profile_); |
142 | 143 |
143 bool wizard_visible = (login_service->current_login_ui() != NULL); | 144 bool wizard_visible = (login_service->current_login_ui() != NULL); |
144 // ProfileSyncService raises OnStateChanged many times. Even multiple | 145 // ProfileSyncService raises OnStateChanged many times. Even multiple |
145 // times before the wizard actually becomes visible for the first time. | 146 // times before the wizard actually becomes visible for the first time. |
146 // So we have to wait for the wizard to become visible once and then we | 147 // So we have to wait for the wizard to become visible once and then we |
147 // wait for it to get dismissed. | 148 // wait for it to get dismissed. |
148 bool finished = wizard_shown_to_user_ && !wizard_visible; | 149 bool finished = wizard_shown_to_user_ && !wizard_visible; |
149 if (wizard_visible) | 150 if (wizard_visible) |
150 wizard_shown_to_user_ = true; | 151 wizard_shown_to_user_ = true; |
151 | 152 |
152 if (finished) { | 153 if (finished) { |
153 StopObservingSync(); | 154 StopObservingSync(); |
154 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); | 155 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); |
155 } | 156 } |
| 157 #endif // !defined(OS_ANDROID) |
156 } | 158 } |
157 | 159 |
158 void AppNotifyChannelUIImpl::StartObservingSync() { | 160 void AppNotifyChannelUIImpl::StartObservingSync() { |
159 CHECK(!observing_sync_); | 161 CHECK(!observing_sync_); |
160 observing_sync_ = true; | 162 observing_sync_ = true; |
161 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 163 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
162 profile_)->AddObserver(this); | 164 profile_)->AddObserver(this); |
163 } | 165 } |
164 | 166 |
165 void AppNotifyChannelUIImpl::StopObservingSync() { | 167 void AppNotifyChannelUIImpl::StopObservingSync() { |
166 CHECK(observing_sync_); | 168 CHECK(observing_sync_); |
167 observing_sync_ = false; | 169 observing_sync_ = false; |
168 ProfileSyncServiceFactory::GetInstance()->GetForProfile( | 170 ProfileSyncServiceFactory::GetInstance()->GetForProfile( |
169 profile_)->RemoveObserver(this); | 171 profile_)->RemoveObserver(this); |
170 } | 172 } |
OLD | NEW |