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

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: Made code changes as per comments. 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 should be linked with the
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
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.
38 TabContents* GetOrCreatePreviewTab(
39 TabContents* initiator_tab, int browser_window_id);
40
41 private:
42 friend class base::RefCounted<PrintPreviewTabController>;
43
44 // Returns true if |tab| is a print preview tab.
45 bool IsPrintPreviewTab(TabContents* tab);
46
47 // Return the browser window with |browser_window_id|.
48 Browser* GetBrowserWindow(int browser_window_id);
Lei Zhang 2010/11/12 23:17:18 This is a one line private method that's only call
kmadhusu 2010/11/13 00:05:59 Removed.
49
50 // Return the initiator tab for |preview_tab| or return NULL.
51 TabContents* GetInitiatorTab(TabContents* preview_tab);
52
53 // Return preview tab for |initiator_tab| or return NULL.
54 TabContents* GetPreviewTab(TabContents* initiator_tab);
55
56 // Create a new print preview tab.
57 TabContents* CreatePrintPreviewTab(
58 TabContents* initiator_tab, int browser_window_id);
59
60 // Add |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED)
Lei Zhang 2010/11/12 23:48:40 nit: Just combine the comments for Add and RemoveO
kmadhusu 2010/11/13 00:05:59 Done.
61 // observers.
62 void AddObservers(TabContents* tab);
63
64 // Remove |tab| notification(TAB_CONTENTS_DESTROYED & NAV_ENTRY_COMMITTED)
65 // observers.
66 void RemoveObservers(TabContents* tab);
67
68 // Notification observer implementation.
69 virtual void Observe(NotificationType type,
Lei Zhang 2010/11/12 23:48:40 this needs to be public.
kmadhusu 2010/11/13 00:05:59 Done.
70 const NotificationSource& source,
71 const NotificationDetails& details);
72
73 // Erase the map entry for |initiator_tab|.
74 void EraseMapEntry(TabContents* initiator_tab);
Lei Zhang 2010/11/12 23:48:40 again, why have a private, one line method that's
kmadhusu 2010/11/13 00:05:59 Removed.
75
76 // 1:1 relationship between initiator tab and print preview tab.
Lei Zhang 2010/11/12 23:17:18 You should state which type of tabs is the key and
kmadhusu 2010/11/13 00:05:59 Done.
77 typedef std::map<TabContents*, TabContents*> PrintPreviewTabMap;
78 PrintPreviewTabMap preview_tab_map_;
79
80 // A registrar for listening for TAB_CONTENTS_DESTROYED notification.
81 NotificationRegistrar registrar_;
82
83 // Are we waiting for a new preview tab with NavigationType::NEW_PAGE? If so,
84 // do nothing in observer.
85 bool waiting_for_new_preview_page_;
86
87 DISALLOW_COPY_AND_ASSIGN(PrintPreviewTabController);
88 };
89
90 } // namespace printing
91 #endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_TAB_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698