Merge pull request #5199 from Mr0grog/5183-disambiguate-loading-from-main-frame-loading
Add `isLoadingMainFrame()` to WebContents
This commit is contained in:
commit
aa29dc0c8a
6 changed files with 88 additions and 1 deletions
|
@ -793,6 +793,14 @@ bool WebContents::IsLoading() const {
|
|||
return web_contents()->IsLoading();
|
||||
}
|
||||
|
||||
bool WebContents::IsLoadingMainFrame() const {
|
||||
// Comparing site instances works because Electron always creates a new site
|
||||
// instance when navigating, regardless of origin. See AtomBrowserClient.
|
||||
return (web_contents()->GetLastCommittedURL().is_empty() ||
|
||||
web_contents()->GetSiteInstance() !=
|
||||
web_contents()->GetPendingSiteInstance()) && IsLoading();
|
||||
}
|
||||
|
||||
bool WebContents::IsWaitingForResponse() const {
|
||||
return web_contents()->IsWaitingForResponse();
|
||||
}
|
||||
|
@ -1195,6 +1203,7 @@ void WebContents::BuildPrototype(v8::Isolate* isolate,
|
|||
.SetMethod("_getURL", &WebContents::GetURL)
|
||||
.SetMethod("getTitle", &WebContents::GetTitle)
|
||||
.SetMethod("isLoading", &WebContents::IsLoading)
|
||||
.SetMethod("isLoadingMainFrame", &WebContents::IsLoadingMainFrame)
|
||||
.SetMethod("isWaitingForResponse", &WebContents::IsWaitingForResponse)
|
||||
.SetMethod("_stop", &WebContents::Stop)
|
||||
.SetMethod("_goBack", &WebContents::GoBack)
|
||||
|
|
|
@ -62,6 +62,7 @@ class WebContents : public mate::TrackableObject<WebContents>,
|
|||
GURL GetURL() const;
|
||||
base::string16 GetTitle() const;
|
||||
bool IsLoading() const;
|
||||
bool IsLoadingMainFrame() const;
|
||||
bool IsWaitingForResponse() const;
|
||||
void Stop();
|
||||
void ReloadIgnoringCache();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue