OLD | NEW |
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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/json_pref_store.h" | 13 #include "chrome/common/json_pref_store.h" |
14 #include "chrome/service/cloud_print/cloud_print_consts.h" | 14 #include "chrome/service/cloud_print/cloud_print_consts.h" |
| 15 #include "chrome/service/cloud_print/print_system.h" |
15 #include "chrome/service/service_process.h" | 16 #include "chrome/service/service_process.h" |
16 | 17 |
17 // This method is invoked on the IO thread to launch the browser process to | 18 // This method is invoked on the IO thread to launch the browser process to |
18 // display a desktop notification that the Cloud Print token is invalid and | 19 // display a desktop notification that the Cloud Print token is invalid and |
19 // needs re-authentication. | 20 // needs re-authentication. |
20 static void ShowTokenExpiredNotificationInBrowser() { | 21 static void ShowTokenExpiredNotificationInBrowser() { |
21 DCHECK(g_service_process->io_thread()->message_loop_proxy()-> | 22 DCHECK(g_service_process->io_thread()->message_loop_proxy()-> |
22 BelongsToCurrentThread()); | 23 BelongsToCurrentThread()); |
23 FilePath exe_path; | 24 FilePath exe_path; |
24 PathService::Get(base::FILE_EXE, &exe_path); | 25 PathService::Get(base::FILE_EXE, &exe_path); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 | 127 |
127 void CloudPrintProxy::Shutdown() { | 128 void CloudPrintProxy::Shutdown() { |
128 DCHECK(CalledOnValidThread()); | 129 DCHECK(CalledOnValidThread()); |
129 if (backend_.get()) | 130 if (backend_.get()) |
130 backend_->Shutdown(); | 131 backend_->Shutdown(); |
131 backend_.reset(); | 132 backend_.reset(); |
132 } | 133 } |
133 | 134 |
134 // Notification methods from the backend. Called on UI thread. | 135 // Notification methods from the backend. Called on UI thread. |
135 void CloudPrintProxy::OnPrinterListAvailable( | 136 void CloudPrintProxy::OnPrinterListAvailable( |
136 const cloud_print::PrinterList& printer_list) { | 137 const printing::PrinterList& printer_list) { |
137 DCHECK(CalledOnValidThread()); | 138 DCHECK(CalledOnValidThread()); |
138 // We could potentially show UI here allowing the user to select which | 139 // We could potentially show UI here allowing the user to select which |
139 // printers to register. For now, we just register all. | 140 // printers to register. For now, we just register all. |
140 backend_->RegisterPrinters(printer_list); | 141 backend_->RegisterPrinters(printer_list); |
141 } | 142 } |
142 | 143 |
143 void CloudPrintProxy::OnAuthenticated( | 144 void CloudPrintProxy::OnAuthenticated( |
144 const std::string& cloud_print_token, | 145 const std::string& cloud_print_token, |
145 const std::string& cloud_print_xmpp_token, | 146 const std::string& cloud_print_xmpp_token, |
146 const std::string& email) { | 147 const std::string& email) { |
147 DCHECK(CalledOnValidThread()); | 148 DCHECK(CalledOnValidThread()); |
148 cloud_print_email_ = email; | 149 cloud_print_email_ = email; |
149 service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken, | 150 service_prefs_->prefs()->SetString(prefs::kCloudPrintAuthToken, |
150 cloud_print_token); | 151 cloud_print_token); |
151 service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken, | 152 service_prefs_->prefs()->SetString(prefs::kCloudPrintXMPPAuthToken, |
152 cloud_print_xmpp_token); | 153 cloud_print_xmpp_token); |
153 service_prefs_->prefs()->SetString(prefs::kCloudPrintEmail, email); | 154 service_prefs_->prefs()->SetString(prefs::kCloudPrintEmail, email); |
154 service_prefs_->WritePrefs(); | 155 service_prefs_->WritePrefs(); |
155 } | 156 } |
156 | 157 |
157 void CloudPrintProxy::OnAuthenticationFailed() { | 158 void CloudPrintProxy::OnAuthenticationFailed() { |
158 DCHECK(CalledOnValidThread()); | 159 DCHECK(CalledOnValidThread()); |
159 // If authenticated failed, we will disable the cloud print proxy. | 160 // If authenticated failed, we will disable the cloud print proxy. |
160 DisableForUser(); | 161 DisableForUser(); |
161 // Launch the browser to display a notification that the credentials have | 162 // Launch the browser to display a notification that the credentials have |
162 // expired. | 163 // expired. |
163 g_service_process->io_thread()->message_loop_proxy()->PostTask( | 164 g_service_process->io_thread()->message_loop_proxy()->PostTask( |
164 FROM_HERE, NewRunnableFunction(&ShowTokenExpiredNotificationInBrowser)); | 165 FROM_HERE, NewRunnableFunction(&ShowTokenExpiredNotificationInBrowser)); |
165 } | 166 } |
166 | |
OLD | NEW |