| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/printing/background_printing_manager.h" | 5 #include "chrome/browser/printing/background_printing_manager.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 } | 49 } |
| 50 void BackgroundPrintingManager::Observer::WebContentsDestroyed() { | 50 void BackgroundPrintingManager::Observer::WebContentsDestroyed() { |
| 51 manager_->DeletePreviewContents(web_contents()); | 51 manager_->DeletePreviewContents(web_contents()); |
| 52 } | 52 } |
| 53 | 53 |
| 54 BackgroundPrintingManager::BackgroundPrintingManager() { | 54 BackgroundPrintingManager::BackgroundPrintingManager() { |
| 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 55 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 56 } | 56 } |
| 57 | 57 |
| 58 BackgroundPrintingManager::~BackgroundPrintingManager() { | 58 BackgroundPrintingManager::~BackgroundPrintingManager() { |
| 59 DCHECK(CalledOnValidThread()); | 59 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 60 // The might be some WebContentses still in |printing_contents_map_| at this | 60 // The might be some WebContentses still in |printing_contents_map_| at this |
| 61 // point (e.g. when the last remaining tab closes and there is still a print | 61 // point (e.g. when the last remaining tab closes and there is still a print |
| 62 // preview WebContents trying to print). In such a case it will fail to print, | 62 // preview WebContents trying to print). In such a case it will fail to print, |
| 63 // but we should at least clean up the observers. | 63 // but we should at least clean up the observers. |
| 64 // TODO(thestig): Handle this case better. | 64 // TODO(thestig): Handle this case better. |
| 65 } | 65 } |
| 66 | 66 |
| 67 void BackgroundPrintingManager::OwnPrintPreviewDialog( | 67 void BackgroundPrintingManager::OwnPrintPreviewDialog( |
| 68 WebContents* preview_dialog) { | 68 WebContents* preview_dialog) { |
| 69 DCHECK(CalledOnValidThread()); | 69 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 70 DCHECK(PrintPreviewDialogController::IsPrintPreviewDialog(preview_dialog)); | 70 DCHECK(PrintPreviewDialogController::IsPrintPreviewDialog(preview_dialog)); |
| 71 CHECK(!HasPrintPreviewDialog(preview_dialog)); | 71 CHECK(!HasPrintPreviewDialog(preview_dialog)); |
| 72 | 72 |
| 73 printing_contents_map_[preview_dialog] = | 73 printing_contents_map_[preview_dialog] = |
| 74 base::MakeUnique<Observer>(this, preview_dialog); | 74 base::MakeUnique<Observer>(this, preview_dialog); |
| 75 | 75 |
| 76 // Watch for print jobs finishing. Everything else is watched for by the | 76 // Watch for print jobs finishing. Everything else is watched for by the |
| 77 // Observer. TODO(avi, cait): finish the job of removing this last | 77 // Observer. TODO(avi, cait): finish the job of removing this last |
| 78 // notification. | 78 // notification. |
| 79 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 79 registrar_.Add(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 return result; | 142 return result; |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool BackgroundPrintingManager::HasPrintPreviewDialog( | 145 bool BackgroundPrintingManager::HasPrintPreviewDialog( |
| 146 WebContents* preview_dialog) { | 146 WebContents* preview_dialog) { |
| 147 return base::ContainsKey(printing_contents_map_, preview_dialog); | 147 return base::ContainsKey(printing_contents_map_, preview_dialog); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace printing | 150 } // namespace printing |
| OLD | NEW |