#ifndef CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
#define CHROME_BROWSER_PRINTING_PRINT_PREVIEW_DIALOG_CONTROLLER_H_
#include <vector>
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/memory/ref_counted.h"
#include "chrome/browser/sessions/session_id.h"
class GURL;
namespace content {
struct LoadCommittedDetails;
class RenderProcessHost;
class WebContents;
}
namespace printing {
class PrintPreviewDialogController
: public base::RefCounted<PrintPreviewDialogController> {
public:
PrintPreviewDialogController();
static PrintPreviewDialogController* GetInstance();
static void PrintPreview(content::WebContents* initiator);
content::WebContents* GetOrCreatePreviewDialog(
content::WebContents* initiator);
content::WebContents* GetPrintPreviewForContents(
content::WebContents* contents) const;
content::WebContents* GetInitiator(content::WebContents* preview_dialog);
void ForEachPreviewDialog(
base::Callback<void(content::WebContents*)> callback);
static bool IsPrintPreviewDialog(content::WebContents* contents);
static bool IsPrintPreviewURL(const GURL& url);
void EraseInitiatorInfo(content::WebContents* preview_dialog);
bool is_creating_print_preview_dialog() const {
return is_creating_print_preview_dialog_;
}
private:
friend class base::RefCounted<PrintPreviewDialogController>;
struct Operation;
virtual ~PrintPreviewDialogController();
void OnRenderProcessExited(content::RenderProcessHost* rph);
void OnWebContentsDestroyed(content::WebContents* contents);
void OnNavigationEntryCommitted(content::WebContents* contents,
const content::LoadCommittedDetails* details);
content::WebContents* CreatePrintPreviewDialog(
content::WebContents* initiator);
void SaveInitiatorTitle(content::WebContents* preview_dialog);
void RemoveInitiator(content::WebContents* initiator);
void RemovePreviewDialog(content::WebContents* preview_dialog);
std::vector<Operation*> preview_operations_;
bool waiting_for_new_preview_page_;
bool is_creating_print_preview_dialog_;
DISALLOW_COPY_AND_ASSIGN(PrintPreviewDialogController);
};
}
#endif