blob: 2701eafc14cc2ea3c644f8be98ac12b565f4e30f (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
// Copyright (c) 2012 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_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
#pragma once
#include "base/compiler_specific.h"
#include "content/public/browser/web_contents_observer.h"
class PrintPreviewUI;
class TabContents;
struct PrintHostMsg_DidGetPreviewPageCount_Params;
struct PrintHostMsg_DidPreviewDocument_Params;
struct PrintHostMsg_DidPreviewPage_Params;
namespace gfx {
class Rect;
}
namespace printing {
struct PageSizeMargins;
// TabContents offloads print preview message handling to
// PrintPreviewMessageHandler. This object has the same life time as the
// TabContents that owns it.
class PrintPreviewMessageHandler : public content::WebContentsObserver {
public:
explicit PrintPreviewMessageHandler(content::WebContents* web_contents);
virtual ~PrintPreviewMessageHandler();
// content::WebContentsObserver implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void NavigateToPendingEntry(const GURL& url,
content::NavigationController::ReloadType reload_type) OVERRIDE;
private:
// Gets the print preview tab associated with the WebContents being observed.
TabContents* GetPrintPreviewTab();
// Helper function to return the TabContents for web_contents().
TabContents* tab_contents();
// Gets the PrintPreviewUI associated with the WebContents being observed.
PrintPreviewUI* GetPrintPreviewUI();
// Message handlers.
void OnRequestPrintPreview(bool source_is_modifiable, bool webnode_only);
void OnDidGetDefaultPageLayout(
const printing::PageSizeMargins& page_layout_in_points,
const gfx::Rect& printable_area_in_points,
bool has_custom_page_size_style);
void OnDidGetPreviewPageCount(
const PrintHostMsg_DidGetPreviewPageCount_Params& params);
void OnDidPreviewPage(const PrintHostMsg_DidPreviewPage_Params& params);
void OnMetafileReadyForPrinting(
const PrintHostMsg_DidPreviewDocument_Params& params);
void OnPrintPreviewFailed(int document_cookie);
void OnPrintPreviewCancelled(int document_cookie);
void OnInvalidPrinterSettings(int document_cookie);
void OnPrintPreviewScalingDisabled();
DISALLOW_COPY_AND_ASSIGN(PrintPreviewMessageHandler);
};
} // namespace printing
#endif // CHROME_BROWSER_PRINTING_PRINT_PREVIEW_MESSAGE_HANDLER_H_
|