No dual_mode on Win10+ shortcuts.
[chromium-blink-merge.git] / chrome / browser / printing / background_printing_manager.h
blobfdcc952bf0c7c5f74e26dc428e46292a52a395a7
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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
8 #include <map>
9 #include <set>
11 #include "base/compiler_specific.h"
12 #include "base/threading/non_thread_safe.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 namespace content {
17 class RenderProcessHost;
18 class WebContents;
21 namespace printing {
23 // Manages hidden WebContents that prints documents in the background.
24 // The hidden WebContents are no longer part of any Browser / TabStripModel.
25 // The WebContents started life as a ConstrainedWebDialog.
26 // They get deleted when the printing finishes.
27 class BackgroundPrintingManager : public base::NonThreadSafe,
28 public content::NotificationObserver {
29 public:
30 class Observer;
31 typedef std::map<content::WebContents*, Observer*> WebContentsObserverMap;
33 BackgroundPrintingManager();
34 ~BackgroundPrintingManager() override;
36 // Takes ownership of |preview_dialog| and deletes it when |preview_dialog|
37 // finishes printing. This removes |preview_dialog| from its ConstrainedDialog
38 // and hides it from the user.
39 void OwnPrintPreviewDialog(content::WebContents* preview_dialog);
41 // Returns true if |printing_contents_map_| contains |preview_dialog|.
42 bool HasPrintPreviewDialog(content::WebContents* preview_dialog);
44 // Let others see the list of background printing contents.
45 std::set<content::WebContents*> CurrentContentSet();
47 private:
48 // content::NotificationObserver overrides:
49 void Observe(int type,
50 const content::NotificationSource& source,
51 const content::NotificationDetails& details) override;
53 // Schedule deletion of |preview_contents|.
54 void DeletePreviewContents(content::WebContents* preview_contents);
56 // A map from print preview WebContentses (managed by
57 // BackgroundPrintingManager) to the Observers that observe them.
58 WebContentsObserverMap printing_contents_map_;
60 content::NotificationRegistrar registrar_;
62 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager);
65 } // namespace printing
67 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_