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 should be linked with the | |
|
James Hawkins
2010/11/16 02:15:42
s/should be/is/
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 21 // initiator tab that initiated the printing operation. If the tab initiates | |
| 22 // a second printing operation while the first print preview tab is still open, | |
| 23 // that PP tab should be focused/activated. There may be more than one PP tab | |
| 24 // open. There is 1:1 relationship between PP tabs and initiating tabs. This | |
|
James Hawkins
2010/11/16 02:15:42
s/is 1:1/is a 1:1/
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 25 // class manages PP 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. | |
| 37 // |browser_window_id| is used to identify |initiator_tab| browser window. | |
|
James Hawkins
2010/11/16 02:15:42
"|browser_window_id| is the browser window contain
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 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 IsPreviewTab(TabContents* tab); | |
|
James Hawkins
2010/11/16 02:15:42
IsPrintPreviewTab
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 51 | |
| 52 // Return the initiator tab for |preview_tab| or return NULL. | |
|
James Hawkins
2010/11/16 02:15:42
Returns
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 53 TabContents* GetInitiatorTab(TabContents* preview_tab); | |
| 54 | |
| 55 // Return preview tab for |current_tab| or return NULL. | |
|
James Hawkins
2010/11/16 02:15:42
Returns
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 56 // If |current_tab| is preview tab return |current_tab|. | |
|
James Hawkins
2010/11/16 02:15:42
returns
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 57 TabContents* GetPreviewTab(TabContents* current_tab); | |
|
James Hawkins
2010/11/16 02:15:42
s/current/initiator/
Lei Zhang
2010/11/16 02:24:23
The tab being passed in is arbitrary. It is not al
James Hawkins
2010/11/16 02:27:15
Then "current" is also wrong and should be changed
James Hawkins
2010/11/16 02:27:15
Taking Lei's comment into account, I believe this
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 58 | |
| 59 // Create a new print preview tab. | |
|
James Hawkins
2010/11/16 02:15:42
Creates
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 60 TabContents* CreatePrintPreviewTab( | |
| 61 TabContents* initiator_tab, int browser_window_id); | |
| 62 | |
| 63 // Add/Remove observers for notifications from |tab|. | |
|
James Hawkins
2010/11/16 02:15:42
Adds/Removes
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 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. | |
| 74 NotificationRegistrar registrar_; | |
| 75 | |
| 76 // Are we waiting for a new preview tab with NavigationType::NEW_PAGE? If so, | |
|
James Hawkins
2010/11/16 02:15:42
It's best not to describe a member variable w/ a q
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 77 // do nothing in observer. | |
| 78 bool waiting_for_new_preview_page_; | |
| 79 | |
| 80 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); | |
| 81 }; | |
| 82 | |
| 83 } // namespace printing | |
|
James Hawkins
2010/11/16 02:15:42
Blank line after this.
kmadhusu
2010/11/16 18:16:09
Done.
| |
| 84 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ | |
| OLD | NEW |