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..6115ddc7631021f81f0524e7bbe63a265667dacd |
--- /dev/null |
+++ b/chrome/browser/printing/print_preview_tab_controller.h |
@@ -0,0 +1,84 @@ |
+// 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_observer.h" |
+#include "chrome/common/notification_registrar.h" |
+ |
+class Browser; |
+class TabContents; |
+ |
+namespace printing { |
+ |
+// 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.
|
+// initiator tab that initiated the printing operation. If the tab initiates |
+// a second printing operation while the first print preview tab is still open, |
+// that PP tab should be focused/activated. There may be more than one PP tab |
+// 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.
|
+// class manages PP tabs and initiator tabs. |
+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. |
James Hawkins
2010/11/16 02:15:42
"|browser_window_id| is the browser window contain
kmadhusu
2010/11/16 18:16:09
Done.
|
+ TabContents* GetOrCreatePreviewTab( |
+ TabContents* initiator_tab, int browser_window_id); |
+ |
+ // Notification observer implementation. |
+ virtual void Observe(NotificationType type, |
+ const NotificationSource& source, |
+ const NotificationDetails& details); |
+ |
+ private: |
+ friend class base::RefCounted<PrintPreviewTabController>; |
+ |
+ // Returns true if |tab| is a print preview tab. |
+ bool IsPreviewTab(TabContents* tab); |
James Hawkins
2010/11/16 02:15:42
IsPrintPreviewTab
kmadhusu
2010/11/16 18:16:09
Done.
|
+ |
+ // 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.
|
+ TabContents* GetInitiatorTab(TabContents* preview_tab); |
+ |
+ // 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.
|
+ // 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.
|
+ 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.
|
+ |
+ // Create a new print preview tab. |
James Hawkins
2010/11/16 02:15:42
Creates
kmadhusu
2010/11/16 18:16:09
Done.
|
+ TabContents* CreatePrintPreviewTab( |
+ TabContents* initiator_tab, int browser_window_id); |
+ |
+ // 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.
|
+ void AddObservers(TabContents* tab); |
+ void RemoveObservers(TabContents* tab); |
+ |
+ // 1:1 relationship between initiator tab and print preview tab. |
+ // Key: Preview tab. |
+ // Value: Initiator 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, |
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.
|
+ // do nothing in observer. |
+ bool waiting_for_new_preview_page_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController); |
+}; |
+ |
+} // namespace printing |
James Hawkins
2010/11/16 02:15:42
Blank line after this.
kmadhusu
2010/11/16 18:16:09
Done.
|
+#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_ |