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

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

Issue 226093007: Convert Chrome usages of WebFrame to WebLocalFrame. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 8 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_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 5 #ifndef CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 6 #define CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/gtest_prod_util.h" 10 #include "base/gtest_prod_util.h"
(...skipping 25 matching lines...) Expand all
36 namespace printing { 36 namespace printing {
37 37
38 struct PageSizeMargins; 38 struct PageSizeMargins;
39 class PrepareFrameAndViewForPrint; 39 class PrepareFrameAndViewForPrint;
40 40
41 // Stores reference to frame using WebVew and unique name. 41 // Stores reference to frame using WebVew and unique name.
42 // Workaround to modal dialog issue on Linux. crbug.com/236147. 42 // Workaround to modal dialog issue on Linux. crbug.com/236147.
43 // If WebFrame someday supports WeakPtr, we should use it here. 43 // If WebFrame someday supports WeakPtr, we should use it here.
44 class FrameReference { 44 class FrameReference {
45 public: 45 public:
46 explicit FrameReference(blink::WebFrame* frame); 46 explicit FrameReference(blink::WebLocalFrame* frame);
47 FrameReference(); 47 FrameReference();
48 ~FrameReference(); 48 ~FrameReference();
49 49
50 void Reset(blink::WebFrame* frame); 50 void Reset(blink::WebLocalFrame* frame);
51 51
52 blink::WebFrame* GetFrame(); 52 blink::WebLocalFrame* GetFrame();
53 blink::WebView* view(); 53 blink::WebView* view();
54 54
55 private: 55 private:
56 blink::WebView* view_; 56 blink::WebView* view_;
57 blink::WebFrame* frame_; 57 blink::WebLocalFrame* frame_;
58 }; 58 };
59 59
60 // PrintWebViewHelper handles most of the printing grunt work for RenderView. 60 // PrintWebViewHelper handles most of the printing grunt work for RenderView.
61 // We plan on making print asynchronous and that will require copying the DOM 61 // We plan on making print asynchronous and that will require copying the DOM
62 // of the document and creating a new WebView with the contents. 62 // of the document and creating a new WebView with the contents.
63 class PrintWebViewHelper 63 class PrintWebViewHelper
64 : public content::RenderViewObserver, 64 : public content::RenderViewObserver,
65 public content::RenderViewObserverTracker<PrintWebViewHelper> { 65 public content::RenderViewObserverTracker<PrintWebViewHelper> {
66 public: 66 public:
67 explicit PrintWebViewHelper(content::RenderView* render_view); 67 explicit PrintWebViewHelper(content::RenderView* render_view);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 106
107 enum PrintPreviewRequestType { 107 enum PrintPreviewRequestType {
108 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME, 108 PRINT_PREVIEW_USER_INITIATED_ENTIRE_FRAME,
109 PRINT_PREVIEW_USER_INITIATED_SELECTION, 109 PRINT_PREVIEW_USER_INITIATED_SELECTION,
110 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE, 110 PRINT_PREVIEW_USER_INITIATED_CONTEXT_NODE,
111 PRINT_PREVIEW_SCRIPTED // triggered by window.print(). 111 PRINT_PREVIEW_SCRIPTED // triggered by window.print().
112 }; 112 };
113 113
114 // RenderViewObserver implementation. 114 // RenderViewObserver implementation.
115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 115 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
116 virtual void PrintPage(blink::WebFrame* frame, bool user_initiated) OVERRIDE; 116 virtual void PrintPage(blink::WebLocalFrame* frame,
117 bool user_initiated) OVERRIDE;
117 virtual void DidStartLoading() OVERRIDE; 118 virtual void DidStartLoading() OVERRIDE;
118 virtual void DidStopLoading() OVERRIDE; 119 virtual void DidStopLoading() OVERRIDE;
119 120
120 // Message handlers --------------------------------------------------------- 121 // Message handlers ---------------------------------------------------------
121 void OnPrintPages(); 122 void OnPrintPages();
122 void OnPrintForSystemDialog(); 123 void OnPrintForSystemDialog();
123 void OnInitiatePrintPreview(bool selection_only); 124 void OnInitiatePrintPreview(bool selection_only);
124 void OnPrintPreview(const base::DictionaryValue& settings); 125 void OnPrintPreview(const base::DictionaryValue& settings);
125 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings); 126 void OnPrintForPrintPreview(const base::DictionaryValue& job_settings);
126 void OnPrintingDone(bool success); 127 void OnPrintingDone(bool success);
(...skipping 27 matching lines...) Expand all
154 155
155 // Finalize the print ready preview document. 156 // Finalize the print ready preview document.
156 bool FinalizePrintReadyDocument(); 157 bool FinalizePrintReadyDocument();
157 158
158 // Enable/Disable window.print calls. If |blocked| is true window.print 159 // Enable/Disable window.print calls. If |blocked| is true window.print
159 // calls will silently fail. Call with |blocked| set to false to reenable. 160 // calls will silently fail. Call with |blocked| set to false to reenable.
160 void SetScriptedPrintBlocked(bool blocked); 161 void SetScriptedPrintBlocked(bool blocked);
161 162
162 // Main printing code ------------------------------------------------------- 163 // Main printing code -------------------------------------------------------
163 164
164 void Print(blink::WebFrame* frame, const blink::WebNode& node); 165 void Print(blink::WebLocalFrame* frame, const blink::WebNode& node);
165 166
166 // Notification when printing is done - signal tear-down/free resources. 167 // Notification when printing is done - signal tear-down/free resources.
167 void DidFinishPrinting(PrintingResult result); 168 void DidFinishPrinting(PrintingResult result);
168 169
169 // Print Settings ----------------------------------------------------------- 170 // Print Settings -----------------------------------------------------------
170 171
171 // Initialize print page settings with default settings. 172 // Initialize print page settings with default settings.
172 // Used only for native printing workflow. 173 // Used only for native printing workflow.
173 bool InitPrintSettings(bool fit_to_paper_size); 174 bool InitPrintSettings(bool fit_to_paper_size);
174 175
175 // Calculate number of pages in source document. 176 // Calculate number of pages in source document.
176 bool CalculateNumberOfPages(blink::WebFrame* frame, 177 bool CalculateNumberOfPages(blink::WebLocalFrame* frame,
177 const blink::WebNode& node, 178 const blink::WebNode& node,
178 int* number_of_pages); 179 int* number_of_pages);
179 180
180 // Update the current print settings with new |passed_job_settings|. 181 // Update the current print settings with new |passed_job_settings|.
181 // |passed_job_settings| dictionary contains print job details such as printer 182 // |passed_job_settings| dictionary contains print job details such as printer
182 // name, number of copies, page range, etc. 183 // name, number of copies, page range, etc.
183 bool UpdatePrintSettings(blink::WebFrame* frame, 184 bool UpdatePrintSettings(blink::WebLocalFrame* frame,
184 const blink::WebNode& node, 185 const blink::WebNode& node,
185 const base::DictionaryValue& passed_job_settings); 186 const base::DictionaryValue& passed_job_settings);
186 187
187 // Get final print settings from the user. 188 // Get final print settings from the user.
188 // Return false if the user cancels or on error. 189 // Return false if the user cancels or on error.
189 bool GetPrintSettingsFromUser(blink::WebFrame* frame, 190 bool GetPrintSettingsFromUser(blink::WebFrame* frame,
190 const blink::WebNode& node, 191 const blink::WebNode& node,
191 int expected_pages_count); 192 int expected_pages_count);
192 193
193 // Page Printing / Rendering ------------------------------------------------ 194 // Page Printing / Rendering ------------------------------------------------
(...skipping 11 matching lines...) Expand all
205 const gfx::Size& canvas_size, 206 const gfx::Size& canvas_size,
206 blink::WebFrame* frame, 207 blink::WebFrame* frame,
207 Metafile* metafile); 208 Metafile* metafile);
208 #else 209 #else
209 void PrintPageInternal(const PrintMsg_PrintPage_Params& params, 210 void PrintPageInternal(const PrintMsg_PrintPage_Params& params,
210 const gfx::Size& canvas_size, 211 const gfx::Size& canvas_size,
211 blink::WebFrame* frame); 212 blink::WebFrame* frame);
212 #endif 213 #endif
213 214
214 // Render the frame for printing. 215 // Render the frame for printing.
215 bool RenderPagesForPrint(blink::WebFrame* frame, 216 bool RenderPagesForPrint(blink::WebLocalFrame* frame,
216 const blink::WebNode& node); 217 const blink::WebNode& node);
217 218
218 // Platform specific helper function for rendering page(s) to |metafile|. 219 // Platform specific helper function for rendering page(s) to |metafile|.
219 #if defined(OS_WIN) 220 #if defined(OS_WIN)
220 void RenderPage(const PrintMsg_Print_Params& params, 221 void RenderPage(const PrintMsg_Print_Params& params,
221 int page_number, 222 int page_number,
222 blink::WebFrame* frame, 223 blink::WebFrame* frame,
223 bool is_preview, 224 bool is_preview,
224 Metafile* metafile, 225 Metafile* metafile,
225 double* scale_factor, 226 double* scale_factor,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // and footers using strings from |header_footer_info| on to the canvas. 265 // and footers using strings from |header_footer_info| on to the canvas.
265 static void PrintHeaderAndFooter( 266 static void PrintHeaderAndFooter(
266 blink::WebCanvas* canvas, 267 blink::WebCanvas* canvas,
267 int page_number, 268 int page_number,
268 int total_pages, 269 int total_pages,
269 float webkit_scale_factor, 270 float webkit_scale_factor,
270 const PageSizeMargins& page_layout_in_points, 271 const PageSizeMargins& page_layout_in_points,
271 const base::DictionaryValue& header_footer_info, 272 const base::DictionaryValue& header_footer_info,
272 const PrintMsg_Print_Params& params); 273 const PrintMsg_Print_Params& params);
273 274
274 bool GetPrintFrame(blink::WebFrame** frame); 275 bool GetPrintFrame(blink::WebLocalFrame** frame);
275 276
276 // Script Initiated Printing ------------------------------------------------ 277 // Script Initiated Printing ------------------------------------------------
277 278
278 // Return true if script initiated printing is currently 279 // Return true if script initiated printing is currently
279 // allowed. |user_initiated| should be true when a user event triggered the 280 // allowed. |user_initiated| should be true when a user event triggered the
280 // script, most likely by pressing a print button on the page. 281 // script, most likely by pressing a print button on the page.
281 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, 282 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame,
282 bool user_initiated); 283 bool user_initiated);
283 284
284 // Returns true if script initiated printing occurs too often. 285 // Returns true if script initiated printing occurs too often.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 // Keeps track of the state of print preview between messages. 338 // Keeps track of the state of print preview between messages.
338 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after 339 // TODO(vitalybuka): Create PrintPreviewContext when needed and delete after
339 // use. Now it's interaction with various messages is confusing. 340 // use. Now it's interaction with various messages is confusing.
340 class PrintPreviewContext { 341 class PrintPreviewContext {
341 public: 342 public:
342 PrintPreviewContext(); 343 PrintPreviewContext();
343 ~PrintPreviewContext(); 344 ~PrintPreviewContext();
344 345
345 // Initializes the print preview context. Need to be called to set 346 // Initializes the print preview context. Need to be called to set
346 // the |web_frame| / |web_node| to generate the print preview for. 347 // the |web_frame| / |web_node| to generate the print preview for.
347 void InitWithFrame(blink::WebFrame* web_frame); 348 void InitWithFrame(blink::WebLocalFrame* web_frame);
348 void InitWithNode(const blink::WebNode& web_node); 349 void InitWithNode(const blink::WebNode& web_node);
349 350
350 // Does bookkeeping at the beginning of print preview. 351 // Does bookkeeping at the beginning of print preview.
351 void OnPrintPreview(); 352 void OnPrintPreview();
352 353
353 // Create the print preview document. |pages| is empty to print all pages. 354 // Create the print preview document. |pages| is empty to print all pages.
354 // Takes ownership of |prepared_frame|. 355 // Takes ownership of |prepared_frame|.
355 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame, 356 bool CreatePreviewDocument(PrepareFrameAndViewForPrint* prepared_frame,
356 const std::vector<int>& pages); 357 const std::vector<int>& pages);
357 358
(...skipping 20 matching lines...) Expand all
378 bool HasSelection(); 379 bool HasSelection();
379 bool IsLastPageOfPrintReadyMetafile() const; 380 bool IsLastPageOfPrintReadyMetafile() const;
380 bool IsFinalPageRendered() const; 381 bool IsFinalPageRendered() const;
381 382
382 // Setters 383 // Setters
383 void set_generate_draft_pages(bool generate_draft_pages); 384 void set_generate_draft_pages(bool generate_draft_pages);
384 void set_error(enum PrintPreviewErrorBuckets error); 385 void set_error(enum PrintPreviewErrorBuckets error);
385 386
386 // Getters 387 // Getters
387 // Original frame for which preview was requested. 388 // Original frame for which preview was requested.
388 blink::WebFrame* source_frame(); 389 blink::WebLocalFrame* source_frame();
389 // Original node for which preview was requested. 390 // Original node for which preview was requested.
390 const blink::WebNode& source_node() const; 391 const blink::WebNode& source_node() const;
391 392
392 // Frame to be use to render preview. May be the same as source_frame(), or 393 // Frame to be use to render preview. May be the same as source_frame(), or
393 // generated from it, e.g. copy of selected block. 394 // generated from it, e.g. copy of selected block.
394 blink::WebFrame* prepared_frame(); 395 blink::WebLocalFrame* prepared_frame();
395 // Node to be use to render preview. May be the same as source_node(), or 396 // Node to be use to render preview. May be the same as source_node(), or
396 // generated from it, e.g. copy of selected block. 397 // generated from it, e.g. copy of selected block.
397 const blink::WebNode& prepared_node() const; 398 const blink::WebNode& prepared_node() const;
398 399
399 int total_page_count() const; 400 int total_page_count() const;
400 bool generate_draft_pages() const; 401 bool generate_draft_pages() const;
401 PreviewMetafile* metafile(); 402 PreviewMetafile* metafile();
402 gfx::Size GetPrintCanvasSize() const; 403 gfx::Size GetPrintCanvasSize() const;
403 int last_error() const; 404 int last_error() const;
404 405
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
447 PrintPreviewContext print_preview_context_; 448 PrintPreviewContext print_preview_context_;
448 bool is_loading_; 449 bool is_loading_;
449 bool is_scripted_preview_delayed_; 450 bool is_scripted_preview_delayed_;
450 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; 451 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_;
451 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); 452 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper);
452 }; 453 };
453 454
454 } // namespace printing 455 } // namespace printing
455 456
456 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_ 457 #endif // CHROME_RENDERER_PRINTING_PRINT_WEB_VIEW_HELPER_H_
OLDNEW
« no previous file with comments | « chrome/renderer/extensions/sync_file_system_custom_bindings.cc ('k') | chrome/renderer/printing/print_web_view_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698