OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 17 matching lines...) Expand all Loading... |
28 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet; | 28 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet; |
29 | 29 |
30 BackgroundPrintingManager(); | 30 BackgroundPrintingManager(); |
31 virtual ~BackgroundPrintingManager(); | 31 virtual ~BackgroundPrintingManager(); |
32 | 32 |
33 // Takes ownership of |preview_tab| and deletes it when |preview_tab| finishes | 33 // Takes ownership of |preview_tab| and deletes it when |preview_tab| finishes |
34 // printing. This removes the TabContentsWrapper from its TabStrip and | 34 // printing. This removes the TabContentsWrapper from its TabStrip and |
35 // hides it from the user. | 35 // hides it from the user. |
36 void OwnPrintPreviewTab(TabContentsWrapper* preview_tab); | 36 void OwnPrintPreviewTab(TabContentsWrapper* preview_tab); |
37 | 37 |
38 // Takes ownership of |initiator_tab| and deletes it when its preview tab is | |
39 // destroyed by either being canceled, closed or finishing printing. This | |
40 // removes the TabContentsWrapper from its TabStrip and hides it from the | |
41 // user. Returns true if content has an associated print preview tab, | |
42 // otherwise, returns false and does not take ownership of |initiator_tab|. | |
43 bool OwnInitiatorTab(TabContentsWrapper* initiator_tab); | |
44 | |
45 // Let others iterate over the list of background printing tabs. | 38 // Let others iterate over the list of background printing tabs. |
46 TabContentsWrapperSet::const_iterator begin(); | 39 TabContentsWrapperSet::const_iterator begin(); |
47 TabContentsWrapperSet::const_iterator end(); | 40 TabContentsWrapperSet::const_iterator end(); |
48 | 41 |
49 // Returns true if |printing_tabs_| contains |preview_tab|. | 42 // Returns true if |printing_tabs_| contains |preview_tab|. |
50 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab); | 43 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab); |
51 | 44 |
52 // content::NotificationObserver overrides: | 45 // content::NotificationObserver overrides: |
53 virtual void Observe(int type, | 46 virtual void Observe(int type, |
54 const content::NotificationSource& source, | 47 const content::NotificationSource& source, |
55 const content::NotificationDetails& details) OVERRIDE; | 48 const content::NotificationDetails& details) OVERRIDE; |
56 | 49 |
57 private: | 50 private: |
58 typedef std::map<TabContentsWrapper*, TabContentsWrapper*> | |
59 TabContentsWrapperMap; | |
60 | |
61 // Notifications handlers. | 51 // Notifications handlers. |
62 void OnRendererProcessClosed(RenderProcessHost* rph); | 52 void OnRendererProcessClosed(RenderProcessHost* rph); |
63 void OnPrintJobReleased(TabContentsWrapper* preview_tab); | 53 void OnPrintJobReleased(TabContentsWrapper* preview_tab); |
64 void OnTabContentsDestroyed(TabContentsWrapper* preview_tab); | 54 void OnTabContentsDestroyed(TabContentsWrapper* preview_tab); |
65 | 55 |
66 // Removes |tab| from its tab strip. | |
67 void RemoveFromTabStrip(TabContentsWrapper* tab); | |
68 | |
69 // Add |tab| to the pending deletion set and schedule deletion. | 56 // Add |tab| to the pending deletion set and schedule deletion. |
70 void DeletePreviewTab(TabContentsWrapper* tab); | 57 void DeletePreviewTab(TabContentsWrapper* tab); |
71 | 58 |
72 // Check if any of the TabContentsWrappers in |set| share a RenderProcessHost | 59 // Check if any of the TabContentsWrappers in |set| share a RenderProcessHost |
73 // with |tab|, excluding |tab|. | 60 // with |tab|, excluding |tab|. |
74 bool HasSharedRenderProcessHost(const TabContentsWrapperSet& set, | 61 bool HasSharedRenderProcessHost(const TabContentsWrapperSet& set, |
75 TabContentsWrapper* tab); | 62 TabContentsWrapper* tab); |
76 | 63 |
77 // The set of print preview tabs managed by BackgroundPrintingManager. | 64 // The set of print preview tabs managed by BackgroundPrintingManager. |
78 TabContentsWrapperSet printing_tabs_; | 65 TabContentsWrapperSet printing_tabs_; |
79 | 66 |
80 // The set of print preview tabs managed by BackgroundPrintingManager that | 67 // The set of print preview tabs managed by BackgroundPrintingManager that |
81 // are pending deletion. | 68 // are pending deletion. |
82 TabContentsWrapperSet printing_tabs_pending_deletion_; | 69 TabContentsWrapperSet printing_tabs_pending_deletion_; |
83 | 70 |
84 // 1:1 mapping between an initiator tab managed by BackgroundPrintingManager | |
85 // and its associated print preview tab. The print preview tab need not be in | |
86 // |printing_tabs_|. | |
87 // Key: print preview tab. | |
88 // Value: initiator tab. | |
89 TabContentsWrapperMap map_; | |
90 | |
91 content::NotificationRegistrar registrar_; | 71 content::NotificationRegistrar registrar_; |
92 | 72 |
93 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); | 73 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); |
94 }; | 74 }; |
95 | 75 |
96 } // namespace printing | 76 } // namespace printing |
97 | 77 |
98 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 78 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
OLD | NEW |