| 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 // NotificationObserver overrides: | 45 // NotificationObserver overrides: |
| 53 virtual void Observe(int type, | 46 virtual void Observe(int type, |
| 54 const NotificationSource& source, | 47 const NotificationSource& source, |
| 55 const NotificationDetails& details) OVERRIDE; | 48 const 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 // The set of print preview tabs managed by BackgroundPrintingManager. | 56 // The set of print preview tabs managed by BackgroundPrintingManager. |
| 70 TabContentsWrapperSet printing_tabs_; | 57 TabContentsWrapperSet printing_tabs_; |
| 71 | 58 |
| 72 // 1:1 mapping between an initiator tab managed by BackgroundPrintingManager | |
| 73 // and its associated print preview tab. The print preview tab need not be in | |
| 74 // |printing_tabs_|. | |
| 75 // Key: print preview tab. | |
| 76 // Value: initiator tab. | |
| 77 TabContentsWrapperMap map_; | |
| 78 | |
| 79 NotificationRegistrar registrar_; | 59 NotificationRegistrar registrar_; |
| 80 | 60 |
| 81 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); | 61 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); |
| 82 }; | 62 }; |
| 83 | 63 |
| 84 } // namespace printing | 64 } // namespace printing |
| 85 | 65 |
| 86 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ | 66 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ |
| OLD | NEW |