summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/webui/print_preview_handler.h
blob: 5e8782026d32771e4d5dd3afc371d412d450c375 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_
#pragma once

#include "base/ref_counted.h"
#include "base/weak_ptr.h"
#include "content/browser/webui/web_ui.h"

class EnumeratePrintersTaskProxy;

namespace printing {
class PrintBackend;
}

// The handler for Javascript messages related to the "print preview" dialog.
class PrintPreviewHandler : public WebUIMessageHandler,
                            public base::SupportsWeakPtr<PrintPreviewHandler> {
 public:
  PrintPreviewHandler();
  virtual ~PrintPreviewHandler();

  // WebUIMessageHandler implementation.
  virtual void RegisterMessages();

 private:
  friend class EnumeratePrintersTaskProxy;

  // Get the list of printers. |args| is unused.
  void HandleGetPrinters(const ListValue* args);

  // Print the preview PDF. |args| is unused.
  void HandlePrint(const ListValue* args);

  // Send the list of printers to the Web UI.
  void SendPrinterList(const ListValue& printers);

  // Pointer to current print system.
  scoped_refptr<printing::PrintBackend> print_backend_;

  DISALLOW_COPY_AND_ASSIGN(PrintPreviewHandler);
};

#endif  // CHROME_BROWSER_UI_WEBUI_PRINT_PREVIEW_HANDLER_H_