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

Side by Side Diff: chrome/browser/chromeos/printing/cups_print_job_notification.cc

Issue 2872733002: [CUPS] Update UI for CUPS printing notifications. (Closed)
Patch Set: . Created 3 years, 7 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
« no previous file with comments | « chrome/app/chromeos_strings.grdp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/browser/chromeos/printing/cups_print_job_notification.h" 5 #include "chrome/browser/chromeos/printing/cups_print_job_notification.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 g_browser_process->notification_ui_manager()->Add(*notification_, profile_); 174 g_browser_process->notification_ui_manager()->Add(*notification_, profile_);
175 } 175 }
176 176
177 // |print_job_| will be deleted by CupsPrintJobManager if the job is finished 177 // |print_job_| will be deleted by CupsPrintJobManager if the job is finished
178 // and we are not supposed to get any notification update after that. 178 // and we are not supposed to get any notification update after that.
179 if (print_job_->IsJobFinished()) 179 if (print_job_->IsJobFinished())
180 print_job_ = nullptr; 180 print_job_ = nullptr;
181 } 181 }
182 182
183 void CupsPrintJobNotification::UpdateNotificationTitle() { 183 void CupsPrintJobNotification::UpdateNotificationTitle() {
184 notification_->set_title(base::UTF8ToUTF16(print_job_->document_title())); 184 base::string16 title;
185 switch (print_job_->state()) {
186 case CupsPrintJob::State::STATE_WAITING:
187 case CupsPrintJob::State::STATE_STARTED:
188 case CupsPrintJob::State::STATE_PAGE_DONE:
189 case CupsPrintJob::State::STATE_SUSPENDED:
190 case CupsPrintJob::State::STATE_RESUMED:
191 title = l10n_util::GetStringFUTF16(
192 IDS_PRINT_JOB_PRINTING_NOTIFICATION_TITLE,
193 base::UTF8ToUTF16(print_job_->document_title()));
194 break;
195 case CupsPrintJob::State::STATE_DOCUMENT_DONE:
196 title = l10n_util::GetStringFUTF16(
197 IDS_PRINT_JOB_DONE_NOTIFICATION_TITLE,
198 base::UTF8ToUTF16(print_job_->document_title()));
199 break;
200 case CupsPrintJob::State::STATE_CANCELLED:
201 case CupsPrintJob::State::STATE_ERROR:
202 title = l10n_util::GetStringFUTF16(
203 IDS_PRINT_JOB_ERROR_NOTIFICATION_TITLE,
204 base::UTF8ToUTF16(print_job_->document_title()));
205 break;
206 default:
207 break;
208 }
209 notification_->set_title(title);
185 } 210 }
186 211
187 void CupsPrintJobNotification::UpdateNotificationIcon() { 212 void CupsPrintJobNotification::UpdateNotificationIcon() {
188 ResourceBundle& bundle = ResourceBundle::GetSharedInstance(); 213 ResourceBundle& bundle = ResourceBundle::GetSharedInstance();
189 switch (print_job_->state()) { 214 switch (print_job_->state()) {
190 case CupsPrintJob::State::STATE_WAITING: 215 case CupsPrintJob::State::STATE_WAITING:
191 case CupsPrintJob::State::STATE_STARTED: 216 case CupsPrintJob::State::STATE_STARTED:
192 case CupsPrintJob::State::STATE_PAGE_DONE: 217 case CupsPrintJob::State::STATE_PAGE_DONE:
193 case CupsPrintJob::State::STATE_SUSPENDED: 218 case CupsPrintJob::State::STATE_SUSPENDED:
194 case CupsPrintJob::State::STATE_RESUMED: 219 case CupsPrintJob::State::STATE_RESUMED:
195 notification_->set_icon( 220 notification_->set_icon(
196 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PRINTING)); 221 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PRINTING));
197 break; 222 break;
198 case CupsPrintJob::State::STATE_DOCUMENT_DONE: 223 case CupsPrintJob::State::STATE_DOCUMENT_DONE:
199 notification_->set_icon( 224 notification_->set_icon(
200 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_DONE)); 225 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_DONE));
201 break; 226 break;
202 case CupsPrintJob::State::STATE_CANCELLED: 227 case CupsPrintJob::State::STATE_CANCELLED:
203 case CupsPrintJob::State::STATE_ERROR: 228 case CupsPrintJob::State::STATE_ERROR:
204 notification_->set_icon( 229 notification_->set_icon(
205 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_ERROR)); 230 bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_ERROR));
206 case CupsPrintJob::State::STATE_NONE: 231 case CupsPrintJob::State::STATE_NONE:
207 break; 232 break;
208 } 233 }
209 } 234 }
210 235
211 void CupsPrintJobNotification::UpdateNotificationBodyMessage() { 236 void CupsPrintJobNotification::UpdateNotificationBodyMessage() {
212 base::string16 message; 237 base::string16 message = l10n_util::GetStringFUTF16(
213 switch (print_job_->state()) { 238 (print_job_->total_page_number() > 1)
214 case CupsPrintJob::State::STATE_NONE: 239 ? IDS_PRINT_JOB_NOTIFICATION_MESSAGE
215 break; 240 : IDS_PRINT_JOB_NOTIFICATION_SINGLE_PAGE_MESSAGE,
216 case CupsPrintJob::State::STATE_WAITING: 241 base::IntToString16(print_job_->total_page_number()),
217 case CupsPrintJob::State::STATE_STARTED: 242 base::UTF8ToUTF16(print_job_->printer().display_name()));
218 case CupsPrintJob::State::STATE_PAGE_DONE:
219 case CupsPrintJob::State::STATE_SUSPENDED:
220 case CupsPrintJob::State::STATE_RESUMED:
221 message = l10n_util::GetStringFUTF16(
222 IDS_PRINT_JOB_PRINTING_NOTIFICATION_MESSAGE,
223 base::IntToString16(print_job_->total_page_number()),
224 base::UTF8ToUTF16(print_job_->printer().display_name()));
225
226 break;
227 case CupsPrintJob::State::STATE_DOCUMENT_DONE:
228 message = l10n_util::GetStringFUTF16(
229 IDS_PRINT_JOB_DONE_NOTIFICATION_MESSAGE,
230 base::IntToString16(print_job_->total_page_number()),
231 base::UTF8ToUTF16(print_job_->printer().display_name()));
232 break;
233 case CupsPrintJob::State::STATE_CANCELLED:
234 case CupsPrintJob::State::STATE_ERROR:
235 message = l10n_util::GetStringFUTF16(
236 IDS_PRINT_JOB_ERROR_NOTIFICATION_MESSAGE,
237 base::IntToString16(print_job_->total_page_number()),
238 base::UTF8ToUTF16(print_job_->printer().display_name()));
239 break;
240 default:
241 break;
242 }
243 notification_->set_message(message); 243 notification_->set_message(message);
244 } 244 }
245 245
246 void CupsPrintJobNotification::UpdateNotificationType() { 246 void CupsPrintJobNotification::UpdateNotificationType() {
247 switch (print_job_->state()) { 247 switch (print_job_->state()) {
248 case CupsPrintJob::State::STATE_WAITING: 248 case CupsPrintJob::State::STATE_WAITING:
249 case CupsPrintJob::State::STATE_STARTED: 249 case CupsPrintJob::State::STATE_STARTED:
250 case CupsPrintJob::State::STATE_PAGE_DONE: 250 case CupsPrintJob::State::STATE_PAGE_DONE:
251 case CupsPrintJob::State::STATE_SUSPENDED: 251 case CupsPrintJob::State::STATE_SUSPENDED:
252 case CupsPrintJob::State::STATE_RESUMED: 252 case CupsPrintJob::State::STATE_RESUMED:
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PLAY); 332 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PLAY);
333 break; 333 break;
334 case ButtonCommand::GET_HELP: 334 case ButtonCommand::GET_HELP:
335 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_HELP); 335 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_HELP);
336 break; 336 break;
337 } 337 }
338 return icon; 338 return icon;
339 } 339 }
340 340
341 } // namespace chromeos 341 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/app/chromeos_strings.grdp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698