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

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

Issue 9443007: Add Chrome To Mobile Service and Views Page Action. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Put shared CloudPrint consts/helpers in chrome/common/; use CloudPrintURL. Created 8 years, 9 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/service/cloud_print/cloud_print_proxy.h" 5 #include "chrome/service/cloud_print/cloud_print_proxy.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
11 #include "base/values.h" 11 #include "base/values.h"
12 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
13 #include "chrome/common/cloud_print/cloud_print_helpers.h"
13 #include "chrome/common/cloud_print/cloud_print_proxy_info.h" 14 #include "chrome/common/cloud_print/cloud_print_proxy_info.h"
14 #include "chrome/common/net/gaia/gaia_oauth_client.h" 15 #include "chrome/common/net/gaia/gaia_oauth_client.h"
15 #include "chrome/common/pref_names.h" 16 #include "chrome/common/pref_names.h"
16 #include "chrome/service/cloud_print/cloud_print_consts.h" 17 #include "chrome/service/cloud_print/cloud_print_consts.h"
17 #include "chrome/service/cloud_print/print_system.h" 18 #include "chrome/service/cloud_print/print_system.h"
18 #include "chrome/service/service_process.h" 19 #include "chrome/service/service_process.h"
19 #include "chrome/service/service_process_prefs.h" 20 #include "chrome/service/service_process_prefs.h"
20 #include "googleurl/src/gurl.h" 21 #include "googleurl/src/gurl.h"
21 22
22 namespace { 23 namespace {
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 } 135 }
135 136
136 bool CloudPrintProxy::CreateBackend() { 137 bool CloudPrintProxy::CreateBackend() {
137 DCHECK(CalledOnValidThread()); 138 DCHECK(CalledOnValidThread());
138 if (backend_.get()) 139 if (backend_.get())
139 return false; 140 return false;
140 141
141 service_prefs_->GetString(prefs::kCloudPrintProxyId, &proxy_id_); 142 service_prefs_->GetString(prefs::kCloudPrintProxyId, &proxy_id_);
142 if (proxy_id_.empty()) { 143 if (proxy_id_.empty()) {
143 proxy_id_ = cloud_print::PrintSystem::GenerateProxyId(); 144 proxy_id_ = cloud_print::GenerateProxyId();
144 service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id_); 145 service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id_);
145 service_prefs_->WritePrefs(); 146 service_prefs_->WritePrefs();
146 } 147 }
147 148
148 // Getting print system specific settings from the preferences. 149 // Getting print system specific settings from the preferences.
149 const DictionaryValue* print_system_settings = NULL; 150 const DictionaryValue* print_system_settings = NULL;
150 service_prefs_->GetDictionary(prefs::kCloudPrintPrintSystemSettings, 151 service_prefs_->GetDictionary(prefs::kCloudPrintPrintSystemSettings,
151 &print_system_settings); 152 &print_system_settings);
152 153
153 // Check if there is an override for the cloud print server URL. 154 // Check if there is an override for the cloud print server URL.
154 std::string cloud_print_server_url_str; 155 std::string cloud_print_server_url_str;
155 service_prefs_->GetString(prefs::kCloudPrintServiceURL, 156 service_prefs_->GetString(prefs::kCloudPrintServiceURL,
156 &cloud_print_server_url_str); 157 &cloud_print_server_url_str);
157 if (cloud_print_server_url_str.empty()) { 158 if (cloud_print_server_url_str.empty())
158 cloud_print_server_url_str = kDefaultCloudPrintServerUrl; 159 cloud_print_server_url_str = kDefaultCloudPrintServerUrl;
159 }
160 160
161 // By default we don't poll for jobs when we lose XMPP connection. But this 161 // By default we don't poll for jobs when we lose XMPP connection. But this
162 // behavior can be overridden by a preference. 162 // behavior can be overridden by a preference.
163 bool enable_job_poll = false; 163 bool enable_job_poll = false;
164 service_prefs_->GetBoolean(prefs::kCloudPrintEnableJobPoll, 164 service_prefs_->GetBoolean(prefs::kCloudPrintEnableJobPoll,
165 &enable_job_poll); 165 &enable_job_poll);
166 166
167 // TODO(sanjeevr): Allow overriding OAuthClientInfo in prefs. 167 // TODO(sanjeevr): Allow overriding OAuthClientInfo in prefs.
168 gaia::OAuthClientInfo oauth_client_info; 168 gaia::OAuthClientInfo oauth_client_info;
169 oauth_client_info.client_id = kDefaultCloudPrintOAuthClientId; 169 oauth_client_info.client_id = cloud_print::kDefaultCloudPrintOAuthClientId;
170 oauth_client_info.client_secret = kDefaultCloudPrintOAuthClientSecret; 170 oauth_client_info.client_secret = kDefaultCloudPrintOAuthClientSecret;
171 171
172 GURL cloud_print_server_url(cloud_print_server_url_str.c_str()); 172 GURL cloud_print_server_url(cloud_print_server_url_str.c_str());
173 DCHECK(cloud_print_server_url.is_valid()); 173 DCHECK(cloud_print_server_url.is_valid());
174 backend_.reset(new CloudPrintProxyBackend(this, proxy_id_, 174 backend_.reset(new CloudPrintProxyBackend(this, proxy_id_,
175 cloud_print_server_url, 175 cloud_print_server_url,
176 print_system_settings, 176 print_system_settings,
177 oauth_client_info, 177 oauth_client_info,
178 enable_job_poll)); 178 enable_job_poll));
179 return true; 179 return true;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 client_->OnCloudPrintProxyDisabled(false); 250 client_->OnCloudPrintProxyDisabled(false);
251 } 251 }
252 } 252 }
253 253
254 void CloudPrintProxy::Shutdown() { 254 void CloudPrintProxy::Shutdown() {
255 DCHECK(CalledOnValidThread()); 255 DCHECK(CalledOnValidThread());
256 if (backend_.get()) 256 if (backend_.get())
257 backend_->Shutdown(); 257 backend_->Shutdown();
258 backend_.reset(); 258 backend_.reset();
259 } 259 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698