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

Side by Side Diff: chrome/browser/printing/background_printing_manager.h

Issue 7800036: Print Preview: Hold on to tabs that do window.print(); window.close() until print preview finishes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months 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
« no previous file with comments | « no previous file | chrome/browser/printing/background_printing_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ 6 #define CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
9 #include <set> 10 #include <set>
10 11
11 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
12 #include "base/threading/non_thread_safe.h" 13 #include "base/threading/non_thread_safe.h"
13 #include "content/common/notification_observer.h" 14 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h" 15 #include "content/common/notification_registrar.h"
15 16
17 class RenderProcessHost;
16 class TabContentsWrapper; 18 class TabContentsWrapper;
17 19
18 namespace printing { 20 namespace printing {
19 21
20 // Manages hidden tabs that prints documents in the background. 22 // Manages hidden tabs that prints documents in the background.
21 // The hidden tabs are no longer part of any Browser / TabStripModel. 23 // The hidden tabs are no longer part of any Browser / TabStripModel.
22 // They get deleted when the tab finishes printing. 24 // They get deleted when the tab finishes printing.
23 class BackgroundPrintingManager : public base::NonThreadSafe, 25 class BackgroundPrintingManager : public base::NonThreadSafe,
24 public NotificationObserver { 26 public NotificationObserver {
25 public: 27 public:
26 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet; 28 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet;
27 29
28 BackgroundPrintingManager(); 30 BackgroundPrintingManager();
29 virtual ~BackgroundPrintingManager(); 31 virtual ~BackgroundPrintingManager();
30 32
31 // Takes ownership of |preview_tab| and deletes it when |preview_tab| finishes 33 // Takes ownership of |preview_tab| and deletes it when |preview_tab| finishes
32 // printing. This removes the TabContentsWrapper from its TabStrip and 34 // printing. This removes the TabContentsWrapper from its TabStrip and
33 // hides it from the user. 35 // hides it from the user.
34 void OwnPrintPreviewTab(TabContentsWrapper* preview_tab); 36 void OwnPrintPreviewTab(TabContentsWrapper* preview_tab);
35 37
38 // Takes ownership of |initiator_tab| and deletes it when its preview tab is
39 // destroyed by either being canceled, closed or finishing printing. This
40 // removes the TabContentsWrapper from its TabStrip and hides it from the
41 // user. Returns true if content has an associated print preview tab,
42 // otherwise, returns false and does not take ownership of |initiator_tab|.
43 bool OwnInitiatorTab(TabContentsWrapper* initiator_tab);
44
36 // Let others iterate over the list of background printing tabs. 45 // Let others iterate over the list of background printing tabs.
37 TabContentsWrapperSet::const_iterator begin(); 46 TabContentsWrapperSet::const_iterator begin();
38 TabContentsWrapperSet::const_iterator end(); 47 TabContentsWrapperSet::const_iterator end();
39 48
40 // Returns true if |printing_tabs_| contains |preview_tab|. 49 // Returns true if |printing_tabs_| contains |preview_tab|.
41 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab); 50 bool HasPrintPreviewTab(TabContentsWrapper* preview_tab);
42 51
43 // NotificationObserver overrides: 52 // NotificationObserver overrides:
44 virtual void Observe(int type, 53 virtual void Observe(int type,
45 const NotificationSource& source, 54 const NotificationSource& source,
46 const NotificationDetails& details) OVERRIDE; 55 const NotificationDetails& details) OVERRIDE;
47 56
48 private: 57 private:
58 typedef std::map<TabContentsWrapper*, TabContentsWrapper*>
59 TabContentsWrapperMap;
60
61 // Notifications handlers.
62 void OnRendererProcessClosed(RenderProcessHost* rph);
63 void OnPrintJobReleased(TabContentsWrapper* preview_tab);
64 void OnTabContentsDestroyed(TabContentsWrapper* preview_tab);
65
66 // Removes |tab| from its tab strip.
67 void RemoveFromTabStrip(TabContentsWrapper* tab);
68
49 // The set of print preview tabs managed by BackgroundPrintingManager. 69 // The set of print preview tabs managed by BackgroundPrintingManager.
50 TabContentsWrapperSet printing_tabs_; 70 TabContentsWrapperSet printing_tabs_;
51 71
72 // 1:1 mapping between an initiator tab managed by BackgroundPrintingManager
73 // and its associated print preview tab. The print preview tab need not be in
74 // |printing_tabs_|.
75 // Key: print preview tab.
76 // Value: initiator tab.
77 TabContentsWrapperMap map_;
78
52 NotificationRegistrar registrar_; 79 NotificationRegistrar registrar_;
53 80
54 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); 81 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager);
55 }; 82 };
56 83
57 } // namespace printing 84 } // namespace printing
58 85
59 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ 86 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/background_printing_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698