| 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 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| 6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <set> | 10 #include <set> |
| 11 | 11 |
| 12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
| 13 #include "base/macros.h" | 13 #include "base/macros.h" |
| 14 #include "base/threading/non_thread_safe.h" | 14 #include "base/sequence_checker.h" |
| 15 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 | 17 |
| 18 namespace content { | 18 namespace content { |
| 19 class WebContents; | 19 class WebContents; |
| 20 class BrowserContext; | 20 class BrowserContext; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace printing { | 23 namespace printing { |
| 24 | 24 |
| 25 // Manages hidden WebContents that prints documents in the background. | 25 // Manages hidden WebContents that prints documents in the background. |
| 26 // The hidden WebContents are no longer part of any Browser / TabStripModel. | 26 // The hidden WebContents are no longer part of any Browser / TabStripModel. |
| 27 // The WebContents started life as a ConstrainedWebDialog. | 27 // The WebContents started life as a ConstrainedWebDialog. |
| 28 // They get deleted when the printing finishes. | 28 // They get deleted when the printing finishes. |
| 29 class BackgroundPrintingManager : public base::NonThreadSafe, | 29 class BackgroundPrintingManager : public content::NotificationObserver { |
| 30 public content::NotificationObserver { | |
| 31 public: | 30 public: |
| 32 class Observer; | 31 class Observer; |
| 33 | 32 |
| 34 BackgroundPrintingManager(); | 33 BackgroundPrintingManager(); |
| 35 ~BackgroundPrintingManager() override; | 34 ~BackgroundPrintingManager() override; |
| 36 | 35 |
| 37 // Takes ownership of |preview_dialog| and deletes it when |preview_dialog| | 36 // Takes ownership of |preview_dialog| and deletes it when |preview_dialog| |
| 38 // finishes printing. This removes |preview_dialog| from its ConstrainedDialog | 37 // finishes printing. This removes |preview_dialog| from its ConstrainedDialog |
| 39 // and hides it from the user. | 38 // and hides it from the user. |
| 40 void OwnPrintPreviewDialog(content::WebContents* preview_dialog); | 39 void OwnPrintPreviewDialog(content::WebContents* preview_dialog); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 58 // Schedule deletion of |preview_contents|. | 57 // Schedule deletion of |preview_contents|. |
| 59 void DeletePreviewContents(content::WebContents* preview_contents); | 58 void DeletePreviewContents(content::WebContents* preview_contents); |
| 60 | 59 |
| 61 // A map from print preview WebContentses (managed by | 60 // A map from print preview WebContentses (managed by |
| 62 // BackgroundPrintingManager) to the Observers that observe them. | 61 // BackgroundPrintingManager) to the Observers that observe them. |
| 63 std::map<content::WebContents*, std::unique_ptr<Observer>> | 62 std::map<content::WebContents*, std::unique_ptr<Observer>> |
| 64 printing_contents_map_; | 63 printing_contents_map_; |
| 65 | 64 |
| 66 content::NotificationRegistrar registrar_; | 65 content::NotificationRegistrar registrar_; |
| 67 | 66 |
| 67 SEQUENCE_CHECKER(sequence_checker_); |
| 68 |
| 68 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); | 69 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); |
| 69 }; | 70 }; |
| 70 | 71 |
| 71 } // namespace printing | 72 } // namespace printing |
| 72 | 73 |
| 73 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 74 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| OLD | NEW |