| 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 // For print preview, a print preview (PP) tab is linked with the initiator tab | 5 // For print preview, a print preview (PP) tab is linked with the initiator tab |
| 6 // that initiated the printing operation. If the tab initiates a second | 6 // that initiated the printing operation. If the tab initiates a second |
| 7 // printing operation while the first print preview tab is still open, that PP | 7 // printing operation while the first print preview tab is still open, that PP |
| 8 // tab is focused/activated. There may be more than one PP tab open. There is a | 8 // tab is focused/activated. There may be more than one PP tab open. There is a |
| 9 // 1:1 relationship between PP tabs and initiating tabs. This class manages PP | 9 // 1:1 relationship between PP tabs and initiating tabs. This class manages PP |
| 10 // tabs and initiator tabs. | 10 // tabs and initiator tabs. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace printing { | 31 namespace printing { |
| 32 | 32 |
| 33 class PrintPreviewTabController | 33 class PrintPreviewTabController |
| 34 : public base::RefCounted<PrintPreviewTabController>, | 34 : public base::RefCounted<PrintPreviewTabController>, |
| 35 public content::NotificationObserver { | 35 public content::NotificationObserver { |
| 36 public: | 36 public: |
| 37 PrintPreviewTabController(); | 37 PrintPreviewTabController(); |
| 38 | 38 |
| 39 virtual ~PrintPreviewTabController(); | |
| 40 | |
| 41 static PrintPreviewTabController* GetInstance(); | 39 static PrintPreviewTabController* GetInstance(); |
| 42 | 40 |
| 43 // Initiate print preview for |initiator_tab|. | 41 // Initiate print preview for |initiator_tab|. |
| 44 // Call this instead of GetOrCreatePreviewTab(). | 42 // Call this instead of GetOrCreatePreviewTab(). |
| 45 static void PrintPreview(TabContentsWrapper* initiator_tab); | 43 static void PrintPreview(TabContentsWrapper* initiator_tab); |
| 46 | 44 |
| 47 // Get/Create the print preview tab for |initiator_tab|. | 45 // Get/Create the print preview tab for |initiator_tab|. |
| 48 // Exposed for unit tests. | 46 // Exposed for unit tests. |
| 49 TabContentsWrapper* GetOrCreatePreviewTab(TabContentsWrapper* initiator_tab); | 47 TabContentsWrapper* GetOrCreatePreviewTab(TabContentsWrapper* initiator_tab); |
| 50 | 48 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 74 bool is_creating_print_preview_tab() const; | 72 bool is_creating_print_preview_tab() const; |
| 75 | 73 |
| 76 private: | 74 private: |
| 77 friend class base::RefCounted<PrintPreviewTabController>; | 75 friend class base::RefCounted<PrintPreviewTabController>; |
| 78 | 76 |
| 79 // 1:1 relationship between initiator tab and print preview tab. | 77 // 1:1 relationship between initiator tab and print preview tab. |
| 80 // Key: Preview tab. | 78 // Key: Preview tab. |
| 81 // Value: Initiator tab. | 79 // Value: Initiator tab. |
| 82 typedef std::map<TabContentsWrapper*, TabContentsWrapper*> PrintPreviewTabMap; | 80 typedef std::map<TabContentsWrapper*, TabContentsWrapper*> PrintPreviewTabMap; |
| 83 | 81 |
| 82 virtual ~PrintPreviewTabController(); |
| 83 |
| 84 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when | 84 // Handler for the RENDERER_PROCESS_CLOSED notification. This is observed when |
| 85 // the initiator renderer crashed. | 85 // the initiator renderer crashed. |
| 86 void OnRendererProcessClosed(content::RenderProcessHost* rph); | 86 void OnRendererProcessClosed(content::RenderProcessHost* rph); |
| 87 | 87 |
| 88 // Handler for the TAB_CONTENTS_DESTROYED notification. This is observed when | 88 // Handler for the TAB_CONTENTS_DESTROYED notification. This is observed when |
| 89 // either tab is closed. | 89 // either tab is closed. |
| 90 void OnTabContentsDestroyed(TabContentsWrapper* tab); | 90 void OnTabContentsDestroyed(TabContentsWrapper* tab); |
| 91 | 91 |
| 92 // Handler for the NAV_ENTRY_COMMITTED notification. This is observed when the | 92 // Handler for the NAV_ENTRY_COMMITTED notification. This is observed when the |
| 93 // renderer is navigated to a different page. | 93 // renderer is navigated to a different page. |
| (...skipping 29 matching lines...) Expand all Loading... |
| 123 // Whether the PrintPreviewTabController is in the middle of creating a | 123 // Whether the PrintPreviewTabController is in the middle of creating a |
| 124 // print preview tab. | 124 // print preview tab. |
| 125 bool is_creating_print_preview_tab_; | 125 bool is_creating_print_preview_tab_; |
| 126 | 126 |
| 127 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); | 127 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); |
| 128 }; | 128 }; |
| 129 | 129 |
| 130 } // namespace printing | 130 } // namespace printing |
| 131 | 131 |
| 132 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | 132 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
| OLD | NEW |