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

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

Issue 9169096: Remove a bunch of GetProfileSyncService callers to use the new factory. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rm todos Created 8 years, 11 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "chrome/browser/sync/profile_sync_service_factory.h"
11 #include "chrome/browser/sync/sync_setup_wizard.h" 12 #include "chrome/browser/sync/sync_setup_wizard.h"
12 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" 13 #include "chrome/browser/tab_contents/confirm_infobar_delegate.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 15 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
15 #include "content/public/browser/notification_details.h" 16 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
18 #include "content/public/browser/notification_source.h" 19 #include "content/public/browser/notification_source.h"
19 #include "content/public/browser/notification_service.h" 20 #include "content/public/browser/notification_service.h"
20 #include "content/public/browser/notification_types.h" 21 #include "content/public/browser/notification_types.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 109
109 InfoBarTabHelper* helper = wrapper_->infobar_tab_helper(); 110 InfoBarTabHelper* helper = wrapper_->infobar_tab_helper();
110 helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar( 111 helper->AddInfoBar(new AppNotifyChannelUIImpl::InfoBar(
111 this, helper, app_name_)); 112 this, helper, app_name_));
112 } 113 }
113 114
114 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) { 115 void AppNotifyChannelUIImpl::OnInfoBarResult(bool accepted) {
115 if (accepted) { 116 if (accepted) {
116 StartObservingSync(); 117 StartObservingSync();
117 ProfileSyncService* service = 118 ProfileSyncService* service =
118 browser_->profile()->GetOriginalProfile()->GetProfileSyncService(); 119 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
120 browser_->profile()->GetOriginalProfile());
119 service->ShowLoginDialog(); 121 service->ShowLoginDialog();
120 } else { 122 } else {
121 delegate_->OnSyncSetupResult(false); 123 delegate_->OnSyncSetupResult(false);
122 } 124 }
123 } 125 }
124 126
125 void AppNotifyChannelUIImpl::OnStateChanged() { 127 void AppNotifyChannelUIImpl::OnStateChanged() {
126 ProfileSyncService* sync_service = 128 ProfileSyncService* sync_service =
127 browser_->profile()->GetProfileSyncService(); 129 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
130 browser_->profile()->GetOriginalProfile());
128 bool wizard_visible = sync_service->WizardIsVisible(); 131 bool wizard_visible = sync_service->WizardIsVisible();
129 // ProfileSyncService raises OnStateChanged many times. Even multiple 132 // ProfileSyncService raises OnStateChanged many times. Even multiple
130 // times before the wizard actually becomes visible for the first time. 133 // times before the wizard actually becomes visible for the first time.
131 // So we have to wait for the wizard to become visible once and then we 134 // So we have to wait for the wizard to become visible once and then we
132 // wait for it to get dismissed. 135 // wait for it to get dismissed.
133 bool finished = wizard_shown_to_user_ && !wizard_visible; 136 bool finished = wizard_shown_to_user_ && !wizard_visible;
134 if (wizard_visible) 137 if (wizard_visible)
135 wizard_shown_to_user_ = true; 138 wizard_shown_to_user_ = true;
136 139
137 if (finished) { 140 if (finished) {
138 StopObservingSync(); 141 StopObservingSync();
139 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted()); 142 delegate_->OnSyncSetupResult(sync_service->HasSyncSetupCompleted());
140 } 143 }
141 } 144 }
142 145
143 void AppNotifyChannelUIImpl::StartObservingSync() { 146 void AppNotifyChannelUIImpl::StartObservingSync() {
144 CHECK(!observing_sync_); 147 CHECK(!observing_sync_);
145 observing_sync_ = true; 148 observing_sync_ = true;
146 browser_->profile()->GetProfileSyncService()->AddObserver(this); 149 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
150 browser_->profile()->GetOriginalProfile())->AddObserver(this);
147 } 151 }
148 152
149 void AppNotifyChannelUIImpl::StopObservingSync() { 153 void AppNotifyChannelUIImpl::StopObservingSync() {
150 CHECK(observing_sync_); 154 CHECK(observing_sync_);
151 observing_sync_ = false; 155 observing_sync_ = false;
152 browser_->profile()->GetProfileSyncService()->RemoveObserver(this); 156 ProfileSyncServiceFactory::GetInstance()->GetForProfile(
157 browser_->profile()->GetOriginalProfile())->RemoveObserver(this);
153 } 158 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/screen_locker.cc ('k') | chrome/browser/extensions/extension_webstore_private_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698