Chromium Code Reviews| 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_observer.h" | |
| 13 #include "chrome/common/notification_registrar.h" | |
| 14 | |
| 15 class Browser; | |
| 16 class TabContents; | |
| 17 | |
| 18 namespace printing { | |
| 19 | |
| 20 // For print preview, a print preview (PP) tab is linked with the initiator tab | |
| 21 // that initiated the printing operation. If the tab initiates a second | |
| 22 // printing operation while the first print preview tab is still open, that PP | |
| 23 // tab is focused/activated. There may be more than one PP tab open. There is a | |
| 24 // 1:1 relationship between PP tabs and initiating tabs. This class manages PP | |
| 25 // tabs and initiator tabs. | |
| 26 class PrintPreviewTabController | |
| 27 : public base::RefCounted<PrintPreviewTabController>, | |
| 28 public NotificationObserver { | |
| 29 public: | |
| 30 static PrintPreviewTabController* GetInstance(); | |
| 31 | |
| 32 PrintPreviewTabController(); | |
| 33 | |
| 34 virtual ~PrintPreviewTabController(); | |
| 35 | |
| 36 // Get/Create the print preview tab for initiator_tab. | |
|
James Hawkins
2010/11/16 18:24:30
|initiator_tab|
kmadhusu
2010/11/16 18:41:42
Done.
| |
| 37 // |browser_window_id| is the browser window containing |initiator_tab|. | |
| 38 TabContents* GetOrCreatePreviewTab( | |
| 39 TabContents* initiator_tab, int browser_window_id); | |
| 40 | |
| 41 // Notification observer implementation. | |
| 42 virtual void Observe(NotificationType type, | |
| 43 const NotificationSource& source, | |
| 44 const NotificationDetails& details); | |
| 45 | |
| 46 private: | |
| 47 friend class base::RefCounted<PrintPreviewTabController>; | |
| 48 | |
| 49 // Returns true if |tab| is a print preview tab. | |
| 50 bool IsPrintPreviewTab(TabContents* tab); | |
| 51 | |
| 52 // Returns initiator tab for |preview_tab| or NULL. | |
|
James Hawkins
2010/11/16 18:24:30
or NULL when...?
kmadhusu
2010/11/16 18:41:42
Done.
| |
| 53 TabContents* GetInitiatorTab(TabContents* preview_tab); | |
| 54 | |
| 55 // Returns preview tab for |tab| or NULL. | |
|
James Hawkins
2010/11/16 18:24:30
or NULL when...?
kmadhusu
2010/11/16 18:41:42
Done.
| |
| 56 // Returns |tab| if |tab| is a preview tab. | |
| 57 TabContents* GetPrintPreviewForTab(TabContents* tab); | |
| 58 | |
| 59 // Creates a new print preview tab. | |
| 60 TabContents* CreatePrintPreviewTab( | |
| 61 TabContents* initiator_tab, int browser_window_id); | |
| 62 | |
| 63 // Adds/Removes observers for notifications from |tab|. | |
| 64 void AddObservers(TabContents* tab); | |
| 65 void RemoveObservers(TabContents* tab); | |
| 66 | |
| 67 // 1:1 relationship between initiator tab and print preview tab. | |
| 68 // Key: Preview tab. | |
| 69 // Value: Initiator tab. | |
| 70 typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap; | |
| 71 PrintPreviewTabMap preview_tab_map_; | |
| 72 | |
| 73 // A registrar for listening for TAB_CONTENTS_DESTROYED notification. | |
|
James Hawkins
2010/11/16 18:24:30
s/TAB_CONTENTS_DESTROYED //
"A registrar for list
kmadhusu
2010/11/16 18:41:42
Done.
| |
| 74 NotificationRegistrar registrar_; | |
| 75 | |
| 76 // True if the controller is waiting for a new preview tab via | |
| 77 // NavigationType::NEW_PAGE. | |
| 78 bool waiting_for_new_preview_page_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); | |
| 81 }; | |
| 82 | |
| 83 } // namespace printing | |
| 84 | |
| 85 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | |
| OLD | NEW |