Disable the undocked devtools.
This commit is contained in:
parent
59a2430f1d
commit
1c07235121
3 changed files with 44 additions and 13 deletions
|
@ -7,6 +7,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "base/file_util.h"
|
||||
#include "base/prefs/pref_service.h"
|
||||
#include "base/message_loop/message_loop.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "base/strings/utf_string_conversions.h"
|
||||
|
@ -38,13 +39,18 @@
|
|||
#include "ui/gfx/point.h"
|
||||
#include "ui/gfx/rect.h"
|
||||
#include "ui/gfx/size.h"
|
||||
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
||||
#include "webkit/common/user_agent/user_agent_util.h"
|
||||
|
||||
using content::NavigationEntry;
|
||||
|
||||
namespace atom {
|
||||
|
||||
namespace {
|
||||
|
||||
const char kDockSidePref[] = "brightray.devtools.dockside";
|
||||
|
||||
} // namespace
|
||||
|
||||
NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||
base::DictionaryValue* options)
|
||||
: content::WebContentsObserver(web_contents),
|
||||
|
@ -166,7 +172,19 @@ bool NativeWindow::HasModalDialog() {
|
|||
}
|
||||
|
||||
void NativeWindow::OpenDevTools() {
|
||||
// Check if the devtools is docked.
|
||||
AtomBrowserContext* browser_context = AtomBrowserContext::Get();
|
||||
std::string dock_side = browser_context->prefs()->GetString(kDockSidePref);
|
||||
if (dock_side == "undocked")
|
||||
browser_context->prefs()->SetString(kDockSidePref, "bottom");
|
||||
|
||||
inspectable_web_contents()->ShowDevTools();
|
||||
|
||||
// Intercept the requestSetDockSide message of devtools.
|
||||
inspectable_web_contents()->embedder_message_dispatcher()->
|
||||
RegisterHandler("requestSetDockSide",
|
||||
base::Bind(&NativeWindow::OnRequestSetDockSide,
|
||||
base::Unretained(this)));
|
||||
}
|
||||
|
||||
void NativeWindow::CloseDevTools() {
|
||||
|
@ -283,10 +301,7 @@ content::WebContents* NativeWindow::GetWebContents() const {
|
|||
}
|
||||
|
||||
content::WebContents* NativeWindow::GetDevToolsWebContents() const {
|
||||
brightray::InspectableWebContentsImpl* inspectable_web_contents_impl =
|
||||
static_cast<brightray::InspectableWebContentsImpl*>(
|
||||
inspectable_web_contents());
|
||||
return inspectable_web_contents_impl->devtools_web_contents();
|
||||
return inspectable_web_contents()->devtools_web_contents();
|
||||
}
|
||||
|
||||
void NativeWindow::NotifyWindowClosed() {
|
||||
|
@ -476,6 +491,22 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
|||
callback.Run(data);
|
||||
}
|
||||
|
||||
bool NativeWindow::OnRequestSetDockSide(const base::ListValue& args) {
|
||||
brightray::DevToolsEmbedderMessageDispatcher::Delegate* delegate =
|
||||
static_cast<brightray::DevToolsEmbedderMessageDispatcher::Delegate*>(
|
||||
inspectable_web_contents());
|
||||
|
||||
// Do not allow the "undocked" state.
|
||||
std::string dock_side;
|
||||
if (args.GetString(0, &dock_side) && dock_side == "undocked") {
|
||||
delegate->CloseWindow();
|
||||
return true;
|
||||
}
|
||||
|
||||
delegate->SetDockSide(dock_side);
|
||||
return true;
|
||||
}
|
||||
|
||||
void NativeWindow::OnRendererMessage(const string16& channel,
|
||||
const base::ListValue& args) {
|
||||
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
|
||||
|
|
|
@ -14,19 +14,15 @@
|
|||
#include "browser/native_window_observer.h"
|
||||
#include "content/public/browser/notification_registrar.h"
|
||||
#include "content/public/browser/notification_observer.h"
|
||||
#include "content/public/browser/web_contents_observer.h"
|
||||
#include "ui/gfx/image/image.h"
|
||||
#include "vendor/brightray/browser/default_web_contents_delegate.h"
|
||||
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
||||
|
||||
namespace base {
|
||||
class DictionaryValue;
|
||||
class ListValue;
|
||||
}
|
||||
|
||||
namespace brightray {
|
||||
class InspectableWebContents;
|
||||
}
|
||||
|
||||
namespace content {
|
||||
class BrowserContext;
|
||||
class WebContents;
|
||||
|
@ -174,8 +170,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
explicit NativeWindow(content::WebContents* web_contents,
|
||||
base::DictionaryValue* options);
|
||||
|
||||
brightray::InspectableWebContents* inspectable_web_contents() const {
|
||||
return inspectable_web_contents_.get();
|
||||
brightray::InspectableWebContentsImpl* inspectable_web_contents() const {
|
||||
return static_cast<brightray::InspectableWebContentsImpl*>(
|
||||
inspectable_web_contents_.get());
|
||||
}
|
||||
|
||||
void NotifyWindowClosed();
|
||||
|
@ -232,6 +229,9 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
|||
bool succeed,
|
||||
const SkBitmap& bitmap);
|
||||
|
||||
// Handler for the requestSetDockSide message from devtools.
|
||||
bool OnRequestSetDockSide(const base::ListValue&);
|
||||
|
||||
void OnRendererMessage(const string16& channel,
|
||||
const base::ListValue& args);
|
||||
|
||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 569ea3f1e14b9214528be09dfc2117e387c0a03f
|
||||
Subproject commit 90ea5b1d3b9147ae935e5077fbb40fa70a15b4f2
|
Loading…
Reference in a new issue