refactor: remove WebContents::CreateFrom (#15241)

This commit is contained in:
Cheng Zhao 2018-10-19 17:52:07 +09:00 committed by GitHub
parent b3f134de06
commit 94aa0762f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 85 additions and 51 deletions

View file

@ -82,18 +82,29 @@ class WebContents : public mate::TrackableObject<WebContents>,
using PrintToPDFCallback =
base::Callback<void(v8::Local<v8::Value>, v8::Local<v8::Value>)>;
// Create from an existing WebContents.
static mate::Handle<WebContents> CreateFrom(
v8::Isolate* isolate,
content::WebContents* web_contents);
static mate::Handle<WebContents> CreateFrom(
// Create a new WebContents and return the V8 wrapper of it.
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
const mate::Dictionary& options);
// Create a new V8 wrapper for an existing |web_content|.
//
// The lifetime of |web_contents| will be managed by this class.
static mate::Handle<WebContents> CreateAndTake(
v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
// Create a new WebContents.
static mate::Handle<WebContents> Create(v8::Isolate* isolate,
const mate::Dictionary& options);
// Get the V8 wrapper of |web_content|, return empty handle if not wrapped.
static mate::Handle<WebContents> From(v8::Isolate* isolate,
content::WebContents* web_content);
// Get the V8 wrapper of the |web_contents|, or create one if not existed.
//
// The lifetime of |web_contents| is NOT managed by this class, and the type
// of this wrapper is always REMOTE.
static mate::Handle<WebContents> FromOrCreate(
v8::Isolate* isolate,
content::WebContents* web_contents);
static void BuildPrototype(v8::Isolate* isolate,
v8::Local<v8::FunctionTemplate> prototype);
@ -281,9 +292,13 @@ class WebContents : public mate::TrackableObject<WebContents>,
content::NavigationHandle* navigation_handle);
protected:
// Does not manage lifetime of |web_contents|.
WebContents(v8::Isolate* isolate, content::WebContents* web_contents);
// Takes over ownership of |web_contents|.
WebContents(v8::Isolate* isolate,
content::WebContents* web_contents,
Type type);
// Creates a new content::WebContents.
WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents() override;