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

Side by Side Diff: chrome/service/cloud_print/cloud_print_proxy.cc

Issue 3257011: Registered the service process to AutoRun (for Windows) if any service (Cloud... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Fixed Linux compile Created 10 years, 3 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
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy.h ('k') | chrome/service/service_process.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/service/cloud_print/cloud_print_proxy.h" 5 #include "chrome/service/cloud_print/cloud_print_proxy.h"
6 6
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/common/pref_names.h" 8 #include "chrome/common/pref_names.h"
9 #include "chrome/common/json_pref_store.h" 9 #include "chrome/common/json_pref_store.h"
10 #include "chrome/service/cloud_print/cloud_print_consts.h" 10 #include "chrome/service/cloud_print/cloud_print_consts.h"
11 11
12 CloudPrintProxy::CloudPrintProxy() { 12 CloudPrintProxy::CloudPrintProxy() {
13 } 13 }
14 14
15 CloudPrintProxy::~CloudPrintProxy() { 15 CloudPrintProxy::~CloudPrintProxy() {
16 DCHECK(CalledOnValidThread()); 16 DCHECK(CalledOnValidThread());
17 Shutdown(); 17 Shutdown();
18 } 18 }
19 19
20 void CloudPrintProxy::Initialize(JsonPrefStore* service_prefs) { 20 void CloudPrintProxy::Initialize(JsonPrefStore* service_prefs, Client* client) {
21 DCHECK(CalledOnValidThread()); 21 DCHECK(CalledOnValidThread());
22 service_prefs_ = service_prefs; 22 service_prefs_ = service_prefs;
23 client_ = client;
23 } 24 }
24 25
25 void CloudPrintProxy::EnableForUser(const std::string& lsid) { 26 void CloudPrintProxy::EnableForUser(const std::string& lsid) {
26 DCHECK(CalledOnValidThread()); 27 DCHECK(CalledOnValidThread());
27 if (backend_.get()) 28 if (backend_.get())
28 return; 29 return;
29 30
30 std::string proxy_id; 31 std::string proxy_id;
31 service_prefs_->prefs()->GetString(prefs::kCloudPrintProxyId, &proxy_id); 32 service_prefs_->prefs()->GetString(prefs::kCloudPrintProxyId, &proxy_id);
32 if (proxy_id.empty()) { 33 if (proxy_id.empty()) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 service_prefs_->prefs()->GetString(prefs::kCloudPrintXMPPAuthToken, 66 service_prefs_->prefs()->GetString(prefs::kCloudPrintXMPPAuthToken,
66 &cloud_print_xmpp_token); 67 &cloud_print_xmpp_token);
67 DCHECK(!cloud_print_xmpp_token.empty()); 68 DCHECK(!cloud_print_xmpp_token.empty());
68 std::string cloud_print_email; 69 std::string cloud_print_email;
69 service_prefs_->prefs()->GetString(prefs::kCloudPrintEmail, 70 service_prefs_->prefs()->GetString(prefs::kCloudPrintEmail,
70 &cloud_print_email); 71 &cloud_print_email);
71 DCHECK(!cloud_print_email.empty()); 72 DCHECK(!cloud_print_email.empty());
72 backend_->InitializeWithToken(cloud_print_token, cloud_print_xmpp_token, 73 backend_->InitializeWithToken(cloud_print_token, cloud_print_xmpp_token,
73 cloud_print_email, proxy_id); 74 cloud_print_email, proxy_id);
74 } 75 }
76 if (client_) {
77 client_->OnCloudPrintProxyEnabled();
78 }
75 } 79 }
76 80
77 void CloudPrintProxy::DisableForUser() { 81 void CloudPrintProxy::DisableForUser() {
78 DCHECK(CalledOnValidThread()); 82 DCHECK(CalledOnValidThread());
79 Shutdown(); 83 Shutdown();
84 if (client_) {
85 client_->OnCloudPrintProxyDisabled();
86 }
80 } 87 }
81 88
82 void CloudPrintProxy::Shutdown() { 89 void CloudPrintProxy::Shutdown() {
83 DCHECK(CalledOnValidThread()); 90 DCHECK(CalledOnValidThread());
84 if (backend_.get()) 91 if (backend_.get())
85 backend_->Shutdown(); 92 backend_->Shutdown();
86 backend_.reset(); 93 backend_.reset();
87 } 94 }
88 95
89 // Notification methods from the backend. Called on UI thread. 96 // Notification methods from the backend. Called on UI thread.
(...skipping 11 matching lines...) Expand all
101 const std::string& email) { 108 const std::string& email) {
102 DCHECK(CalledOnValidThread()); 109 DCHECK(CalledOnValidThread());
103 service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken, 110 service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken,
104 cloud_print_token); 111 cloud_print_token);
105 service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken, 112 service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken,
106 cloud_print_xmpp_token); 113 cloud_print_xmpp_token);
107 service_prefs_->prefs()->SetString(prefs::kCloudPrintEmail, email); 114 service_prefs_->prefs()->SetString(prefs::kCloudPrintEmail, email);
108 service_prefs_->WritePrefs(); 115 service_prefs_->WritePrefs();
109 } 116 }
110 117
OLDNEW
« no previous file with comments | « chrome/service/cloud_print/cloud_print_proxy.h ('k') | chrome/service/service_process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698