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

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

Issue 7574002: Be able to print items that do window.print(); window.close() (airline tix e.g.) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addressed comments. Created 9 years, 4 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
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 <set> 9 #include <set>
10 10
11 #include "base/compiler_specific.h" 11 #include "base/compiler_specific.h"
12 #include "base/threading/non_thread_safe.h" 12 #include "base/threading/non_thread_safe.h"
13 #include "content/common/notification_observer.h" 13 #include "content/common/notification_observer.h"
14 #include "content/common/notification_registrar.h" 14 #include "content/common/notification_registrar.h"
15 15
16 class TabContentsWrapper; 16 class TabContentsWrapper;
17 17
18 namespace printing { 18 namespace printing {
19 19
20 // Manages hidden tabs that prints documents in the background. 20 // Manages hidden tabs that prints documents in the background.
21 // The hidden tabs are no longer part of any Browser / TabStripModel. 21 // The hidden tabs are no longer part of any Browser / TabStripModel.
22 // They get deleted when the tab finishes printing. 22 // They get deleted when the tab finishes printing.
23 class BackgroundPrintingManager 23 class BackgroundPrintingManager
24 : public base::NonThreadSafe, 24 : public base::NonThreadSafe,
25 public NotificationObserver { 25 public NotificationObserver {
26 public: 26 public:
27 typedef std::set<TabContentsWrapper*> TabContentsWrapperSet;
28
27 BackgroundPrintingManager(); 29 BackgroundPrintingManager();
28 virtual ~BackgroundPrintingManager(); 30 virtual ~BackgroundPrintingManager();
29 31
30 // Takes ownership of |content| and deletes it when |content| finishes 32 // Takes ownership of |content| and deletes it when |content| finishes
31 // printing. This removes the TabContentsWrapper from its TabStrip and 33 // printing. This removes the TabContentsWrapper from its TabStrip and
32 // hides it from the user. 34 // hides it from the user.
33 void OwnTabContents(TabContentsWrapper* content); 35 void OwnPreviewTabContents(TabContentsWrapper* content);
36
37 // Takes ownership of |content| and deletes it when its preview tab is
38 // destroyed by either being canceled, closed or finishing printing. This
39 // removes the TabContentsWrapper from its TabStrip and hides it from the
40 // user. Returns true if content has an associated print preview tab,
41 // otherwise, returns false and does not take ownership of |content|.
42 bool OwnInitiatorTabContents(TabContentsWrapper* content);
43
44 // Called when we no longer need to access the initiator tab, deletes if
45 // currently owned. Returns true when |content| was owned.
46 bool ReleaseInitiatorTabContents(TabContentsWrapper* content);
34 47
35 // Let others iterate over the list of background printing tabs. 48 // Let others iterate over the list of background printing tabs.
36 std::set<TabContentsWrapper*>::const_iterator begin(); 49 TabContentsWrapperSet::const_iterator begin();
37 std::set<TabContentsWrapper*>::const_iterator end(); 50 TabContentsWrapperSet::const_iterator end();
38 51
39 // Returns true if |printing_contents_| contains |entry|. 52 // Returns true if |printing_contents_| contains |entry|.
40 bool HasTabContents(TabContentsWrapper* entry); 53 bool HasTabContents(TabContentsWrapper* entry);
Lei Zhang 2011/08/26 10:01:54 Probably want to rename this to HasPreviewTabConte
Sheridan Rawlins 2011/08/26 23:45:39 Done.
41 54
42 // NotificationObserver overrides: 55 // NotificationObserver overrides:
43 virtual void Observe(int type, 56 virtual void Observe(int type,
44 const NotificationSource& source, 57 const NotificationSource& source,
45 const NotificationDetails& details) OVERRIDE; 58 const NotificationDetails& details) OVERRIDE;
46 59
47 private: 60 private:
61
62 // Called when the preview tab is going away to release the corresponding
63 // initiator tab. Returns true when the initiator content was owned.
64 bool ReleaseInitiatorForPreviewTabContents(
65 TabContentsWrapper* preview_content);
66
67 // Takes ownership of |content| in |wrapper_set| and deletes it when
68 // |source_content| is destroyed by either being canceled, closed or finishing
69 // printing. This removes the TabContentsWrapper from its TabStrip and hides
70 // it from the user.
71 void OwnTabContents(TabContentsWrapper* content,
72 TabContentsWrapper* source_content,
73 TabContentsWrapperSet* wrapper_set);
74
48 // The set of tabs managed by BackgroundPrintingManager. 75 // The set of tabs managed by BackgroundPrintingManager.
49 std::set<TabContentsWrapper*> printing_contents_; 76 TabContentsWrapperSet printing_contents_;
77
78 // The set of tabs managed by BackgroundPrintingManager.
Lei Zhang 2011/08/26 10:01:54 update comment
Sheridan Rawlins 2011/08/26 23:45:39 Done.
79 TabContentsWrapperSet initiator_contents_;
50 80
51 NotificationRegistrar registrar_; 81 NotificationRegistrar registrar_;
52 82
53 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager); 83 DISALLOW_COPY_AND_ASSIGN(BackgroundPrintingManager);
54 }; 84 };
55 85
56 } // namespace printing 86 } // namespace printing
57 87
58 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_ 88 #endif // CHROME_BROWSER_PRINTING_BACKGROUND_PRINTING_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698