Merge pull request #219 from deepak1556/devtools_lifecycle_events_patch

notify devtools open and close once per lifetime
This commit is contained in:
Cheng Zhao 2016-05-13 09:14:44 +09:00
commit 768efe89cf
4 changed files with 4 additions and 10 deletions

View file

@ -370,7 +370,7 @@ void InspectableWebContentsImpl::LoadCompleted() {
SetIsDocked(DispatchCallback(), false); SetIsDocked(DispatchCallback(), false);
if (view_->GetDelegate()) if (view_->GetDelegate())
view_->GetDelegate()->DevToolsLoaded(); view_->GetDelegate()->DevToolsOpened();
} }
void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) { void InspectableWebContentsImpl::SetInspectedPageBounds(const gfx::Rect& rect) {
@ -621,6 +621,9 @@ void InspectableWebContentsImpl::WebContentsDestroyed() {
for (const auto& pair : pending_requests_) for (const auto& pair : pending_requests_)
delete pair.first; delete pair.first;
if (view_ && view_->GetDelegate())
view_->GetDelegate()->DevToolsClosed();
} }
bool InspectableWebContentsImpl::AddMessageToConsole( bool InspectableWebContentsImpl::AddMessageToConsole(

View file

@ -12,7 +12,6 @@ class InspectableWebContentsViewDelegate {
virtual void DevToolsFocused() {} virtual void DevToolsFocused() {}
virtual void DevToolsOpened() {} virtual void DevToolsOpened() {}
virtual void DevToolsClosed() {} virtual void DevToolsClosed() {}
virtual void DevToolsLoaded() {}
// Returns the icon of devtools window. // Returns the icon of devtools window.
virtual gfx::ImageSkia GetDevToolsWindowIcon(); virtual gfx::ImageSkia GetDevToolsWindowIcon();

View file

@ -29,14 +29,10 @@ gfx::NativeView InspectableWebContentsViewMac::GetNativeView() const {
void InspectableWebContentsViewMac::ShowDevTools() { void InspectableWebContentsViewMac::ShowDevTools() {
[view_ setDevToolsVisible:YES]; [view_ setDevToolsVisible:YES];
if (GetDelegate())
GetDelegate()->DevToolsOpened();
} }
void InspectableWebContentsViewMac::CloseDevTools() { void InspectableWebContentsViewMac::CloseDevTools() {
[view_ setDevToolsVisible:NO]; [view_ setDevToolsVisible:NO];
if (GetDelegate())
GetDelegate()->DevToolsClosed();
} }
bool InspectableWebContentsViewMac::IsDevToolsViewShowing() { bool InspectableWebContentsViewMac::IsDevToolsViewShowing() {

View file

@ -118,8 +118,6 @@ void InspectableWebContentsViewViews::ShowDevTools() {
devtools_web_view_->RequestFocus(); devtools_web_view_->RequestFocus();
Layout(); Layout();
} }
if (GetDelegate())
GetDelegate()->DevToolsOpened();
} }
void InspectableWebContentsViewViews::CloseDevTools() { void InspectableWebContentsViewViews::CloseDevTools() {
@ -137,8 +135,6 @@ void InspectableWebContentsViewViews::CloseDevTools() {
devtools_web_view_->SetWebContents(NULL); devtools_web_view_->SetWebContents(NULL);
Layout(); Layout();
} }
if (GetDelegate())
GetDelegate()->DevToolsClosed();
} }
bool InspectableWebContentsViewViews::IsDevToolsViewShowing() { bool InspectableWebContentsViewViews::IsDevToolsViewShowing() {