Store the devtools window in weak pointer.

This commit is contained in:
Cheng Zhao 2014-03-04 18:42:37 +08:00
parent 391468ece0
commit 6bd0b82b2e
2 changed files with 19 additions and 5 deletions

View file

@ -181,8 +181,10 @@ bool NativeWindow::HasModalDialog() {
}
void NativeWindow::OpenDevTools() {
// For docked devtools we give it to brightray.
inspectable_web_contents()->ShowDevTools();
if (devtools_window_)
devtools_window_->Focus(true);
else
inspectable_web_contents()->ShowDevTools();
}
void NativeWindow::CloseDevTools() {
@ -472,11 +474,17 @@ void NativeWindow::Observe(int type,
bool NativeWindow::DevToolsSetDockSide(const std::string& dock_side,
bool* succeed) {
if (dock_side != "undocked")
if (dock_side != "undocked") {
// Switch to docked mode.
if (devtools_window_) {
devtools_window_->Close();
devtools_window_.reset();
}
return false;
}
CloseDevTools();
Debug(GetWebContents());
devtools_window_ = Debug(GetWebContents())->GetWeakPtr();
return true;
}
@ -484,7 +492,7 @@ bool NativeWindow::DevToolsShow(const std::string& dock_side) {
if (dock_side != "undocked")
return false;
Debug(GetWebContents());
devtools_window_ = Debug(GetWebContents())->GetWeakPtr();
return true;
}