diff options
Diffstat (limited to 'chrome/service/cloud_print')
-rw-r--r-- | chrome/service/cloud_print/cloud_print_proxy.cc | 54 | ||||
-rw-r--r-- | chrome/service/cloud_print/cloud_print_proxy.h | 6 |
2 files changed, 31 insertions, 29 deletions
diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc index 4141b2d..d2fb73c 100644 --- a/chrome/service/cloud_print/cloud_print_proxy.cc +++ b/chrome/service/cloud_print/cloud_print_proxy.cc @@ -10,10 +10,10 @@ #include "base/values.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" -#include "chrome/common/json_pref_store.h" #include "chrome/service/cloud_print/cloud_print_consts.h" #include "chrome/service/cloud_print/print_system.h" #include "chrome/service/service_process.h" +#include "chrome/service/service_process_prefs.h" // This method is invoked on the IO thread to launch the browser process to // display a desktop notification that the Cloud Print token is invalid and @@ -48,7 +48,8 @@ CloudPrintProxy::~CloudPrintProxy() { Shutdown(); } -void CloudPrintProxy::Initialize(JsonPrefStore* service_prefs, Client* client) { +void CloudPrintProxy::Initialize(ServiceProcessPrefs* service_prefs, + Client* client) { DCHECK(CalledOnValidThread()); service_prefs_ = service_prefs; client_ = client; @@ -60,22 +61,22 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) { return; std::string proxy_id; - service_prefs_->prefs()->GetString(prefs::kCloudPrintProxyId, &proxy_id); + service_prefs_->GetString(prefs::kCloudPrintProxyId, &proxy_id); if (proxy_id.empty()) { proxy_id = cloud_print::PrintSystem::GenerateProxyId(); - service_prefs_->prefs()->SetString(prefs::kCloudPrintProxyId, proxy_id); + service_prefs_->SetString(prefs::kCloudPrintProxyId, proxy_id); service_prefs_->WritePrefs(); } // Getting print system specific settings from the preferences. DictionaryValue* print_system_settings = NULL; - service_prefs_->prefs()->GetDictionary(prefs::kCloudPrintPrintSystemSettings, - &print_system_settings); + service_prefs_->GetDictionary(prefs::kCloudPrintPrintSystemSettings, + &print_system_settings); // Check if there is an override for the cloud print server URL. std::string cloud_print_server_url_str; - service_prefs_->prefs()->GetString(prefs::kCloudPrintServiceURL, - &cloud_print_server_url_str); + service_prefs_->GetString(prefs::kCloudPrintServiceURL, + &cloud_print_server_url_str); if (cloud_print_server_url_str.empty()) { cloud_print_server_url_str = kDefaultCloudPrintServerUrl; } @@ -90,15 +91,15 @@ void CloudPrintProxy::EnableForUser(const std::string& lsid) { backend_->InitializeWithLsid(lsid, proxy_id); } else { std::string cloud_print_token; - service_prefs_->prefs()->GetString(prefs::kCloudPrintAuthToken, - &cloud_print_token); + service_prefs_->GetString(prefs::kCloudPrintAuthToken, + &cloud_print_token); DCHECK(!cloud_print_token.empty()); std::string cloud_print_xmpp_token; - service_prefs_->prefs()->GetString(prefs::kCloudPrintXMPPAuthToken, - &cloud_print_xmpp_token); + service_prefs_->GetString(prefs::kCloudPrintXMPPAuthToken, + &cloud_print_xmpp_token); DCHECK(!cloud_print_xmpp_token.empty()); - service_prefs_->prefs()->GetString(prefs::kCloudPrintEmail, - &cloud_print_email_); + service_prefs_->GetString(prefs::kCloudPrintEmail, + &cloud_print_email_); DCHECK(!cloud_print_email_.empty()); backend_->InitializeWithToken(cloud_print_token, cloud_print_xmpp_token, cloud_print_email_, proxy_id); @@ -125,13 +126,6 @@ bool CloudPrintProxy::IsEnabled(std::string* email) const { return enabled; } -void CloudPrintProxy::Shutdown() { - DCHECK(CalledOnValidThread()); - if (backend_.get()) - backend_->Shutdown(); - backend_.reset(); -} - // Notification methods from the backend. Called on UI thread. void CloudPrintProxy::OnPrinterListAvailable( const printing::PrinterList& printer_list) { @@ -147,11 +141,12 @@ void CloudPrintProxy::OnAuthenticated( const std::string& email) { DCHECK(CalledOnValidThread()); cloud_print_email_ = email; - service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken, - cloud_print_token); - service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken, - cloud_print_xmpp_token); - service_prefs_->prefs()->SetString(prefs::kCloudPrintEmail, email); + service_prefs_->SetString(prefs::kCloudPrintAuthToken, + cloud_print_token); + service_prefs_->SetString(prefs::kCloudPrintXMPPAuthToken, + cloud_print_xmpp_token); + service_prefs_->SetString(prefs::kCloudPrintEmail, + email); service_prefs_->WritePrefs(); } @@ -164,3 +159,10 @@ void CloudPrintProxy::OnAuthenticationFailed() { g_service_process->io_thread()->message_loop_proxy()->PostTask( FROM_HERE, NewRunnableFunction(&ShowTokenExpiredNotificationInBrowser)); } + +void CloudPrintProxy::Shutdown() { + DCHECK(CalledOnValidThread()); + if (backend_.get()) + backend_->Shutdown(); + backend_.reset(); +} diff --git a/chrome/service/cloud_print/cloud_print_proxy.h b/chrome/service/cloud_print/cloud_print_proxy.h index 36399ca..a5832f2 100644 --- a/chrome/service/cloud_print/cloud_print_proxy.h +++ b/chrome/service/cloud_print/cloud_print_proxy.h @@ -13,7 +13,7 @@ #include "base/scoped_ptr.h" #include "chrome/service/cloud_print/cloud_print_proxy_backend.h" -class JsonPrefStore; +class ServiceProcessPrefs; // CloudPrintProxy is the layer between the service process UI thread // and the cloud print proxy backend. @@ -31,7 +31,7 @@ class CloudPrintProxy : public CloudPrintProxyFrontend, // Initializes the object. This should be called every time an object of this // class is constructed. - void Initialize(JsonPrefStore* service_prefs, Client* client); + void Initialize(ServiceProcessPrefs* service_prefs, Client* client); // Enables/disables cloud printing for the user void EnableForUser(const std::string& lsid); @@ -60,7 +60,7 @@ class CloudPrintProxy : public CloudPrintProxyFrontend, scoped_ptr<CloudPrintProxyBackend> backend_; // This class does not own this. It is guaranteed to remain valid for the // lifetime of this class. - JsonPrefStore* service_prefs_; + ServiceProcessPrefs* service_prefs_; // This class does not own this. If non-NULL, It is guaranteed to remain // valid for the lifetime of this class. Client* client_; |