Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 static_cast<size_t>(button_index) < button_commands_->size()); | 110 static_cast<size_t>(button_index) < button_commands_->size()); |
| 111 | 111 |
| 112 CupsPrintJobNotification::ButtonCommand button_command = | 112 CupsPrintJobNotification::ButtonCommand button_command = |
| 113 button_commands_->at(button_index); | 113 button_commands_->at(button_index); |
| 114 CupsPrintJobManager* print_job_manager = | 114 CupsPrintJobManager* print_job_manager = |
| 115 CupsPrintJobManagerFactory::GetForBrowserContext(profile_); | 115 CupsPrintJobManagerFactory::GetForBrowserContext(profile_); |
| 116 const ProfileID profile_id = NotificationUIManager::GetProfileID(profile_); | 116 const ProfileID profile_id = NotificationUIManager::GetProfileID(profile_); |
| 117 | 117 |
| 118 switch (button_command) { | 118 switch (button_command) { |
| 119 case ButtonCommand::CANCEL_PRINTING: | 119 case ButtonCommand::CANCEL_PRINTING: |
| 120 if (print_job_manager->CancelPrintJob(print_job_)) { | 120 print_job_manager->CancelPrintJob(print_job_); |
| 121 // only clean up the nofitication if cancel was successful. | 121 // print_job_ may be deleted by print_job_manager after cancellation. |
|
Carlson
2017/03/16 18:36:48
I don't understand what this comment means. That
skau
2017/03/16 22:14:36
It was supposed to mean that print_job_ is deleted
| |
| 122 g_browser_process->notification_ui_manager()->CancelById( | 122 print_job_ = nullptr; |
| 123 GetNotificationId(), profile_id); | 123 |
| 124 cancelled_by_user_ = true; | 124 // only clean up the nofitication if cancel was successful. |
| 125 notification_manager_->OnPrintJobNotificationRemoved(this); | 125 g_browser_process->notification_ui_manager()->CancelById( |
| 126 } | 126 GetNotificationId(), profile_id); |
| 127 cancelled_by_user_ = true; | |
| 128 notification_manager_->OnPrintJobNotificationRemoved(this); | |
| 127 break; | 129 break; |
| 128 case ButtonCommand::PAUSE_PRINTING: | 130 case ButtonCommand::PAUSE_PRINTING: |
| 129 print_job_manager->SuspendPrintJob(print_job_); | 131 print_job_manager->SuspendPrintJob(print_job_); |
| 130 break; | 132 break; |
| 131 case ButtonCommand::RESUME_PRINTING: | 133 case ButtonCommand::RESUME_PRINTING: |
| 132 print_job_manager->ResumePrintJob(print_job_); | 134 print_job_manager->ResumePrintJob(print_job_); |
| 133 break; | 135 break; |
| 134 case ButtonCommand::GET_HELP: | 136 case ButtonCommand::GET_HELP: |
| 135 break; | 137 break; |
| 136 } | 138 } |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PLAY); | 338 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_PLAY); |
| 337 break; | 339 break; |
| 338 case ButtonCommand::GET_HELP: | 340 case ButtonCommand::GET_HELP: |
| 339 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_HELP); | 341 icon = bundle.GetImageNamed(IDR_PRINT_NOTIFICATION_HELP); |
| 340 break; | 342 break; |
| 341 } | 343 } |
| 342 return icon; | 344 return icon; |
| 343 } | 345 } |
| 344 | 346 |
| 345 } // namespace chromeos | 347 } // namespace chromeos |
| OLD | NEW |