Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 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_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ |
| 6 #define CHROME_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ | 6 #define CHROME_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/scoped_ptr.h" | 9 #include <utility> |
|
James Hawkins
2011/01/31 18:39:38
This is right to remove scoped_ptr.h, but now we n
Lei Zhang
2011/01/31 22:15:51
weak_ptr.h includes ref_counted.h, but I added it
| |
| 10 | |
| 10 #include "base/weak_ptr.h" | 11 #include "base/weak_ptr.h" |
| 11 #include "chrome/browser/dom_ui/dom_ui.h" | 12 #include "chrome/browser/dom_ui/dom_ui.h" |
| 12 | 13 |
| 14 namespace base { | |
| 15 class SharedMemory; | |
| 16 } | |
| 17 | |
| 13 namespace printing { | 18 namespace printing { |
| 14 class PrintBackend; | 19 class PrintBackend; |
| 15 } // namespace printing | 20 } |
|
James Hawkins
2011/01/31 18:39:38
I realize there was disagreement on the list recen
Lei Zhang
2011/01/31 22:15:51
I've asked for the style guide to be updated to re
| |
| 16 | 21 |
| 17 // The handler for Javascript messages related to the "print preview" dialog. | 22 // The handler for Javascript messages related to the "print preview" dialog. |
| 18 class PrintPreviewHandler : public DOMMessageHandler, | 23 class PrintPreviewHandler : public DOMMessageHandler, |
| 19 public base::SupportsWeakPtr<PrintPreviewHandler> { | 24 public base::SupportsWeakPtr<PrintPreviewHandler> { |
| 20 public: | 25 public: |
| 26 typedef std::pair<base::SharedMemory*, uint32> PrintPreviewData; | |
|
James Hawkins
2011/01/31 18:39:38
Document this typedef.
Lei Zhang
2011/01/31 22:15:51
Done.
| |
| 27 | |
| 21 PrintPreviewHandler(); | 28 PrintPreviewHandler(); |
| 22 virtual ~PrintPreviewHandler(); | 29 virtual ~PrintPreviewHandler(); |
| 23 | 30 |
| 31 // Get the print preview |data|. The data is valid as long as the | |
|
James Hawkins
2011/01/31 18:39:38
s/Get/Gets/
Lei Zhang
2011/01/31 22:15:51
Done.
| |
| 32 // PrintPreviewHandler is valid and SetPrintPreviewData() does not get called. | |
| 33 void GetPrintPreviewData(PrintPreviewData* data); | |
| 34 | |
| 35 // Save the print preview |data|. PrintPreviewHandler owns the data and is | |
|
James Hawkins
2011/01/31 18:39:38
s/Save/Saves/ and now that I look at the method na
Lei Zhang
2011/01/31 22:15:51
There's no function named "SetsFoo". Everything in
James Hawkins
2011/02/01 01:02:38
By "this", I was referring to the comment.
| |
| 36 // responsible for freeing it when either: | |
| 37 // a) there is new data. | |
| 38 // b) when PrintPreviewHandler goes away. | |
|
James Hawkins
2011/01/31 18:39:38
nit: You should probably be more descriptive than
Lei Zhang
2011/01/31 22:15:51
Done.
| |
| 39 void SetPrintPreviewData(const PrintPreviewData& data); | |
| 40 | |
| 24 // DOMMessageHandler implementation. | 41 // DOMMessageHandler implementation. |
| 25 virtual void RegisterMessages(); | 42 virtual void RegisterMessages(); |
| 26 | 43 |
| 27 private: | 44 private: |
| 28 // Get the PDF preview and refresh the PDF plugin. |args| is unused. | 45 // Get the PDF preview and refresh the PDF plugin. |args| is unused. |
| 29 void HandleGetPreview(const ListValue* args); | 46 void HandleGetPreview(const ListValue* args); |
| 30 | 47 |
| 31 // Get the list of printers and send it to the DOM UI. |args| is unused. | 48 // Get the list of printers and send it to the DOM UI. |args| is unused. |
| 32 void HandleGetPrinters(const ListValue* args); | 49 void HandleGetPrinters(const ListValue* args); |
| 33 | 50 |
| 34 // Pointer to current print system. | 51 // Pointer to current print system. |
| 35 scoped_refptr<printing::PrintBackend> print_backend_; | 52 scoped_refptr<printing::PrintBackend> print_backend_; |
| 36 | 53 |
| 54 // Current print preview data, owned by PrintPreviewHandler. | |
| 55 PrintPreviewData data_; | |
| 56 | |
| 37 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); | 57 DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler); |
| 38 }; | 58 }; |
| 39 | 59 |
| 40 #endif // CHROME_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ | 60 #endif // CHROME_BROWSER_DOM_UI_PRINT_PREVIEW_HANDLER_H_ |
| OLD | NEW |