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

Side by Side Diff: chrome/browser/extensions/app_notify_channel_ui_impl.cc

Issue 10700202: Add Android stub implementation for AppNotifyChannelUI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added a Create method to the interface Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 observing_sync_(false), 103 observing_sync_(false),
104 wizard_shown_to_user_(false) { 104 wizard_shown_to_user_(false) {
105 } 105 }
106 106
107 AppNotifyChannelUIImpl::~AppNotifyChannelUIImpl() { 107 AppNotifyChannelUIImpl::~AppNotifyChannelUIImpl() {
108 // We should have either not started observing sync, or already called 108 // We should have either not started observing sync, or already called
109 // StopObservingSync by this point. 109 // StopObservingSync by this point.
110 CHECK(!observing_sync_); 110 CHECK(!observing_sync_);
111 } 111 }
112 112
113 // static
114 AppNotifyChannelUI* AppNotifyChannelUI::Create(Profile* profile,
115 TabContents* tab_contents,
116 const std::string& app_name,
117 AppNotifyChannelUI::UIType ui_type) {
118 return new AppNotifyChannelUIImpl(profile, tab_contents, app_name, ui_type);
119 }
120
113 void AppNotifyChannelUIImpl::PromptSyncSetup( 121 void AppNotifyChannelUIImpl::PromptSyncSetup(
114 AppNotifyChannelUI::Delegate* delegate) { 122 AppNotifyChannelUI::Delegate* delegate) {
115 CHECK(delegate_ == NULL); 123 CHECK(delegate_ == NULL);
116 delegate_ = delegate; 124 delegate_ = delegate;
117 125
118 if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService( 126 if (!ProfileSyncServiceFactory::GetInstance()->HasProfileSyncService(
119 profile_)) { 127 profile_)) {
120 delegate_->OnSyncSetupResult(false); 128 delegate_->OnSyncSetupResult(false);
121 return; 129 return;
122 } 130 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 DCHECK(!login_ui_service->current_login_ui()); 165 DCHECK(!login_ui_service->current_login_ui());
158 } 166 }
159 } 167 }
160 // Any existing UI is now closed - display new login UI. 168 // Any existing UI is now closed - display new login UI.
161 Browser* browser = browser::FindBrowserWithWebContents( 169 Browser* browser = browser::FindBrowserWithWebContents(
162 tab_contents_->web_contents()); 170 tab_contents_->web_contents());
163 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupForceLoginSubPage); 171 chrome::ShowSettingsSubPage(browser, chrome::kSyncSetupForceLoginSubPage);
164 } 172 }
165 173
166 void AppNotifyChannelUIImpl::OnStateChanged() { 174 void AppNotifyChannelUIImpl::OnStateChanged() {
167 #if !defined(OS_ANDROID)
168 ProfileSyncService* sync_service = 175 ProfileSyncService* sync_service =
169 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 176 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
170 LoginUIService* login_service = 177 LoginUIService* login_service =
171 LoginUIServiceFactory::GetForProfile(profile_); 178 LoginUIServiceFactory::GetForProfile(profile_);
172 179
173 bool wizard_visible = (login_service->current_login_ui() != NULL); 180 bool wizard_visible = (login_service->current_login_ui() != NULL);
174 // ProfileSyncService raises OnStateChanged many times. Even multiple 181 // ProfileSyncService raises OnStateChanged many times. Even multiple
175 // times before the wizard actually becomes visible for the first time. 182 // 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 183 // So we have to wait for the wizard to become visible once and then we
177 // wait for it to get dismissed. 184 // wait for it to get dismissed.
178 bool finished = wizard_shown_to_user_ && !wizard_visible; 185 bool finished = wizard_shown_to_user_ && !wizard_visible;
179 if (wizard_visible) 186 if (wizard_visible)
180 wizard_shown_to_user_ = true; 187 wizard_shown_to_user_ = true;
181 188
182 if (finished) { 189 if (finished) {
183 StopObservingSync(); 190 StopObservingSync();
184 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); 191 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted());
185 } 192 }
186 #endif // !defined(OS_ANDROID)
187 } 193 }
188 194
189 void AppNotifyChannelUIImpl::StartObservingSync() { 195 void AppNotifyChannelUIImpl::StartObservingSync() {
190 CHECK(!observing_sync_); 196 CHECK(!observing_sync_);
191 observing_sync_ = true; 197 observing_sync_ = true;
192 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 198 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
193 profile_)->AddObserver(this); 199 profile_)->AddObserver(this);
194 } 200 }
195 201
196 void AppNotifyChannelUIImpl::StopObservingSync() { 202 void AppNotifyChannelUIImpl::StopObservingSync() {
197 CHECK(observing_sync_); 203 CHECK(observing_sync_);
198 observing_sync_ = false; 204 observing_sync_ = false;
199 ProfileSyncServiceFactory::GetInstance()->GetForProfile( 205 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
200 profile_)->RemoveObserver(this); 206 profile_)->RemoveObserver(this);
201 } 207 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/app_notify_channel_ui_impl.h ('k') | chrome/browser/extensions/extension_tab_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698