| 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" |
| 8 #include "base/single_thread_task_runner.h" |
| 7 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" |
| 8 #include "chrome/browser/chrome_notification_types.h" | 11 #include "chrome/browser/chrome_notification_types.h" |
| 9 #include "chrome/browser/printing/print_job.h" | 12 #include "chrome/browser/printing/print_job.h" |
| 10 #include "chrome/browser/printing/print_preview_dialog_controller.h" | 13 #include "chrome/browser/printing/print_preview_dialog_controller.h" |
| 11 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 12 #include "content/public/browser/notification_details.h" | 15 #include "content/public/browser/notification_details.h" |
| 13 #include "content/public/browser/notification_source.h" | 16 #include "content/public/browser/notification_source.h" |
| 14 #include "content/public/browser/render_view_host.h" | 17 #include "content/public/browser/render_view_host.h" |
| 15 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
| 16 #include "content/public/browser/web_contents_delegate.h" | 19 #include "content/public/browser/web_contents_delegate.h" |
| 17 #include "content/public/browser/web_contents_observer.h" | 20 #include "content/public/browser/web_contents_observer.h" |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 110 |
| 108 // Stop all observation ... | 111 // Stop all observation ... |
| 109 registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, | 112 registrar_.Remove(this, chrome::NOTIFICATION_PRINT_JOB_RELEASED, |
| 110 content::Source<WebContents>(preview_contents)); | 113 content::Source<WebContents>(preview_contents)); |
| 111 Observer* observer = i->second; | 114 Observer* observer = i->second; |
| 112 printing_contents_map_.erase(i); | 115 printing_contents_map_.erase(i); |
| 113 delete observer; | 116 delete observer; |
| 114 | 117 |
| 115 // ... and mortally wound the contents. (Deletion immediately is not a good | 118 // ... and mortally wound the contents. (Deletion immediately is not a good |
| 116 // idea in case this was called from RenderViewGone.) | 119 // idea in case this was called from RenderViewGone.) |
| 117 base::MessageLoop::current()->DeleteSoon(FROM_HERE, preview_contents); | 120 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, preview_contents); |
| 118 } | 121 } |
| 119 | 122 |
| 120 std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() { | 123 std::set<content::WebContents*> BackgroundPrintingManager::CurrentContentSet() { |
| 121 std::set<content::WebContents*> result; | 124 std::set<content::WebContents*> result; |
| 122 for (WebContentsObserverMap::iterator i = printing_contents_map_.begin(); | 125 for (WebContentsObserverMap::iterator i = printing_contents_map_.begin(); |
| 123 i != printing_contents_map_.end(); ++i) { | 126 i != printing_contents_map_.end(); ++i) { |
| 124 result.insert(i->first); | 127 result.insert(i->first); |
| 125 } | 128 } |
| 126 return result; | 129 return result; |
| 127 } | 130 } |
| 128 | 131 |
| 129 bool BackgroundPrintingManager::HasPrintPreviewDialog( | 132 bool BackgroundPrintingManager::HasPrintPreviewDialog( |
| 130 WebContents* preview_dialog) { | 133 WebContents* preview_dialog) { |
| 131 return ContainsKey(printing_contents_map_, preview_dialog); | 134 return ContainsKey(printing_contents_map_, preview_dialog); |
| 132 } | 135 } |
| 133 | 136 |
| 134 } // namespace printing | 137 } // namespace printing |
| OLD | NEW |