Index: chrome/browser/printing/print_preview_tab_controller.h |
diff --git a/chrome/browser/printing/print_preview_tab_controller.h b/chrome/browser/printing/print_preview_tab_controller.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..af1d79f7d58c8b6e0196cf2c914542b73ab4a755 |
--- /dev/null |
+++ b/chrome/browser/printing/print_preview_tab_controller.h |
@@ -0,0 +1,86 @@ |
+// Copyright (c) 2010 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
+#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |
+#pragma once |
+ |
+#include <map> |
+ |
+#include "base/ref_counted.h" |
+#include "chrome/common/notification_registrar.h" |
+#include "chrome/common/notification_service.h" |
+ |
+class Browser; |
+class TabContents; |
+ |
+namespace printing { |
+ |
+// 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.
|
+class PrintPreviewTabController |
+ : public base::RefCounted<PrintPreviewTabController>, |
+ public NotificationObserver { |
+ public: |
+ static PrintPreviewTabController* GetInstance(); |
+ |
+ PrintPreviewTabController(); |
+ |
+ virtual ~PrintPreviewTabController(); |
+ |
+ // Get/Create the print preview tab for initiator_tab. |
+ // |browser_window_id| is used to identify |initiator_tab| browser window. |
+ 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.
|
+ TabContents* initiator_tab, int browser_window_id); |
+ |
+ private: |
+ friend class base::RefCounted<PrintPreviewTabController>; |
+ |
+ // Returns true if |tab| is a print preview tab. |
+ bool IsPrintPreviewTab(TabContents* tab); |
+ |
+ // Return the browser window with |browser_window_id|. |
+ Browser* GetBrowserWindow(int browser_window_id); |
+ |
+ // Return the initiator tab for |preview_tab| or return NULL. |
+ TabContents* GetInitiatorTab(TabContents* preview_tab); |
+ |
+ // Return preview tab for |initiator_tab| or return NULL. |
+ TabContents* GetPreviewTab(TabContents* initiator_tab); |
+ |
+ // Create a new print preview tab. |
+ TabContents* CreatePrintPreviewTab( |
+ TabContents* initiator_tab, int browser_window_id); |
+ |
+ // Add |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED) |
+ // observers. |
+ void AddObservers(TabContents* tab); |
+ |
+ // Remove |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED) |
+ // observers. |
+ void RemoveObservers(TabContents* tab); |
+ |
+ // Notification observer implementation. |
+ virtual void Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details); |
+ |
+ // Erase the map entry for |initiator_tab|. |
+ void EraseMapEntry(TabContents* initiator_tab); |
+ |
+ // 1:1 relationship between initiator tab and print preview tab. |
+ typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap; |
+ PrintPreviewTabMap preview_tab_map_; |
+ |
+ // A registrar for listening for TAB_CONTENTS_DESTROYED notification. |
+ NotificationRegistrar registrar_; |
+ |
+ // Are we waiting for a new preview tab with NavigationType::NEW_PAGE? If so, |
+ // do nothing in observer. |
+ bool waiting_for_new_preview_page_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); |
+}; |
+ |
+} // namespace printing |
Lei Zhang
2010/11/12 02:10:55
nit: 2 spaces after }
kmadhusu
2010/11/12 22:21:48
Done.
|
+#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |