Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6466)

Unified Diff: chrome/browser/printing/print_preview_tab_controller.h

Issue 4338001: Implement print preview tab controller. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Uploading my changes again. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..b931c033115094806d10db7784259cf4b4b6320b
--- /dev/null
+++ b/chrome/browser/printing/print_preview_tab_controller.h
@@ -0,0 +1,83 @@
+// 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
+// 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
+// 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.
+ 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 IsPrintPreviewTab(TabContents* tab);
Lei Zhang 2010/11/13 05:04:56 nit: Be consistent. Either name this IsPreviewTab(
kmadhusu 2010/11/15 21:22:27 Renamed IsPrintPreviewTab() to IsPreviewTab().
+
+ // 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);
Lei Zhang 2010/11/13 05:04:56 nit: |initiator_tab| is called "current_tab" in th
kmadhusu 2010/11/15 21:22:27 Done.
+
+ // Create a new print preview tab.
+ TabContents* CreatePrintPreviewTab(
+ TabContents* initiator_tab, int browser_window_id);
+
+ // Add/Remove observers for notifications from |tab|.
+ 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,
+ // do nothing in observer.
+ bool waiting_for_new_preview_page_;
+
+ DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController);
+};
+
+} // namespace printing
+#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_

Powered by Google App Engine
This is Rietveld 408576698