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

Side by Side Diff: chrome/renderer/print_web_view_helper.h

Issue 6533006: Print Preview: Hook up the print button to initiate printing without displaying a print dialog. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: '' Created 9 years, 10 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_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // Prints |frame|. 86 // Prints |frame|.
87 void PrintFrame(WebKit::WebFrame* frame, 87 void PrintFrame(WebKit::WebFrame* frame,
88 bool script_initiated, 88 bool script_initiated,
89 bool is_preview); 89 bool is_preview);
90 90
91 // Message handlers. Public for testing. 91 // Message handlers. Public for testing.
92 void OnPrintingDone(int document_cookie, bool success); 92 void OnPrintingDone(int document_cookie, bool success);
93 void OnPrintPages(); 93 void OnPrintPages();
94 void OnPrintPreview(); 94 void OnPrintPreview();
95 void OnPrintNodeUnderContextMenu(); 95 void OnPrintNodeUnderContextMenu();
96 void OnPrintForPrintPreview(const std::string& job_settings);
96 97
97 protected: 98 protected:
98 bool CopyAndPrint(WebKit::WebFrame* web_frame); 99 bool CopyAndPrint(WebKit::WebFrame* web_frame);
99 100
100 // Prints the page listed in |params|. 101 // Prints the page listed in |params|.
101 #if defined(USE_X11) 102 #if defined(USE_X11)
102 void PrintPage(const ViewMsg_PrintPage_Params& params, 103 void PrintPage(const ViewMsg_PrintPage_Params& params,
103 const gfx::Size& canvas_size, 104 const gfx::Size& canvas_size,
104 WebKit::WebFrame* frame, 105 WebKit::WebFrame* frame,
105 printing::NativeMetafile* metafile, 106 printing::NativeMetafile* metafile,
106 skia::VectorCanvas** canvas); 107 skia::VectorCanvas** canvas);
107 #else 108 #else
108 void PrintPage(const ViewMsg_PrintPage_Params& params, 109 void PrintPage(const ViewMsg_PrintPage_Params& params,
109 const gfx::Size& canvas_size, 110 const gfx::Size& canvas_size,
110 WebKit::WebFrame* frame); 111 WebKit::WebFrame* frame);
111 #endif 112 #endif
112 113
113 // Prints all the pages listed in |params|. 114 // Prints all the pages listed in |params|.
114 // It will implicitly revert the document to display CSS media type. 115 // It will implicitly revert the document to display CSS media type.
115 void PrintPages(const ViewMsg_PrintPages_Params& params, 116 void PrintPages(const ViewMsg_PrintPages_Params& params,
116 WebKit::WebFrame* frame, 117 WebKit::WebFrame* frame,
117 WebKit::WebNode* node); 118 WebKit::WebNode* node);
118 119
119 // WebKit::WebViewClient override: 120 // WebKit::WebViewClient override:
120 virtual void didStopLoading(); 121 virtual void didStopLoading();
121 122
122 private: 123 private:
124 enum GetSettingsParam {
125 DEFAULT,
126 CURRENT,
127 };
128
123 static void GetPageSizeAndMarginsInPoints( 129 static void GetPageSizeAndMarginsInPoints(
124 WebKit::WebFrame* frame, 130 WebKit::WebFrame* frame,
125 int page_index, 131 int page_index,
126 const ViewMsg_Print_Params& default_params, 132 const ViewMsg_Print_Params& default_params,
127 double* content_width_in_points, 133 double* content_width_in_points,
128 double* content_height_in_points, 134 double* content_height_in_points,
129 double* margin_top_in_points, 135 double* margin_top_in_points,
130 double* margin_right_in_points, 136 double* margin_right_in_points,
131 double* margin_bottom_in_points, 137 double* margin_bottom_in_points,
132 double* margin_left_in_points); 138 double* margin_left_in_points);
133 139
134 // RenderViewObserver implementation. 140 // RenderViewObserver implementation.
135 virtual bool OnMessageReceived(const IPC::Message& message); 141 virtual bool OnMessageReceived(const IPC::Message& message);
136 142
137 // Common method for OnPrintPages() and OnPrintPreview(). 143 // Common method for OnPrintPages() and OnPrintPreview().
138 void OnPrint(bool is_preview); 144 void OnPrint(bool is_preview);
139 145
140 void PrintNode(WebKit::WebNode* node, 146 void PrintNode(WebKit::WebNode* node,
141 bool script_initiated, 147 bool script_initiated,
142 bool is_preview); 148 bool is_preview,
149 bool is_print_for_print_preview);
143 150
144 // Notification when printing is done - signal teardown 151 // Notification when printing is done - signal teardown
145 void DidFinishPrinting(bool success); 152 void DidFinishPrinting(bool success);
146 153
154 // Print the pages for print preview. Do not display the native print dialog
155 // for user settings. Use the current print settings set by the user in
156 // preview tab.
157 void PrintForPrintPreview(WebKit::WebFrame* frame, WebKit::WebNode* node);
158
147 void Print(WebKit::WebFrame* frame, 159 void Print(WebKit::WebFrame* frame,
148 WebKit::WebNode* node, 160 WebKit::WebNode* node,
149 bool script_initiated, 161 bool script_initiated,
150 bool is_preview); 162 bool is_preview);
151 163
152 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame, 164 void UpdatePrintableSizeInPrintParameters(WebKit::WebFrame* frame,
153 WebKit::WebNode* node, 165 WebKit::WebNode* node,
154 ViewMsg_Print_Params* params); 166 ViewMsg_Print_Params* params);
155 167
156 // Initialize print page settings with default settings. 168 // Initialize print page settings with default settings.
157 bool InitPrintSettings(WebKit::WebFrame* frame, 169 bool InitPrintSettings(WebKit::WebFrame* frame,
158 WebKit::WebNode* node); 170 WebKit::WebNode* node,
171 GetSettingsParam setting_type);
159 172
160 // Get the default printer settings. 173 // Update the current print settings with new |job_settings|. |job_settings|
161 bool GetDefaultPrintSettings(WebKit::WebFrame* frame, 174 // is a json string which contains print job details such as printer name,
162 WebKit::WebNode* node, 175 // number of copies, page range, etc.
163 ViewMsg_Print_Params* params); 176 bool UpdatePrintSettings(const std::string& job_settings);
177
178 // Get the print settings. |setting_type| determines whether we need to get
179 // current settings or default settings.
180 bool GetPrintSettings(WebKit::WebFrame* frame,
181 WebKit::WebNode* node,
182 GetSettingsParam setting_type,
183 ViewMsg_Print_Params* params);
164 184
165 // Get final print settings from the user. 185 // Get final print settings from the user.
166 // Return false if the user cancels or on error. 186 // Return false if the user cancels or on error.
167 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame, 187 bool GetPrintSettingsFromUser(WebKit::WebFrame* frame,
168 int expected_pages_count, 188 int expected_pages_count,
169 bool use_browser_overlays); 189 bool use_browser_overlays);
170 190
171 // Render the frame for printing. 191 // Render the frame for printing.
172 void RenderPagesForPrint(WebKit::WebFrame* frame, 192 void RenderPagesForPrint(WebKit::WebFrame* frame,
173 WebKit::WebNode* node); 193 WebKit::WebNode* node);
(...skipping 25 matching lines...) Expand all
199 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_; 219 scoped_ptr<ViewMsg_PrintPages_Params> print_pages_params_;
200 base::Time last_cancelled_script_print_; 220 base::Time last_cancelled_script_print_;
201 int user_cancelled_scripted_print_count_; 221 int user_cancelled_scripted_print_count_;
202 bool is_preview_; 222 bool is_preview_;
203 223
204 private: 224 private:
205 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 225 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
206 }; 226 };
207 227
208 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_ 228 #endif // CHROME_RENDERER_PRINT_WEB_VIEW_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698