Add API to capture a page into file.

This commit is contained in:
Cheng Zhao 2013-11-21 21:50:06 +08:00
parent 9ad3b7939f
commit 36ecb35cb1
2 changed files with 49 additions and 0 deletions

View file

@ -108,6 +108,13 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
virtual void RestartHangMonitorTimeout();
virtual bool SetIcon(const std::string& path);
// Captures the page with |rect| and saves the image to |path|, |callback|
// would be called when capturing is done.
typedef base::Callback<void(bool succeed)> CapturePageCallback;
virtual void CapturePage(const gfx::Rect& rect,
const base::FilePath& path,
const CapturePageCallback& callback);
// The same with closing a tab in a real browser.
//
// Should be called by platform code when user want to close the window.
@ -184,6 +191,12 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
private:
void RendererUnresponsiveDelayed();
// Called when CapturePage has done.
void OnCapturePageDone(const base::FilePath& filename,
const CapturePageCallback& callback,
bool succeed,
const SkBitmap& bitmap);
void OnRendererMessage(const string16& channel,
const base::ListValue& args);