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

Side by Side Diff: chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc

Issue 12096060: browser: Start moving application_lifetime.h functions into chrome namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/printing/cloud_print/cloud_print_proxy_service.h" 5 #include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
6 6
7 #include <stack> 7 #include <stack>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 147
148 // TODO(sanjeevr): Get icon for this notification. crbug.com/132848. 148 // TODO(sanjeevr): Get icon for this notification. crbug.com/132848.
149 string16 title = l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT); 149 string16 title = l10n_util::GetStringUTF16(IDS_GOOGLE_CLOUD_PRINT);
150 string16 message = 150 string16 message =
151 l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_TOKEN_EXPIRED_MESSAGE, title); 151 l10n_util::GetStringFUTF16(IDS_CLOUD_PRINT_TOKEN_EXPIRED_MESSAGE, title);
152 token_expired_delegate_ = new TokenExpiredNotificationDelegate(this); 152 token_expired_delegate_ = new TokenExpiredNotificationDelegate(this);
153 DesktopNotificationService::AddNotification( 153 DesktopNotificationService::AddNotification(
154 GURL(), title, message, GURL(), string16(), 154 GURL(), title, message, GURL(), string16(),
155 token_expired_delegate_.get(), profile_); 155 token_expired_delegate_.get(), profile_);
156 // Keep the browser alive while we are showing the notification. 156 // Keep the browser alive while we are showing the notification.
157 browser::StartKeepAlive(); 157 chrome::StartKeepAlive();
158 return true; 158 return true;
159 } 159 }
160 160
161 void CloudPrintProxyService::OnTokenExpiredNotificationError() { 161 void CloudPrintProxyService::OnTokenExpiredNotificationError() {
162 TokenExpiredNotificationDone(false); 162 TokenExpiredNotificationDone(false);
163 } 163 }
164 164
165 void CloudPrintProxyService::OnTokenExpiredNotificationClosed(bool by_user) { 165 void CloudPrintProxyService::OnTokenExpiredNotificationClosed(bool by_user) {
166 TokenExpiredNotificationDone(false); 166 TokenExpiredNotificationDone(false);
167 } 167 }
168 168
169 void CloudPrintProxyService::OnTokenExpiredNotificationClick() { 169 void CloudPrintProxyService::OnTokenExpiredNotificationClick() {
170 TokenExpiredNotificationDone(true); 170 TokenExpiredNotificationDone(true);
171 // Clear the cached cloud print email pref so that the cloud print setup 171 // Clear the cached cloud print email pref so that the cloud print setup
172 // flow happens. 172 // flow happens.
173 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); 173 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string());
174 cloud_print_setup_handler_.reset(new CloudPrintSetupHandler(this)); 174 cloud_print_setup_handler_.reset(new CloudPrintSetupHandler(this));
175 CloudPrintSetupFlow::OpenDialog( 175 CloudPrintSetupFlow::OpenDialog(
176 profile_, cloud_print_setup_handler_->AsWeakPtr(), NULL); 176 profile_, cloud_print_setup_handler_->AsWeakPtr(), NULL);
177 } 177 }
178 178
179 void CloudPrintProxyService::TokenExpiredNotificationDone(bool keep_alive) { 179 void CloudPrintProxyService::TokenExpiredNotificationDone(bool keep_alive) {
180 if (token_expired_delegate_.get()) { 180 if (token_expired_delegate_.get()) {
181 g_browser_process->notification_ui_manager()->CancelById( 181 g_browser_process->notification_ui_manager()->CancelById(
182 token_expired_delegate_->id()); 182 token_expired_delegate_->id());
183 token_expired_delegate_ = NULL; 183 token_expired_delegate_ = NULL;
184 if (!keep_alive) 184 if (!keep_alive)
185 browser::EndKeepAlive(); 185 chrome::EndKeepAlive();
186 } 186 }
187 } 187 }
188 188
189 bool CloudPrintProxyService::ApplyCloudPrintConnectorPolicy() { 189 bool CloudPrintProxyService::ApplyCloudPrintConnectorPolicy() {
190 if (!profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) { 190 if (!profile_->GetPrefs()->GetBoolean(prefs::kCloudPrintProxyEnabled)) {
191 std::string email = 191 std::string email =
192 profile_->GetPrefs()->GetString(prefs::kCloudPrintEmail); 192 profile_->GetPrefs()->GetString(prefs::kCloudPrintEmail);
193 if (!email.empty()) { 193 if (!email.empty()) {
194 DisableForUser(); 194 DisableForUser();
195 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string()); 195 profile_->GetPrefs()->SetString(prefs::kCloudPrintEmail, std::string());
196 if (enforcing_connector_policy_) { 196 if (enforcing_connector_policy_) {
197 MessageLoop::current()->PostTask( 197 MessageLoop::current()->PostTask(
198 FROM_HERE, 198 FROM_HERE,
199 base::Bind(&CloudPrintProxyService::RefreshCloudPrintProxyStatus, 199 base::Bind(&CloudPrintProxyService::RefreshCloudPrintProxyStatus,
200 weak_factory_.GetWeakPtr())); 200 weak_factory_.GetWeakPtr()));
201 } 201 }
202 return false; 202 return false;
203 } else if (enforcing_connector_policy_) { 203 } else if (enforcing_connector_policy_) {
204 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 204 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
205 } 205 }
206 } 206 }
207 return true; 207 return true;
208 } 208 }
209 209
210 void CloudPrintProxyService::OnCloudPrintSetupClosed() { 210 void CloudPrintProxyService::OnCloudPrintSetupClosed() {
211 MessageLoop::current()->PostTask( 211 MessageLoop::current()->PostTask(FROM_HERE,
212 FROM_HERE, base::Bind(&browser::EndKeepAlive)); 212 base::Bind(&chrome::EndKeepAlive));
213 } 213 }
214 214
215 void CloudPrintProxyService::RefreshCloudPrintProxyStatus() { 215 void CloudPrintProxyService::RefreshCloudPrintProxyStatus() {
216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 216 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
217 ServiceProcessControl* process_control = GetServiceProcessControl(); 217 ServiceProcessControl* process_control = GetServiceProcessControl();
218 DCHECK(process_control->IsConnected()); 218 DCHECK(process_control->IsConnected());
219 ServiceProcessControl::CloudPrintProxyInfoHandler callback = 219 ServiceProcessControl::CloudPrintProxyInfoHandler callback =
220 base::Bind(&CloudPrintProxyService::ProxyInfoCallback, 220 base::Bind(&CloudPrintProxyService::ProxyInfoCallback,
221 base::Unretained(this)); 221 base::Unretained(this));
222 // GetCloudPrintProxyInfo takes ownership of callback. 222 // GetCloudPrintProxyInfo takes ownership of callback.
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 bool CloudPrintProxyService::InvokeServiceTask(const base::Closure& task) { 268 bool CloudPrintProxyService::InvokeServiceTask(const base::Closure& task) {
269 GetServiceProcessControl()->Launch(task, base::Closure()); 269 GetServiceProcessControl()->Launch(task, base::Closure());
270 return true; 270 return true;
271 } 271 }
272 272
273 ServiceProcessControl* CloudPrintProxyService::GetServiceProcessControl() { 273 ServiceProcessControl* CloudPrintProxyService::GetServiceProcessControl() {
274 return ServiceProcessControl::GetInstance(); 274 return ServiceProcessControl::GetInstance();
275 } 275 }
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime_win.cc ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698