summaryrefslogtreecommitdiffstats
path: root/chrome/browser/printing/cloud_print/cloud_print_setup_handler.h
blob: d5d24d4a03fc91db660f204a66742560f1da95b5 (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
// 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_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_
#define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_
#pragma once

#include "base/memory/weak_ptr.h"
#include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"

// Cloud Print setup handler.
// Provides a weak pointer adapter so that callers of
// CloudPrintSetupFlow::OpenDialog can still be notified when the dialog
// completes, but don't have to stick around until the end. Lifetime should be
// shorter than that of it's owner.
class CloudPrintSetupHandler
    : public CloudPrintSetupFlow::Delegate,
      public base::SupportsWeakPtr<CloudPrintSetupHandler> {
 public:
  class Delegate {
   public:
    virtual ~Delegate() {}
    // Called when the setup dialog is closed.
    virtual void OnCloudPrintSetupClosed() = 0;
  };

  explicit CloudPrintSetupHandler(Delegate* handler);
  virtual ~CloudPrintSetupHandler();

  // CloudPrintSetupFlow::Delegate implementation.
  virtual void OnDialogClosed() OVERRIDE;

 private:
  Delegate* handler_;

  DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupHandler);
};

// Workaround for MSVC 2005 not handling inheritance from nested classes well.
typedef CloudPrintSetupHandler::Delegate CloudPrintSetupHandlerDelegate;

#endif  // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_