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

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

Issue 10689190: Block printing through JS when printing is disabled by policy or pref (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Meh. The printing code changed under me. Rebased. Created 8 years, 5 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/print_view_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) 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/prefs/pref_member.h"
10 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
12 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
13 #include "printing/printed_pages_source.h" 14 #include "printing/printed_pages_source.h"
14 15
15 class TabContents; 16 class TabContents;
16 struct PrintHostMsg_DidPrintPage_Params; 17 struct PrintHostMsg_DidPrintPage_Params;
17 18
18 namespace content { 19 namespace content {
19 class RenderProcessHost; 20 class RenderProcessHost;
21 class RenderViewHost;
20 } 22 }
21 23
22 namespace printing { 24 namespace printing {
23 25
24 class JobEventDetails; 26 class JobEventDetails;
25 class PrintJob; 27 class PrintJob;
26 class PrintJobWorkerOwner; 28 class PrintJobWorkerOwner;
27 class PrintViewManagerObserver; 29 class PrintViewManagerObserver;
28 30
29 // Manages the print commands in relation to a TabContents. 31 // Manages the print commands in relation to a TabContents.
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 bool PrintPreviewNow(); 64 bool PrintPreviewNow();
63 65
64 // Notify PrintViewManager that print preview is starting in the renderer for 66 // Notify PrintViewManager that print preview is starting in the renderer for
65 // a particular WebNode. 67 // a particular WebNode.
66 void PrintPreviewForWebNode(); 68 void PrintPreviewForWebNode();
67 69
68 // Notify PrintViewManager that print preview has finished. Unfreeze the 70 // Notify PrintViewManager that print preview has finished. Unfreeze the
69 // renderer in the case of scripted print preview. 71 // renderer in the case of scripted print preview.
70 void PrintPreviewDone(); 72 void PrintPreviewDone();
71 73
72 // Whether to block scripted printing or not. 74 // Whether to block scripted printing for our tab or not.
73 void SetScriptedPrintingBlocked(bool blocked); 75 void UpdateScriptedPrintingBlocked();
74 76
75 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to 77 // Sets |observer| as the current PrintViewManagerObserver. Pass in NULL to
76 // remove the current observer. |observer| may always be NULL, but |observer_| 78 // remove the current observer. |observer| may always be NULL, but |observer_|
77 // must be NULL if |observer| is non-NULL. 79 // must be NULL if |observer| is non-NULL.
78 void set_observer(PrintViewManagerObserver* observer); 80 void set_observer(PrintViewManagerObserver* observer);
79 81
80 // PrintedPagesSource implementation. 82 // PrintedPagesSource implementation.
81 virtual string16 RenderSourceName() OVERRIDE; 83 virtual string16 RenderSourceName() OVERRIDE;
82 84
83 // content::NotificationObserver implementation. 85 // content::NotificationObserver implementation.
84 virtual void Observe(int type, 86 virtual void Observe(int type,
85 const content::NotificationSource& source, 87 const content::NotificationSource& source,
86 const content::NotificationDetails& details) OVERRIDE; 88 const content::NotificationDetails& details) OVERRIDE;
87 89
88 // content::WebContentsObserver implementation. 90 // content::WebContentsObserver implementation.
91 virtual void DidStartLoading(
92 content::RenderViewHost* render_view_host) OVERRIDE;
93
94 // content::WebContentsObserver implementation.
89 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 95 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
90 96
91 // Terminates or cancels the print job if one was pending. 97 // Terminates or cancels the print job if one was pending.
92 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE; 98 virtual void RenderViewGone(base::TerminationStatus status) OVERRIDE;
93 99
94 // Cancels the print job. 100 // Cancels the print job.
95 virtual void StopNavigation() OVERRIDE; 101 virtual void StopNavigation() OVERRIDE;
96 102
97 private: 103 private:
98 enum PrintPreviewState { 104 enum PrintPreviewState {
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 202
197 // The document cookie of the current PrinterQuery. 203 // The document cookie of the current PrinterQuery.
198 int cookie_; 204 int cookie_;
199 205
200 // Current state of print preview for this view. 206 // Current state of print preview for this view.
201 PrintPreviewState print_preview_state_; 207 PrintPreviewState print_preview_state_;
202 208
203 // Keeps track of the pending callback during scripted print preview. 209 // Keeps track of the pending callback during scripted print preview.
204 content::RenderProcessHost* scripted_print_preview_rph_; 210 content::RenderProcessHost* scripted_print_preview_rph_;
205 211
212 // Whether printing is enabled.
213 BooleanPrefMember printing_enabled_;
214
215 // Whether our tab content is in blocked state.
216 bool tab_content_blocked_;
217
206 DISALLOW_COPY_AND_ASSIGN(PrintViewManager); 218 DISALLOW_COPY_AND_ASSIGN(PrintViewManager);
207 }; 219 };
208 220
209 } // namespace printing 221 } // namespace printing
210 222
211 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_ 223 #endif // CHROME_BROWSER_PRINTING_PRINT_VIEW_MANAGER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/printing/print_view_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698