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

Side by Side 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: '' 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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|.
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|.
53 // Returns NULL if no initiator tab exists for |preview_tab|.
54 TabContents* GetInitiatorTab(TabContents* preview_tab);
55
56 // Returns preview tab for |tab|.
57 // Returns |tab| if |tab| is a preview tab.
58 // Returns NULL if no preview tab exists for |tab|.
59 TabContents* GetPrintPreviewForTab(TabContents* tab);
60
61 // Creates a new print preview tab.
62 TabContents* CreatePrintPreviewTab(
63 TabContents* initiator_tab, int browser_window_id);
64
65 // Adds/Removes observers for notifications from |tab|.
66 void AddObservers(TabContents* tab);
67 void RemoveObservers(TabContents* tab);
68
69 // 1:1 relationship between initiator tab and print preview tab.
70 // Key: Preview tab.
71 // Value: Initiator tab.
72 typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap;
73 PrintPreviewTabMap preview_tab_map_;
74
75 // A registrar for listening notifications.
76 NotificationRegistrar registrar_;
77
78 // True if the controller is waiting for a new preview tab via
79 // NavigationType::NEW_PAGE.
80 bool waiting_for_new_preview_page_;
81
82 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController);
83 };
84
85 } // namespace printing
86
87 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_
OLDNEW
« no previous file with comments | « chrome/browser/browser_process_impl.cc ('k') | chrome/browser/printing/print_preview_tab_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698