summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc66
-rw-r--r--chrome/browser/printing/cloud_print/cloud_print_proxy_service.h22
-rw-r--r--chrome/chrome.gyp17
-rw-r--r--chrome/chrome_browser.gypi14
-rw-r--r--chrome/service/cloud_print/cloud_print_consts.cc (renamed from chrome/browser/printing/cloud_print/cloud_print_consts.cc)10
-rw-r--r--chrome/service/cloud_print/cloud_print_consts.h (renamed from chrome/browser/printing/cloud_print/cloud_print_consts.h)10
-rw-r--r--chrome/service/cloud_print/cloud_print_helpers.cc (renamed from chrome/browser/printing/cloud_print/cloud_print_helpers.cc)11
-rw-r--r--chrome/service/cloud_print/cloud_print_helpers.h (renamed from chrome/browser/printing/cloud_print/cloud_print_helpers.h)8
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.cc20
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy.h13
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy_backend.cc (renamed from chrome/browser/printing/cloud_print/cloud_print_proxy_backend.cc)79
-rw-r--r--chrome/service/cloud_print/cloud_print_proxy_backend.h (renamed from chrome/browser/printing/cloud_print/cloud_print_proxy_backend.h)10
-rw-r--r--chrome/service/cloud_print/job_status_updater.cc (renamed from chrome/browser/printing/cloud_print/job_status_updater.cc)6
-rw-r--r--chrome/service/cloud_print/job_status_updater.h (renamed from chrome/browser/printing/cloud_print/job_status_updater.h)8
-rw-r--r--chrome/service/cloud_print/printer_info.h (renamed from chrome/browser/printing/cloud_print/printer_info.h)6
-rw-r--r--chrome/service/cloud_print/printer_info_linux.cc (renamed from chrome/browser/printing/cloud_print/printer_info_linux.cc)2
-rw-r--r--chrome/service/cloud_print/printer_info_mac.cc (renamed from chrome/browser/printing/cloud_print/printer_info_mac.cc)2
-rw-r--r--chrome/service/cloud_print/printer_info_win.cc (renamed from chrome/browser/printing/cloud_print/printer_info_win.cc)2
-rw-r--r--chrome/service/cloud_print/printer_job_handler.cc (renamed from chrome/browser/printing/cloud_print/printer_job_handler.cc)8
-rw-r--r--chrome/service/cloud_print/printer_job_handler.h (renamed from chrome/browser/printing/cloud_print/printer_job_handler.h)10
20 files changed, 172 insertions, 152 deletions
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
index 75ec15c..87b4450 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
+++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.cc
@@ -26,78 +26,20 @@ CloudPrintProxyService::~CloudPrintProxyService() {
}
void CloudPrintProxyService::Initialize() {
- PrefService* prefs = g_browser_process->local_state();
- DCHECK(prefs);
- prefs->RegisterStringPref(prefs::kCloudPrintProxyId, L"");
- prefs->RegisterStringPref(prefs::kCloudPrintProxyName, L"");
- prefs->RegisterStringPref(prefs::kCloudPrintAuthToken, L"");
}
void CloudPrintProxyService::EnableForUser(const std::string& auth_token) {
- if (backend_.get())
- return;
-
- PrefService* prefs = g_browser_process->local_state();
- DCHECK(prefs);
- std::string proxy_id =
- WideToUTF8(prefs->GetString(prefs::kCloudPrintProxyId));
- if (proxy_id.empty()) {
- // TODO(sanjeevr): Determine whether the proxy id should be server generated
- proxy_id = cloud_print::GenerateProxyId();
- prefs->SetString(prefs::kCloudPrintProxyId, UTF8ToWide(proxy_id));
- }
- std::string token_to_use = auth_token;
- if (token_to_use.empty()) {
- token_to_use = WideToUTF8(prefs->GetString(prefs::kCloudPrintAuthToken));
- } else {
- prefs->SetString(prefs::kCloudPrintAuthToken, UTF8ToWide(token_to_use));
- }
-
- backend_.reset(new CloudPrintProxyBackend(this));
- backend_->Initialize(token_to_use, proxy_id);
+ // TODO(sanjeevr): Add code to communicate with the cloud print proxy code
+ // running in the service process here.
}
void CloudPrintProxyService::DisableForUser() {
- PrefService* prefs = g_browser_process->local_state();
- DCHECK(prefs);
- prefs->ClearPref(prefs::kCloudPrintAuthToken);
Shutdown();
}
-void CloudPrintProxyService::HandlePrinterNotification(
- const std::string& printer_id) {
- if (backend_.get())
- backend_->HandlePrinterNotification(printer_id);
-}
-
void CloudPrintProxyService::Shutdown() {
- if (backend_.get())
- backend_->Shutdown();
- backend_.reset();
-}
-
-// Notification methods from the backend. Called on UI thread.
-void CloudPrintProxyService::OnPrinterListAvailable(
- const cloud_print::PrinterList& printer_list) {
- DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
- // Here we will trim the list to eliminate printers already registered.
- // If there are any more printers left in the list after trimming, we will
- // show the print selection UI. Any printers left in the list after the user
- // selection process will then be registered.
- backend_->RegisterPrinters(printer_list);
-}
-
-// Called when authentication is done. Called on UI thread.
-// Note that sid can be empty. This is a temp function to steal the sid
-// from the Bookmarks Sync code. When the common GAIA signin code is done,
-// The CloudPrintProxyService will simply get a notification when authentication
-// done with an lsid and a sid.
-void CloudPrintProxyService::OnAuthenticated(const std::string& sid) {
- FilePath user_data_dir;
- PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
- ProfileManager* profile_manager = g_browser_process->profile_manager();
- Profile* profile = profile_manager->GetDefaultProfile(user_data_dir);
- profile->GetCloudPrintProxyService()->EnableForUser(sid);
+ // TODO(sanjeevr): Add code to communicate with the cloud print proxy code
+ // running in the service process here.
}
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
index 92985e2..a3795b0 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
+++ b/chrome/browser/printing/cloud_print/cloud_print_proxy_service.h
@@ -15,12 +15,12 @@
#include "base/scoped_ptr.h"
#include "chrome/browser/profile.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_proxy_backend.h"
class Profile;
-// Layer between the browser user interface and the cloud print proxy backend.
-class CloudPrintProxyService : public CloudPrintProxyFrontend {
+// Layer between the browser user interface and the cloud print proxy code
+// running in the service process.
+class CloudPrintProxyService {
public:
explicit CloudPrintProxyService(Profile* profile);
virtual ~CloudPrintProxyService();
@@ -32,26 +32,10 @@ class CloudPrintProxyService : public CloudPrintProxyFrontend {
// Enables/disables cloud printing for the user
virtual void EnableForUser(const std::string& auth_token);
virtual void DisableForUser();
- // Notification received from the server for a particular printer.
- // We need to inform the backend to look for jobs for this printer.
- void HandlePrinterNotification(const std::string& printer_id);
-
- // Notification methods from the backend. Called on UI thread.
- void OnPrinterListAvailable(const cloud_print::PrinterList& printer_list);
-
- // Called when authentication is done. Called on UI thread.
- // Note that sid can be empty. This is placeholder code until we can get
- // common GAIA signin code in place.
- // TODO(sanjeevr): Remove this.
- static void OnAuthenticated(const std::string& auth_token);
protected:
void Shutdown();
- // Our asynchronous backend to communicate with sync components living on
- // other threads.
- scoped_ptr<CloudPrintProxyBackend> backend_;
-
DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyService);
};
diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp
index 729438a..31c4e42 100644
--- a/chrome/chrome.gyp
+++ b/chrome/chrome.gyp
@@ -979,14 +979,31 @@
'type': '<(library)',
'msvs_guid': '2DA87614-55C5-4E56-A17E-0CD099786197',
'dependencies': [
+ 'common',
+ 'common_net',
'../base/base.gyp:base',
+ '../third_party/libjingle/libjingle.gyp:libjingle',
],
'sources': [
'service/service_main.cc',
'service/service_process.cc',
'service/service_process.h',
+ 'service/cloud_print/cloud_print_consts.cc',
+ 'service/cloud_print/cloud_print_consts.h',
+ 'service/cloud_print/cloud_print_helpers.cc',
+ 'service/cloud_print/cloud_print_helpers.h',
'service/cloud_print/cloud_print_proxy.cc',
'service/cloud_print/cloud_print_proxy.h',
+ 'service/cloud_print/cloud_print_proxy_backend.cc',
+ 'service/cloud_print/cloud_print_proxy_backend.h',
+ 'service/cloud_print/job_status_updater.cc',
+ 'service/cloud_print/job_status_updater.h',
+ 'service/cloud_print/printer_info_linux.cc',
+ 'service/cloud_print/printer_info_mac.cc',
+ 'service/cloud_print/printer_info_win.cc',
+ 'service/cloud_print/printer_info.h',
+ 'service/cloud_print/printer_job_handler.cc',
+ 'service/cloud_print/printer_job_handler.h',
'service/gaia/service_gaia_authenticator.cc',
'service/gaia/service_gaia_authenticator.h',
'service/net/service_url_request_context.cc',
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index 38ff50a..be96c12 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -1762,22 +1762,8 @@
'browser/printing/print_view_manager.h',
'browser/printing/printer_query.cc',
'browser/printing/printer_query.h',
- 'browser/printing/cloud_print/cloud_print_consts.cc',
- 'browser/printing/cloud_print/cloud_print_consts.h',
- 'browser/printing/cloud_print/cloud_print_helpers.cc',
- 'browser/printing/cloud_print/cloud_print_helpers.h',
- 'browser/printing/cloud_print/cloud_print_proxy_backend.cc',
- 'browser/printing/cloud_print/cloud_print_proxy_backend.h',
'browser/printing/cloud_print/cloud_print_proxy_service.cc',
'browser/printing/cloud_print/cloud_print_proxy_service.h',
- 'browser/printing/cloud_print/job_status_updater.cc',
- 'browser/printing/cloud_print/job_status_updater.h',
- 'browser/printing/cloud_print/printer_info_linux.cc',
- 'browser/printing/cloud_print/printer_info_mac.cc',
- 'browser/printing/cloud_print/printer_info_win.cc',
- 'browser/printing/cloud_print/printer_info.h',
- 'browser/printing/cloud_print/printer_job_handler.cc',
- 'browser/printing/cloud_print/printer_job_handler.h',
'browser/privacy_blacklist/blacklist.h',
'browser/privacy_blacklist/blacklist.cc',
'browser/privacy_blacklist/blacklist_interceptor.h',
diff --git a/chrome/browser/printing/cloud_print/cloud_print_consts.cc b/chrome/service/cloud_print/cloud_print_consts.cc
index d1c4685..d1f6c17 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_consts.cc
+++ b/chrome/service/cloud_print/cloud_print_consts.cc
@@ -4,7 +4,7 @@
// Constant defines used in the cloud print proxy code
-#include "chrome/browser/printing/cloud_print/cloud_print_consts.h"
+#include "chrome/service/cloud_print/cloud_print_consts.h"
const char kProxyIdValue[] = "proxy";
const char kPrinterNameValue[] = "printer";
@@ -26,5 +26,11 @@ const wchar_t kPrinterCapsHashValue[] = L"capsHash";
// TODO(sanjeevr): Change this to a real one. Also read this from prefs instead
// of hardcoding.
-const char kCloudPrintServerUrl[] = "https://<TBD>";
+const char kCloudPrintServerUrl[] = "http://<TBD>";
+// TODO(sanjeevr): Change this to a real one.
+const char kCloudPrintTalkServiceUrl[] = "http://www.google.com/printing";
+const char kGaiaUrl[] = "https://www.google.com/accounts/ClientLogin";
+// TODO(sanjeevr): Change this to a real one once we get a GAIA service id.
+const char kCloudPrintGaiaServiceId[] = "print";
+const char kSyncGaiaServiceId[] = "chromiumsync";
diff --git a/chrome/browser/printing/cloud_print/cloud_print_consts.h b/chrome/service/cloud_print/cloud_print_consts.h
index 13a091f..126f58e 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_consts.h
+++ b/chrome/service/cloud_print/cloud_print_consts.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
+#define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
#include "base/basictypes.h"
@@ -26,6 +26,10 @@ extern const wchar_t kTitleValue[];
extern const wchar_t kPrinterCapsHashValue[];
extern const char kCloudPrintServerUrl[];
+extern const char kCloudPrintTalkServiceUrl[];
+extern const char kGaiaUrl[];
+extern const char kCloudPrintGaiaServiceId[];
+extern const char kSyncGaiaServiceId[];
// Max interval between retrying connection to the server
const int64 kMaxRetryInterval = 5*60*1000; // 5 minutes in millseconds
@@ -33,5 +37,5 @@ const int64 kBaseRetryInterval = 5*1000; // 5 seconds
const int kMaxRetryCount = 5;
const int64 kJobStatusUpdateInterval = 10*1000; // 10 seconds
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_CONSTS_H_
diff --git a/chrome/browser/printing/cloud_print/cloud_print_helpers.cc b/chrome/service/cloud_print/cloud_print_helpers.cc
index 3f0871f..85d02ad 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_helpers.cc
+++ b/chrome/service/cloud_print/cloud_print_helpers.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/cloud_print_helpers.h"
+#include "chrome/service/cloud_print/cloud_print_helpers.h"
#include "base/json/json_reader.h"
#include "base/rand_util.h"
@@ -11,9 +11,10 @@
#include "base/task.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_consts.h"
-#include "chrome/browser/profile.h"
+#include "chrome/service/cloud_print/cloud_print_consts.h"
#include "chrome/common/net/url_fetcher.h"
+#include "chrome/service/net/service_url_request_context.h"
+#include "chrome/service/service_process.h"
std::string StringFromJobStatus(cloud_print::PrintJobStatus status) {
std::string ret;
@@ -103,8 +104,8 @@ bool CloudPrintHelpers::ParseResponseJSON(
void CloudPrintHelpers::PrepCloudPrintRequest(URLFetcher* request,
const std::string& auth_token) {
- request->set_request_context(
- Profile::GetDefaultRequestContext());
+ DCHECK(g_service_process);
+ request->set_request_context(new ServiceURLRequestContextGetter());
std::string headers = "Authorization: GoogleLogin auth=";
headers += auth_token;
request->set_extra_request_headers(headers);
diff --git a/chrome/browser/printing/cloud_print/cloud_print_helpers.h b/chrome/service/cloud_print/cloud_print_helpers.h
index 46f0e5b..1815663 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_helpers.h
+++ b/chrome/service/cloud_print/cloud_print_helpers.h
@@ -2,12 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
+#define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
#include <string>
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "googleurl/src/gurl.h"
class DictionaryValue;
@@ -67,5 +67,5 @@ class CloudPrintHelpers {
}
};
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_HELPERS_H_
diff --git a/chrome/service/cloud_print/cloud_print_proxy.cc b/chrome/service/cloud_print/cloud_print_proxy.cc
index ea6139b..aff851a 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy.cc
@@ -17,6 +17,11 @@ void CloudPrintProxy::Initialize() {
void CloudPrintProxy::EnableForUser(const std::string& lsid,
const std::string& proxy_id) {
+ if (backend_.get())
+ return;
+
+ backend_.reset(new CloudPrintProxyBackend(this));
+ backend_->Initialize(lsid, proxy_id);
}
void CloudPrintProxy::DisableForUser() {
@@ -25,8 +30,23 @@ void CloudPrintProxy::DisableForUser() {
void CloudPrintProxy::HandlePrinterNotification(
const std::string& printer_id) {
+ if (backend_.get())
+ backend_->HandlePrinterNotification(printer_id);
}
void CloudPrintProxy::Shutdown() {
+ if (backend_.get())
+ backend_->Shutdown();
+ backend_.reset();
+}
+
+// Notification methods from the backend. Called on UI thread.
+void CloudPrintProxy::OnPrinterListAvailable(
+ const cloud_print::PrinterList& printer_list) {
+ // Here we will trim the list to eliminate printers already registered.
+ // If there are any more printers left in the list after trimming, we will
+ // show the print selection UI. Any printers left in the list after the user
+ // selection process will then be registered.
+ backend_->RegisterPrinters(printer_list);
}
diff --git a/chrome/service/cloud_print/cloud_print_proxy.h b/chrome/service/cloud_print/cloud_print_proxy.h
index 0f67d7f..e76f0d9 100644
--- a/chrome/service/cloud_print/cloud_print_proxy.h
+++ b/chrome/service/cloud_print/cloud_print_proxy.h
@@ -9,13 +9,11 @@
#include "base/basictypes.h"
#include "base/scoped_ptr.h"
-
-// TODO(sanjeevr): Integrate this with the CloudPrintProxyBackend. This needs to
-// happen after the cloud_print related files are moved to chrome/service.
+#include "chrome/service/cloud_print/cloud_print_proxy_backend.h"
// CloudPrintProxy is the layer between the service process UI thread
// and the cloud print proxy backend.
-class CloudPrintProxy {
+class CloudPrintProxy : public CloudPrintProxyFrontend {
public:
explicit CloudPrintProxy();
virtual ~CloudPrintProxy();
@@ -33,9 +31,16 @@ class CloudPrintProxy {
// We need to inform the backend to look for jobs for this printer.
void HandlePrinterNotification(const std::string& printer_id);
+ // Notification methods from the backend. Called on UI thread.
+ void OnPrinterListAvailable(const cloud_print::PrinterList& printer_list);
+
protected:
void Shutdown();
+ // Our asynchronous backend to communicate with sync components living on
+ // other threads.
+ scoped_ptr<CloudPrintProxyBackend> backend_;
+
DISALLOW_COPY_AND_ASSIGN(CloudPrintProxy);
};
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_backend.cc b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
index dbc6640..4b0616c 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_backend.cc
+++ b/chrome/service/cloud_print/cloud_print_proxy_backend.cc
@@ -2,18 +2,21 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/cloud_print_proxy_backend.h"
+#include "chrome/service/cloud_print/cloud_print_proxy_backend.h"
#include "base/file_util.h"
#include "base/md5.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/profile.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_consts.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_helpers.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_proxy_service.h"
-#include "chrome/browser/printing/cloud_print/printer_job_handler.h"
+#include "chrome/service/cloud_print/cloud_print_consts.h"
+#include "chrome/service/cloud_print/cloud_print_helpers.h"
+#include "chrome/service/cloud_print/printer_job_handler.h"
+#include "chrome/common/deprecated/event_sys-inl.h"
+#include "chrome/common/net/notifier/listener/talk_mediator_impl.h"
+#include "chrome/service/gaia/service_gaia_authenticator.h"
+#include "chrome/service/service_process.h"
+
#include "googleurl/src/gurl.h"
#include "net/url_request/url_request_status.h"
@@ -33,8 +36,7 @@ class CloudPrintProxyBackend::Core
//
// Called on the CloudPrintProxyBackend core_thread_ to perform
// initialization
- void DoInitialize(const std::string& auth_token,
- const std::string& proxy_id);
+ void DoInitialize(const std::string& lsid, const std::string& proxy_id);
// Called on the CloudPrintProxyBackend core_thread_ to perform
// shutdown.
void DoShutdown();
@@ -107,6 +109,7 @@ class CloudPrintProxyBackend::Core
// handler is responsible for checking for pending print jobs for this
// printer and print them.
void InitJobHandlerForPrinter(DictionaryValue* printer_data);
+ void HandleTalkMediatorEvent(const notifier::TalkMediatorEvent& event);
// Our parent CloudPrintProxyBackend
CloudPrintProxyBackend* backend_;
@@ -140,6 +143,9 @@ class CloudPrintProxyBackend::Core
ResponseHandler next_response_handler_;
cloud_print::PrinterChangeNotifier printer_change_notifier_;
bool new_printers_available_;
+ // Notification (xmpp) handler.
+ scoped_ptr<notifier::TalkMediator> talk_mediator_;
+ scoped_ptr<EventListenerHookup> talk_mediator_hookup_;
DISALLOW_COPY_AND_ASSIGN(Core);
};
@@ -157,13 +163,13 @@ CloudPrintProxyBackend::~CloudPrintProxyBackend() {
DCHECK(!core_);
}
-bool CloudPrintProxyBackend::Initialize(const std::string& auth_token,
+bool CloudPrintProxyBackend::Initialize(const std::string& lsid,
const std::string& proxy_id) {
if (!core_thread_.Start())
return false;
core_thread_.message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(
- core_.get(), &CloudPrintProxyBackend::Core::DoInitialize, auth_token,
+ core_.get(), &CloudPrintProxyBackend::Core::DoInitialize, lsid,
proxy_id));
return true;
}
@@ -199,12 +205,47 @@ CloudPrintProxyBackend::Core::Core(CloudPrintProxyBackend* backend)
next_response_handler_(NULL), new_printers_available_(false) {
}
-void CloudPrintProxyBackend::Core::DoInitialize(const std::string& auth_token,
+void CloudPrintProxyBackend::Core::DoInitialize(const std::string& lsid,
const std::string& proxy_id) {
DCHECK(MessageLoop::current() == backend_->core_thread_.message_loop());
+ // Since Talk does not accept a Cloud Print token, for now, we make 2 auth
+ // requests, one for the chromiumsync service and another for print. This is
+ // temporary and should be removed once Talk supports our token.
+ // Note: The GAIA login is synchronous but that should be OK because we are in
+ // the CloudPrintProxyCoreThread and we cannot really do anything else until
+ // the GAIA signin is successful.
+ std::string user_agent = "ChromiumBrowser";
+ scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_talk =
+ new ServiceGaiaAuthenticator(
+ user_agent, kSyncGaiaServiceId, kGaiaUrl,
+ g_service_process->io_thread()->message_loop_proxy());
+ gaia_auth_for_talk->set_message_loop(MessageLoop::current());
+ // TODO(sanjeevr): Handle auth failure case. We basically need to disable
+ // cloud print and shutdown.
+ if (gaia_auth_for_talk->AuthenticateWithLsid(lsid, true)) {
+ scoped_refptr<ServiceGaiaAuthenticator> gaia_auth_for_print =
+ new ServiceGaiaAuthenticator(
+ user_agent, kCloudPrintGaiaServiceId, kGaiaUrl,
+ g_service_process->io_thread()->message_loop_proxy());
+ gaia_auth_for_print->set_message_loop(MessageLoop::current());
+ if (gaia_auth_for_print->AuthenticateWithLsid(lsid, true)) {
+ auth_token_ = gaia_auth_for_print->auth_token();
+ talk_mediator_.reset(
+ new notifier::TalkMediatorImpl(false));
+ talk_mediator_->AddSubscribedServiceUrl(kCloudPrintTalkServiceUrl);
+ talk_mediator_hookup_.reset(
+ NewEventListenerHookup(
+ talk_mediator_->channel(),
+ this,
+ &CloudPrintProxyBackend::Core::HandleTalkMediatorEvent));
+ talk_mediator_->SetAuthToken(gaia_auth_for_talk->email(),
+ gaia_auth_for_talk->auth_token(),
+ kSyncGaiaServiceId);
+ talk_mediator_->Login();
+ }
+ }
printer_change_notifier_.StartWatching(std::string(), this);
proxy_id_ = proxy_id;
- auth_token_ = auth_token;
StartRegistration();
}
@@ -479,6 +520,20 @@ bool CloudPrintProxyBackend::Core::RemovePrinterFromList(
return ret;
}
+void CloudPrintProxyBackend::Core::HandleTalkMediatorEvent(
+ const notifier::TalkMediatorEvent& event) {
+ if ((event.what_happened ==
+ notifier::TalkMediatorEvent::NOTIFICATION_RECEIVED) &&
+ (0 == base::strcasecmp(kCloudPrintTalkServiceUrl,
+ event.notification_data.service_url.c_str()))) {
+ backend_->core_thread_.message_loop()->PostTask(
+ FROM_HERE,
+ NewRunnableMethod(
+ this, &CloudPrintProxyBackend::Core::DoHandlePrinterNotification,
+ event.notification_data.service_specific_data));
+ }
+}
+
// cloud_print::PrinterChangeNotifier::Delegate implementation
void CloudPrintProxyBackend::Core::OnPrinterAdded() {
if (request_.get()) {
diff --git a/chrome/browser/printing/cloud_print/cloud_print_proxy_backend.h b/chrome/service/cloud_print/cloud_print_proxy_backend.h
index acced9a..d622ccc 100644
--- a/chrome/browser/printing/cloud_print/cloud_print_proxy_backend.h
+++ b/chrome/service/cloud_print/cloud_print_proxy_backend.h
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
+#define CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
#include <map>
#include <string>
#include "base/thread.h"
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "chrome/common/net/url_fetcher.h"
class CloudPrintProxyService;
@@ -41,7 +41,7 @@ class CloudPrintProxyBackend {
explicit CloudPrintProxyBackend(CloudPrintProxyFrontend* frontend);
~CloudPrintProxyBackend();
- bool Initialize(const std::string& auth_token, const std::string& proxy_id);
+ bool Initialize(const std::string& lsid, const std::string& proxy_id);
void Shutdown();
void RegisterPrinters(const cloud_print::PrinterList& printer_list);
void HandlePrinterNotification(const std::string& printer_id);
@@ -66,5 +66,5 @@ class CloudPrintProxyBackend {
DISALLOW_COPY_AND_ASSIGN(CloudPrintProxyBackend);
};
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_CLOUD_PRINT_PROXY_BACKEND_H_
diff --git a/chrome/browser/printing/cloud_print/job_status_updater.cc b/chrome/service/cloud_print/job_status_updater.cc
index a17c451..2492a84 100644
--- a/chrome/browser/printing/cloud_print/job_status_updater.cc
+++ b/chrome/service/cloud_print/job_status_updater.cc
@@ -2,14 +2,14 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/job_status_updater.h"
+#include "chrome/service/cloud_print/job_status_updater.h"
#include "base/json/json_reader.h"
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_consts.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_helpers.h"
+#include "chrome/service/cloud_print/cloud_print_consts.h"
+#include "chrome/service/cloud_print/cloud_print_helpers.h"
#include "googleurl/src/gurl.h"
JobStatusUpdater::JobStatusUpdater(const std::string& printer_name,
diff --git a/chrome/browser/printing/cloud_print/job_status_updater.h b/chrome/service/cloud_print/job_status_updater.h
index a951084..d840b1c 100644
--- a/chrome/browser/printing/cloud_print/job_status_updater.h
+++ b/chrome/service/cloud_print/job_status_updater.h
@@ -2,15 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+#define CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
#include <string>
#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/thread.h"
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "chrome/common/net/url_fetcher.h"
#include "net/url_request/url_request_status.h"
@@ -60,5 +60,5 @@ class JobStatusUpdater : public base::RefCountedThreadSafe<JobStatusUpdater>,
// the workaround was not needed for my machine).
typedef JobStatusUpdater::Delegate JobStatusUpdaterDelegate;
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_JOB_STATUS_UPDATER_H_
diff --git a/chrome/browser/printing/cloud_print/printer_info.h b/chrome/service/cloud_print/printer_info.h
index 1bb1746..912e6bf 100644
--- a/chrome/browser/printing/cloud_print/printer_info.h
+++ b/chrome/service/cloud_print/printer_info.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
+#define CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
#include <string>
#include <vector>
@@ -121,5 +121,5 @@ typedef PrinterChangeNotifier::Delegate PrinterChangeNotifierDelegate;
} // namespace cloud_print
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_INFO_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_INFO_H_
diff --git a/chrome/browser/printing/cloud_print/printer_info_linux.cc b/chrome/service/cloud_print/printer_info_linux.cc
index 0715bb8..7ef9529 100644
--- a/chrome/browser/printing/cloud_print/printer_info_linux.cc
+++ b/chrome/service/cloud_print/printer_info_linux.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "base/logging.h"
diff --git a/chrome/browser/printing/cloud_print/printer_info_mac.cc b/chrome/service/cloud_print/printer_info_mac.cc
index dd0dbad..1c09b4a 100644
--- a/chrome/browser/printing/cloud_print/printer_info_mac.cc
+++ b/chrome/service/cloud_print/printer_info_mac.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "base/logging.h"
diff --git a/chrome/browser/printing/cloud_print/printer_info_win.cc b/chrome/service/cloud_print/printer_info_win.cc
index b1ec208..4839d60 100644
--- a/chrome/browser/printing/cloud_print/printer_info_win.cc
+++ b/chrome/service/cloud_print/printer_info_win.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include <windows.h>
#include <objidl.h>
diff --git a/chrome/browser/printing/cloud_print/printer_job_handler.cc b/chrome/service/cloud_print/printer_job_handler.cc
index a27fdf0..09b649f 100644
--- a/chrome/browser/printing/cloud_print/printer_job_handler.cc
+++ b/chrome/service/cloud_print/printer_job_handler.cc
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/printing/cloud_print/printer_job_handler.h"
+#include "chrome/service/cloud_print/printer_job_handler.h"
#include "base/file_util.h"
#include "base/json/json_reader.h"
@@ -10,9 +10,9 @@
#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "base/values.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_consts.h"
-#include "chrome/browser/printing/cloud_print/cloud_print_helpers.h"
-#include "chrome/browser/printing/cloud_print/job_status_updater.h"
+#include "chrome/service/cloud_print/cloud_print_consts.h"
+#include "chrome/service/cloud_print/cloud_print_helpers.h"
+#include "chrome/service/cloud_print/job_status_updater.h"
#include "googleurl/src/gurl.h"
#include "net/http/http_response_headers.h"
diff --git a/chrome/browser/printing/cloud_print/printer_job_handler.h b/chrome/service/cloud_print/printer_job_handler.h
index 4e8d61c..5b480db 100644
--- a/chrome/browser/printing/cloud_print/printer_job_handler.h
+++ b/chrome/service/cloud_print/printer_job_handler.h
@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
-#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
+#ifndef CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
+#define CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
#include <list>
#include <string>
@@ -11,8 +11,8 @@
#include "base/file_path.h"
#include "base/ref_counted.h"
#include "base/thread.h"
-#include "chrome/browser/printing/cloud_print/job_status_updater.h"
-#include "chrome/browser/printing/cloud_print/printer_info.h"
+#include "chrome/service/cloud_print/job_status_updater.h"
+#include "chrome/service/cloud_print/printer_info.h"
#include "chrome/common/net/url_fetcher.h"
#include "net/url_request/url_request_status.h"
@@ -236,5 +236,5 @@ class PrinterJobHandler : public base::RefCountedThreadSafe<PrinterJobHandler>,
// the workaround was not needed for my machine).
typedef PrinterJobHandler::Delegate PrinterJobHandlerDelegate;
-#endif // CHROME_BROWSER_PRINTING_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_
+#endif // CHROME_SERVICE_CLOUD_PRINT_PRINTER_JOB_HANDLER_H_