From c2996d4fd16195a58810177753ca33468afe1739 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Tue, 4 Mar 2014 15:46:12 +0800 Subject: [PATCH] Take control if devtools is undocked. --- browser/native_window.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/browser/native_window.cc b/browser/native_window.cc index 3d3d38474c10..72db7ef77a6c 100644 --- a/browser/native_window.cc +++ b/browser/native_window.cc @@ -180,12 +180,15 @@ bool NativeWindow::HasModalDialog() { } void NativeWindow::OpenDevTools() { - // Check if the devtools is docked. + // Check if the devtools is undocked. AtomBrowserContext* browser_context = AtomBrowserContext::Get(); std::string dock_side = browser_context->prefs()->GetString(kDockSidePref); - if (dock_side == "undocked") - browser_context->prefs()->SetString(kDockSidePref, "bottom"); + if (dock_side == "undocked") { + Debug(GetWebContents()); + return; + } + // For docked devtools we give it to brightray. inspectable_web_contents()->ShowDevTools(); // Intercept the requestSetDockSide message of devtools. @@ -494,14 +497,14 @@ bool NativeWindow::OnRequestSetDockSide(const base::ListValue& args) { static_cast( inspectable_web_contents()); - // Do not allow the "undocked" state. + // Takeover when devtools is undocked. std::string dock_side; if (args.GetString(0, &dock_side) && dock_side == "undocked") { delegate->CloseWindow(); - return true; + Debug(GetWebContents()); + } else { + delegate->SetDockSide(dock_side); } - - delegate->SetDockSide(dock_side); return true; }