summaryrefslogtreecommitdiffstats
path: root/android_webview/browser/aw_printing_message_filter.h
blob: f5c159c5bb9df3e4556b5d367956441383ac7828 (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
// Copyright 2015 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 ANDROID_WEBVIEW_BROWSER_PRINTING_MESSAGE_FILTER_H_
#define ANDROID_WEBVIEW_BROWSER_PRINTING_MESSAGE_FILTER_H_

#include "content/public/browser/browser_message_filter.h"

namespace android_webview {

// This class filters out incoming printing related IPC messages for the
// renderer process on the IPC thread.
class AwPrintingMessageFilter : public content::BrowserMessageFilter {
 public:
  explicit AwPrintingMessageFilter(int render_process_id);

  // content::BrowserMessageFilter methods.
  void OverrideThreadForMessage(const IPC::Message& message,
                                content::BrowserThread::ID* thread) override;
  bool OnMessageReceived(const IPC::Message& message) override;

 private:
  ~AwPrintingMessageFilter() override;

  // Used to ask the browser allocate a temporary file for the renderer
  // to fill in resulting PDF in renderer.
  void OnAllocateTempFileForPrinting(int render_view_id,
                                     base::FileDescriptor* temp_file_fd,
                                     int* sequence_number);
  void OnTempFileForPrintingWritten(int render_view_id, int sequence_number);

  const int render_process_id_;

  DISALLOW_COPY_AND_ASSIGN(AwPrintingMessageFilter);
};

}  // namespace android_webview

#endif  // ANDROID_WEBVIEW_BROWSER_PRINTING_MESSAGE_FILTER_H_