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. |
11 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | 11 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
12 | 12 |
13 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | 13 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
14 #pragma once | 14 #pragma once |
15 | 15 |
16 #include <map> | 16 #include <map> |
17 | 17 |
18 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
19 #include "chrome/browser/sessions/session_id.h" | 19 #include "chrome/browser/sessions/session_id.h" |
20 #include "content/common/notification_observer.h" | 20 #include "content/common/notification_observer.h" |
21 #include "content/common/notification_registrar.h" | 21 #include "content/common/notification_registrar.h" |
22 | 22 |
23 class Browser; | 23 class Browser; |
| 24 class GURL; |
24 class RenderProcessHost; | 25 class RenderProcessHost; |
25 class TabContentsWrapper; | 26 class TabContentsWrapper; |
26 | 27 |
27 namespace content { | 28 namespace content { |
28 struct LoadCommittedDetails; | 29 struct LoadCommittedDetails; |
29 } | 30 } |
30 | 31 |
31 namespace printing { | 32 namespace printing { |
32 | 33 |
33 class PrintPreviewTabController | 34 class PrintPreviewTabController |
(...skipping 24 matching lines...) Expand all Loading... |
58 TabContentsWrapper* GetInitiatorTab(TabContentsWrapper* preview_tab); | 59 TabContentsWrapper* GetInitiatorTab(TabContentsWrapper* preview_tab); |
59 | 60 |
60 // NotificationObserver implementation. | 61 // NotificationObserver implementation. |
61 virtual void Observe(int type, | 62 virtual void Observe(int type, |
62 const NotificationSource& source, | 63 const NotificationSource& source, |
63 const NotificationDetails& details); | 64 const NotificationDetails& details); |
64 | 65 |
65 // Returns true if |tab| is a print preview tab. | 66 // Returns true if |tab| is a print preview tab. |
66 static bool IsPrintPreviewTab(TabContentsWrapper* tab); | 67 static bool IsPrintPreviewTab(TabContentsWrapper* tab); |
67 | 68 |
| 69 // Returns true if |url| is a print preview url. |
| 70 static bool IsPrintPreviewURL(const GURL& url); |
| 71 |
68 // Erase the initiator tab info associated with |preview_tab|. | 72 // Erase the initiator tab info associated with |preview_tab|. |
69 void EraseInitiatorTabInfo(TabContentsWrapper* preview_tab); | 73 void EraseInitiatorTabInfo(TabContentsWrapper* preview_tab); |
70 | 74 |
71 private: | 75 private: |
72 friend class base::RefCounted<PrintPreviewTabController>; | 76 friend class base::RefCounted<PrintPreviewTabController>; |
73 | 77 |
74 // 1:1 relationship between initiator tab and print preview tab. | 78 // 1:1 relationship between initiator tab and print preview tab. |
75 // Key: Preview tab. | 79 // Key: Preview tab. |
76 // Value: Initiator tab. | 80 // Value: Initiator tab. |
77 typedef std::map<TabContentsWrapper*, TabContentsWrapper*> PrintPreviewTabMap; | 81 typedef std::map<TabContentsWrapper*, TabContentsWrapper*> PrintPreviewTabMap; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // True if the controller is waiting for a new preview tab via | 113 // True if the controller is waiting for a new preview tab via |
110 // NavigationType::NEW_PAGE. | 114 // NavigationType::NEW_PAGE. |
111 bool waiting_for_new_preview_page_; | 115 bool waiting_for_new_preview_page_; |
112 | 116 |
113 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); | 117 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); |
114 }; | 118 }; |
115 | 119 |
116 } // namespace printing | 120 } // namespace printing |
117 | 121 |
118 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | 122 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
OLD | NEW |