Home | History | Annotate | Download | only in cloud_print
      1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #ifndef CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_
      6 #define CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_
      7 #pragma once
      8 
      9 #include "base/memory/weak_ptr.h"
     10 #include "chrome/browser/printing/cloud_print/cloud_print_setup_flow.h"
     11 
     12 // Cloud Print setup handler.
     13 // Provides a weak pointer adapter so that callers of
     14 // CloudPrintSetupFlow::OpenDialog can still be notified when the dialog
     15 // completes, but don't have to stick around until the end. Lifetime should be
     16 // shorter than that of it's owner.
     17 class CloudPrintSetupHandler
     18     : public CloudPrintSetupFlow::Delegate,
     19       public base::SupportsWeakPtr<CloudPrintSetupHandler> {
     20  public:
     21   class Delegate {
     22    public:
     23     virtual ~Delegate() {}
     24     // Called when the setup dialog is closed.
     25     virtual void OnCloudPrintSetupClosed() = 0;
     26   };
     27 
     28   explicit CloudPrintSetupHandler(Delegate* handler);
     29   virtual ~CloudPrintSetupHandler();
     30 
     31   // CloudPrintSetupFlow::Delegate implementation.
     32   virtual void OnDialogClosed();
     33 
     34  private:
     35   Delegate* handler_;
     36 
     37   DISALLOW_COPY_AND_ASSIGN(CloudPrintSetupHandler);
     38 };
     39 
     40 // Workaround for MSVC 2005 not handling inheritance from nested classes well.
     41 typedef CloudPrintSetupHandler::Delegate CloudPrintSetupHandlerDelegate;
     42 
     43 #endif  // CHROME_BROWSER_PRINTING_CLOUD_PRINT_CLOUD_PRINT_SETUP_HANDLER_H_
     44