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

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

Issue 10911351: Switch PrintViewManager, PrintPreviewMessageHandler to use WebContentsUserData. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, fix typo Created 8 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_PRINT_VIEW_MANAGER_H_ 5 #ifndef CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 6 #define CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
7 7
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/string16.h" 9 #include "base/string16.h"
10 #include "chrome/browser/api/prefs/pref_member.h" 10 #include "chrome/browser/api/prefs/pref_member.h"
11 #include "chrome/browser/tab_contents/web_contents_user_data.h"
11 #include "content/public/browser/notification_observer.h" 12 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 13 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h" 14 #include "content/public/browser/web_contents_observer.h"
14 #include "printing/printed_pages_source.h" 15 #include "printing/printed_pages_source.h"
15 16
16 class TabContents;
17 struct PrintHostMsg_DidPrintPage_Params; 17 struct PrintHostMsg_DidPrintPage_Params;
18 18
19 namespace content { 19 namespace content {
20 class RenderProcessHost; 20 class RenderProcessHost;
21 class RenderViewHost; 21 class RenderViewHost;
22 } 22 }
23 23
24 namespace printing { 24 namespace printing {
25 25
26 class JobEventDetails; 26 class JobEventDetails;
27 class PrintJob; 27 class PrintJob;
28 class PrintJobWorkerOwner; 28 class PrintJobWorkerOwner;
29 class PrintViewManagerObserver; 29 class PrintViewManagerObserver;
30 30
31 // Manages the print commands in relation to a TabContents. 31 // Manages the print commands for a WebContents.
32 // TabContents delegates a few printing related commands to this
33 // instance.
34 class PrintViewManager : public content::NotificationObserver, 32 class PrintViewManager : public content::NotificationObserver,
35 public PrintedPagesSource, 33 public PrintedPagesSource,
36 public content::WebContentsObserver { 34 public content::WebContentsObserver,
35 public WebContentsUserData<PrintViewManager> {
37 public: 36 public:
38 explicit PrintViewManager(TabContents* tab);
39 virtual ~PrintViewManager(); 37 virtual ~PrintViewManager();
40 38
41 // Prints the current document immediately. Since the rendering is 39 // Prints the current document immediately. Since the rendering is
42 // asynchronous, the actual printing will not be completed on the return of 40 // asynchronous, the actual printing will not be completed on the return of
43 // this function. Returns false if printing is impossible at the moment. 41 // this function. Returns false if printing is impossible at the moment.
44 bool PrintNow(); 42 bool PrintNow();
45 43
46 // Same as PrintNow(), but for the case where a user prints with the system 44 // Same as PrintNow(), but for the case where a user prints with the system
47 // dialog from print preview. 45 // dialog from print preview.
48 bool PrintForSystemDialogNow(); 46 bool PrintForSystemDialogNow();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 // content::WebContentsObserver implementation. 92 // content::WebContentsObserver implementation.
95 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 93 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
96 94
97 // Terminates or cancels the print job if one was pending. 95 // Terminates or cancels the print job if one was pending.
98 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 96 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
99 97
100 // Cancels the print job. 98 // Cancels the print job.
101 virtual void StopNavigation() OVERRIDE; 99 virtual void StopNavigation() OVERRIDE;
102 100
103 private: 101 private:
102 explicit PrintViewManager(content::WebContents* web_contents);
103 static int kUserDataKey;
104 friend class WebContentsUserData<PrintViewManager>;
105
104 enum PrintPreviewState { 106 enum PrintPreviewState {
105 NOT_PREVIEWING, 107 NOT_PREVIEWING,
106 USER_INITIATED_PREVIEW, 108 USER_INITIATED_PREVIEW,
107 SCRIPTED_PREVIEW, 109 SCRIPTED_PREVIEW,
108 }; 110 };
109 111
110 // IPC Message handlers. 112 // IPC Message handlers.
111 void OnDidGetPrintedPagesCount(int cookie, int number_pages); 113 void OnDidGetPrintedPagesCount(int cookie, int number_pages);
112 void OnDidGetDocumentCookie(int cookie); 114 void OnDidGetDocumentCookie(int cookie);
113 void OnDidShowPrintDialog(); 115 void OnDidShowPrintDialog();
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // control flow, print_job_ is initialized whenever possible. No-op is 167 // control flow, print_job_ is initialized whenever possible. No-op is
166 // print_job_ is initialized. 168 // print_job_ is initialized.
167 bool OpportunisticallyCreatePrintJob(int cookie); 169 bool OpportunisticallyCreatePrintJob(int cookie);
168 170
169 // Helper method for Print*Now(). 171 // Helper method for Print*Now().
170 bool PrintNowInternal(IPC::Message* message); 172 bool PrintNowInternal(IPC::Message* message);
171 173
172 // Release the PrinterQuery associated with our |cookie_|. 174 // Release the PrinterQuery associated with our |cookie_|.
173 void ReleasePrinterQuery(); 175 void ReleasePrinterQuery();
174 176
175 // TabContents we're associated with.
176 TabContents* tab_;
177
178 content::NotificationRegistrar registrar_; 177 content::NotificationRegistrar registrar_;
179 178
180 // Manages the low-level talk to the printer. 179 // Manages the low-level talk to the printer.
181 scoped_refptr<PrintJob> print_job_; 180 scoped_refptr<PrintJob> print_job_;
182 181
183 // Number of pages to print in the print job. 182 // Number of pages to print in the print job.
184 int number_pages_; 183 int number_pages_;
185 184
186 // Indication of success of the print job. 185 // Indication of success of the print job.
187 bool printing_succeeded_; 186 bool printing_succeeded_;
(...skipping 17 matching lines...) Expand all
205 204
206 // Current state of print preview for this view. 205 // Current state of print preview for this view.
207 PrintPreviewState print_preview_state_; 206 PrintPreviewState print_preview_state_;
208 207
209 // Keeps track of the pending callback during scripted print preview. 208 // Keeps track of the pending callback during scripted print preview.
210 content::RenderProcessHost* scripted_print_preview_rph_; 209 content::RenderProcessHost* scripted_print_preview_rph_;
211 210
212 // Whether printing is enabled. 211 // Whether printing is enabled.
213 BooleanPrefMember printing_enabled_; 212 BooleanPrefMember printing_enabled_;
214 213
215 // Whether our tab content is in blocked state. 214 // Whether our content is in blocked state.
216 bool tab_content_blocked_; 215 bool tab_content_blocked_;
217 216
218 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); 217 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
219 }; 218 };
220 219
221 } // namespace printing 220 } // namespace printing
222 221
223 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 222 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/printing/print_preview_tab_controller_unittest.cc ('k') | chrome/browser/printing/print_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698