#ifndef CHROME_BROWSER_EXTENSIONS_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_
#define CHROME_BROWSER_EXTENSIONS_API_CAPTURE_WEB_CONTENTS_FUNCTION_H_
#include "chrome/browser/extensions/chrome_extension_function.h"
#include "chrome/common/extensions/api/types.h"
class SkBitmap;
namespace content {
class WebContents;
}
namespace extensions {
class CaptureWebContentsFunction : public ChromeAsyncExtensionFunction {
public:
CaptureWebContentsFunction();
protected:
virtual ~CaptureWebContentsFunction();
virtual bool HasPermission() OVERRIDE;
virtual bool RunImpl() OVERRIDE;
virtual bool IsScreenshotEnabled() = 0;
virtual content::WebContents* GetWebContentsForID(int context_id) = 0;
enum FailureReason {
FAILURE_REASON_UNKNOWN,
FAILURE_REASON_CONTENT_NOT_FOUND,
FAILURE_REASON_ENCODING_FAILED,
FAILURE_REASON_VIEW_INVISIBLE
};
virtual void OnCaptureFailure(FailureReason reason) = 0;
private:
typedef api::types::ImageDetails ImageDetails;
void CopyFromBackingStoreComplete(bool succeed, const SkBitmap& bitmap);
void GetSnapshotFromRendererComplete(bool succeeded, const SkBitmap& bitmap);
void OnCaptureSuccess(const SkBitmap& bitmap);
int context_id_;
ImageDetails::Format image_format_;
int image_quality_;
DISALLOW_COPY_AND_ASSIGN(CaptureWebContentsFunction);
};
}
#endif