| OLD | NEW |
| 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 COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 5 #ifndef COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 6 #define COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 ~FrameReference(); | 65 ~FrameReference(); |
| 66 | 66 |
| 67 void Reset(blink::WebLocalFrame* frame); | 67 void Reset(blink::WebLocalFrame* frame); |
| 68 | 68 |
| 69 blink::WebLocalFrame* GetFrame(); | 69 blink::WebLocalFrame* GetFrame(); |
| 70 blink::WebView* view(); | 70 blink::WebView* view(); |
| 71 | 71 |
| 72 private: | 72 private: |
| 73 blink::WebView* view_; | 73 blink::WebView* view_; |
| 74 blink::WebLocalFrame* frame_; | 74 blink::WebLocalFrame* frame_; |
| 75 |
| 76 DISALLOW_COPY_AND_ASSIGN(FrameReference); |
| 75 }; | 77 }; |
| 76 | 78 |
| 77 // PrintWebViewHelper handles most of the printing grunt work for RenderView. | 79 // PrintWebViewHelper handles most of the printing grunt work for RenderView. |
| 78 // We plan on making print asynchronous and that will require copying the DOM | 80 // We plan on making print asynchronous and that will require copying the DOM |
| 79 // of the document and creating a new WebView with the contents. | 81 // of the document and creating a new WebView with the contents. |
| 80 class PrintWebViewHelper | 82 class PrintWebViewHelper |
| 81 : public content::RenderFrameObserver, | 83 : public content::RenderFrameObserver, |
| 82 public content::RenderFrameObserverTracker<PrintWebViewHelper> { | 84 public content::RenderFrameObserverTracker<PrintWebViewHelper> { |
| 83 public: | 85 public: |
| 84 class Delegate { | 86 class Delegate { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 // Finalize the print ready preview document. | 217 // Finalize the print ready preview document. |
| 216 bool FinalizePrintReadyDocument(); | 218 bool FinalizePrintReadyDocument(); |
| 217 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | 219 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 218 | 220 |
| 219 // Enable/Disable printing. | 221 // Enable/Disable printing. |
| 220 void OnSetPrintingEnabled(bool enabled); | 222 void OnSetPrintingEnabled(bool enabled); |
| 221 | 223 |
| 222 // Main printing code ------------------------------------------------------- | 224 // Main printing code ------------------------------------------------------- |
| 223 | 225 |
| 224 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 226 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 225 // |is_scripted| should be true when the call is coming from window.print() | 227 // Print with the system dialog. |
| 228 // |is_scripted| should be true when the call is coming from window.print(). |
| 229 // WARNING: |this| may be gone after this method returns. |
| 226 void Print(blink::WebLocalFrame* frame, | 230 void Print(blink::WebLocalFrame* frame, |
| 227 const blink::WebNode& node, | 231 const blink::WebNode& node, |
| 228 bool is_scripted); | 232 bool is_scripted); |
| 229 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 233 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 230 | 234 |
| 231 // Notification when printing is done - signal tear-down/free resources. | 235 // Notification when printing is done - signal tear-down/free resources. |
| 232 void DidFinishPrinting(PrintingResult result); | 236 void DidFinishPrinting(PrintingResult result); |
| 233 | 237 |
| 234 // Print Settings ----------------------------------------------------------- | 238 // Print Settings ----------------------------------------------------------- |
| 235 | 239 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 248 PrintHostMsg_SetOptionsFromDocument_Params* options); | 252 PrintHostMsg_SetOptionsFromDocument_Params* options); |
| 249 | 253 |
| 250 // Update the current print settings with new |passed_job_settings|. | 254 // Update the current print settings with new |passed_job_settings|. |
| 251 // |passed_job_settings| dictionary contains print job details such as printer | 255 // |passed_job_settings| dictionary contains print job details such as printer |
| 252 // name, number of copies, page range, etc. | 256 // name, number of copies, page range, etc. |
| 253 bool UpdatePrintSettings(blink::WebLocalFrame* frame, | 257 bool UpdatePrintSettings(blink::WebLocalFrame* frame, |
| 254 const blink::WebNode& node, | 258 const blink::WebNode& node, |
| 255 const base::DictionaryValue& passed_job_settings); | 259 const base::DictionaryValue& passed_job_settings); |
| 256 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) | 260 #endif // BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 257 | 261 |
| 262 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 258 // Get final print settings from the user. | 263 // Get final print settings from the user. |
| 259 // Return false if the user cancels or on error. | 264 // WARNING: |this| may be gone after this method returns. |
| 260 bool GetPrintSettingsFromUser(blink::WebLocalFrame* frame, | 265 void GetPrintSettingsFromUser( |
| 261 const blink::WebNode& node, | 266 blink::WebLocalFrame* frame, |
| 262 int expected_pages_count, | 267 const blink::WebNode& node, |
| 263 bool is_scripted); | 268 int expected_pages_count, |
| 269 bool is_scripted, |
| 270 PrintMsg_PrintPages_Params* print_settings); |
| 271 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 264 | 272 |
| 265 // Page Printing / Rendering ------------------------------------------------ | 273 // Page Printing / Rendering ------------------------------------------------ |
| 266 | |
| 267 #if BUILDFLAG(ENABLE_BASIC_PRINTING) | 274 #if BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 268 void OnFramePreparedForPrintPages(); | 275 void OnFramePreparedForPrintPages(); |
| 269 void PrintPages(); | 276 void PrintPages(); |
| 270 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); | 277 bool PrintPagesNative(blink::WebLocalFrame* frame, int page_count); |
| 271 void FinishFramePrinting(); | 278 void FinishFramePrinting(); |
| 272 // Render the frame for printing. | 279 // Render the frame for printing. |
| 273 bool RenderPagesForPrint(blink::WebLocalFrame* frame, | 280 bool RenderPagesForPrint(blink::WebLocalFrame* frame, |
| 274 const blink::WebNode& node); | 281 const blink::WebNode& node); |
| 275 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) | 282 #endif // BUILDFLAG(ENABLE_BASIC_PRINTING) |
| 276 | 283 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 // Return true if script initiated printing is currently | 352 // Return true if script initiated printing is currently |
| 346 // allowed. |user_initiated| should be true when a user event triggered the | 353 // allowed. |user_initiated| should be true when a user event triggered the |
| 347 // script, most likely by pressing a print button on the page. | 354 // script, most likely by pressing a print button on the page. |
| 348 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, | 355 bool IsScriptInitiatedPrintAllowed(blink::WebFrame* frame, |
| 349 bool user_initiated); | 356 bool user_initiated); |
| 350 | 357 |
| 351 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) | 358 #if BUILDFLAG(ENABLE_PRINT_PREVIEW) |
| 352 // Shows scripted print preview when options from plugin are available. | 359 // Shows scripted print preview when options from plugin are available. |
| 353 void ShowScriptedPrintPreview(); | 360 void ShowScriptedPrintPreview(); |
| 354 | 361 |
| 362 // WARNING: |this| may be gone after this method returns when |type| is |
| 363 // PRINT_PREVIEW_SCRIPTED. |
| 355 void RequestPrintPreview(PrintPreviewRequestType type); | 364 void RequestPrintPreview(PrintPreviewRequestType type); |
| 356 | 365 |
| 357 // Checks whether print preview should continue or not. | 366 // Checks whether print preview should continue or not. |
| 358 // Returns true if canceling, false if continuing. | 367 // Returns true if canceling, false if continuing. |
| 359 bool CheckForCancel(); | 368 bool CheckForCancel(); |
| 360 | 369 |
| 361 // Notifies the browser a print preview page has been rendered. | 370 // Notifies the browser a print preview page has been rendered. |
| 362 // |page_number| is 0-based. | 371 // |page_number| is 0-based. |
| 363 // For a valid |page_number| with modifiable content, | 372 // For a valid |page_number| with modifiable content, |
| 364 // |metafile| is the rendered page. Otherwise |metafile| is NULL. | 373 // |metafile| is the rendered page. Otherwise |metafile| is NULL. |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 base::Closure on_stop_loading_closure_; | 537 base::Closure on_stop_loading_closure_; |
| 529 | 538 |
| 530 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; | 539 base::WeakPtrFactory<PrintWebViewHelper> weak_ptr_factory_; |
| 531 | 540 |
| 532 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); | 541 DISALLOW_COPY_AND_ASSIGN(PrintWebViewHelper); |
| 533 }; | 542 }; |
| 534 | 543 |
| 535 } // namespace printing | 544 } // namespace printing |
| 536 | 545 |
| 537 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ | 546 #endif // COMPONENTS_PRINTING_RENDERER_PRINT_WEB_VIEW_HELPER_H_ |
| OLD | NEW |