OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2010 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. | |
4 | |
5 #ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | |
6 #define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | |
7 #pragma once | |
8 | |
9 #include <map> | |
10 | |
11 #include "base/ref_counted.h" | |
12 #include "chrome/common/notification_registrar.h" | |
13 #include "chrome/common/notification_service.h" | |
14 | |
15 class Browser; | |
16 class TabContents; | |
17 | |
18 namespace printing { | |
19 | |
20 // This class manages print preview tabs and initiator tabs. | |
Lei Zhang
2010/11/12 02:10:55
You should definite what the initiator tab is and
kmadhusu
2010/11/12 22:21:48
Done.
| |
21 class PrintPreviewTabController | |
22 : public base::RefCounted<PrintPreviewTabController>, | |
23 public NotificationObserver { | |
24 public: | |
25 static PrintPreviewTabController* GetInstance(); | |
26 | |
27 PrintPreviewTabController(); | |
28 | |
29 virtual ~PrintPreviewTabController(); | |
30 | |
31 // Get/Create the print preview tab for initiator_tab. | |
32 // |browser_window_id| is used to identify |initiator_tab| browser window. | |
33 TabContents* get_print_preview_tab( | |
Lei Zhang
2010/11/12 02:10:55
nit: Method names should be LikeThis() not like_th
kmadhusu
2010/11/12 22:21:48
Done.
| |
34 TabContents* initiator_tab, int browser_window_id); | |
35 | |
36 private: | |
37 friend class base::RefCounted<PrintPreviewTabController>; | |
38 | |
39 // Returns true if |tab| is a print preview tab. | |
40 bool IsPrintPreviewTab(TabContents* tab); | |
41 | |
42 // Return the browser window with |browser_window_id|. | |
43 Browser* GetBrowserWindow(int browser_window_id); | |
44 | |
45 // Return the initiator tab for |preview_tab| or return NULL. | |
46 TabContents* GetInitiatorTab(TabContents* preview_tab); | |
47 | |
48 // Return preview tab for |initiator_tab| or return NULL. | |
49 TabContents* GetPreviewTab(TabContents* initiator_tab); | |
50 | |
51 // Create a new print preview tab. | |
52 TabContents* CreatePrintPreviewTab( | |
53 TabContents* initiator_tab, int browser_window_id); | |
54 | |
55 // Add |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED) | |
56 // observers. | |
57 void AddObservers(TabContents* tab); | |
58 | |
59 // Remove |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED) | |
60 // observers. | |
61 void RemoveObservers(TabContents* tab); | |
62 | |
63 // Notification observer implementation. | |
64 virtual void Observe(NotificationType type, | |
65 const NotificationSource& source, | |
66 const NotificationDetails& details); | |
67 | |
68 // Erase the map entry for |initiator_tab|. | |
69 void EraseMapEntry(TabContents* initiator_tab); | |
70 | |
71 // 1:1 relationship between initiator tab and print preview tab. | |
72 typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap; | |
73 PrintPreviewTabMap preview_tab_map_; | |
74 | |
75 // A registrar for listening for TAB_CONTENTS_DESTROYED notification. | |
76 NotificationRegistrar registrar_; | |
77 | |
78 // Are we waiting for a new preview tab with NavigationType::NEW_PAGE? If so, | |
79 // do nothing in observer. | |
80 bool waiting_for_new_preview_page_; | |
81 | |
82 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); | |
83 }; | |
84 | |
85 } // namespace printing | |
Lei Zhang
2010/11/12 02:10:55
nit: 2 spaces after }
kmadhusu
2010/11/12 22:21:48
Done.
| |
86 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | |
OLD | NEW |