| 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/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 54 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 55 } | 55 } |
| 56 | 56 |
| 57 BackgroundPrintingManager::~BackgroundPrintingManager() { | 57 BackgroundPrintingManager::~BackgroundPrintingManager() { |
| 58 DCHECK(CalledOnValidThread()); | 58 DCHECK(CalledOnValidThread()); |
| 59 // The might be some WebContentses still in |printing_contents_map_| at this | 59 // The might be some WebContentses still in |printing_contents_map_| at this |
| 60 // point (e.g. when the last remaining tab closes and there is still a print | 60 // point (e.g. when the last remaining tab closes and there is still a print |
| 61 // preview WebContents trying to print). In such a case it will fail to print, | 61 // preview WebContents trying to print). In such a case it will fail to print, |
| 62 // but we should at least clean up the observers. | 62 // but we should at least clean up the observers. |
| 63 // TODO(thestig): Handle this case better. | 63 // TODO(thestig): Handle this case better. |
| 64 STLDeleteValues(&printing_contents_map_); | 64 base::STLDeleteValues(&printing_contents_map_); |
| 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(CalledOnValidThread()); |
| 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] = new Observer(this, preview_dialog); | 73 printing_contents_map_[preview_dialog] = new Observer(this, preview_dialog); |
| 74 | 74 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 std::set<content::WebContents*> result; | 124 std::set<content::WebContents*> result; |
| 125 for (WebContentsObserverMap::iterator i = printing_contents_map_.begin(); | 125 for (WebContentsObserverMap::iterator i = printing_contents_map_.begin(); |
| 126 i != printing_contents_map_.end(); ++i) { | 126 i != printing_contents_map_.end(); ++i) { |
| 127 result.insert(i->first); | 127 result.insert(i->first); |
| 128 } | 128 } |
| 129 return result; | 129 return result; |
| 130 } | 130 } |
| 131 | 131 |
| 132 bool BackgroundPrintingManager::HasPrintPreviewDialog( | 132 bool BackgroundPrintingManager::HasPrintPreviewDialog( |
| 133 WebContents* preview_dialog) { | 133 WebContents* preview_dialog) { |
| 134 return ContainsKey(printing_contents_map_, preview_dialog); | 134 return base::ContainsKey(printing_contents_map_, preview_dialog); |
| 135 } | 135 } |
| 136 | 136 |
| 137 } // namespace printing | 137 } // namespace printing |
| OLD | NEW |