Use InspectableWebContentsDelegate.
This commit is contained in:
parent
c2996d4fd1
commit
5e05a3045c
3 changed files with 27 additions and 34 deletions
|
@ -72,6 +72,7 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
|
||||||
options->GetString(switches::kNodeIntegration, &node_integration_);
|
options->GetString(switches::kNodeIntegration, &node_integration_);
|
||||||
|
|
||||||
web_contents->SetDelegate(this);
|
web_contents->SetDelegate(this);
|
||||||
|
inspectable_web_contents()->SetDelegate(this);
|
||||||
|
|
||||||
WindowList::AddWindow(this);
|
WindowList::AddWindow(this);
|
||||||
|
|
||||||
|
@ -180,22 +181,8 @@ bool NativeWindow::HasModalDialog() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeWindow::OpenDevTools() {
|
void NativeWindow::OpenDevTools() {
|
||||||
// Check if the devtools is undocked.
|
|
||||||
AtomBrowserContext* browser_context = AtomBrowserContext::Get();
|
|
||||||
std::string dock_side = browser_context->prefs()->GetString(kDockSidePref);
|
|
||||||
if (dock_side == "undocked") {
|
|
||||||
Debug(GetWebContents());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// For docked devtools we give it to brightray.
|
// For docked devtools we give it to brightray.
|
||||||
inspectable_web_contents()->ShowDevTools();
|
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() {
|
void NativeWindow::CloseDevTools() {
|
||||||
|
@ -483,6 +470,24 @@ void NativeWindow::Observe(int type,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NativeWindow::DevToolsSetDockSide(const std::string& dock_side,
|
||||||
|
bool* succeed) {
|
||||||
|
if (dock_side != "undocked")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
CloseDevTools();
|
||||||
|
Debug(GetWebContents());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NativeWindow::DevToolsShow(const std::string& dock_side) {
|
||||||
|
if (dock_side != "undocked")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Debug(GetWebContents());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
bool succeed,
|
bool succeed,
|
||||||
const SkBitmap& bitmap) {
|
const SkBitmap& bitmap) {
|
||||||
|
@ -492,22 +497,6 @@ void NativeWindow::OnCapturePageDone(const CapturePageCallback& callback,
|
||||||
callback.Run(data);
|
callback.Run(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NativeWindow::OnRequestSetDockSide(const base::ListValue& args) {
|
|
||||||
brightray::DevToolsEmbedderMessageDispatcher::Delegate* delegate =
|
|
||||||
static_cast<brightray::DevToolsEmbedderMessageDispatcher::Delegate*>(
|
|
||||||
inspectable_web_contents());
|
|
||||||
|
|
||||||
// Takeover when devtools is undocked.
|
|
||||||
std::string dock_side;
|
|
||||||
if (args.GetString(0, &dock_side) && dock_side == "undocked") {
|
|
||||||
delegate->CloseWindow();
|
|
||||||
Debug(GetWebContents());
|
|
||||||
} else {
|
|
||||||
delegate->SetDockSide(dock_side);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeWindow::OnRendererMessage(const string16& channel,
|
void NativeWindow::OnRendererMessage(const string16& channel,
|
||||||
const base::ListValue& args) {
|
const base::ListValue& args) {
|
||||||
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
|
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "content/public/browser/notification_observer.h"
|
#include "content/public/browser/notification_observer.h"
|
||||||
#include "ui/gfx/image/image.h"
|
#include "ui/gfx/image/image.h"
|
||||||
#include "vendor/brightray/browser/default_web_contents_delegate.h"
|
#include "vendor/brightray/browser/default_web_contents_delegate.h"
|
||||||
|
#include "vendor/brightray/browser/inspectable_web_contents_delegate.h"
|
||||||
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
#include "vendor/brightray/browser/inspectable_web_contents_impl.h"
|
||||||
|
|
||||||
namespace base {
|
namespace base {
|
||||||
|
@ -45,6 +46,7 @@ class DevToolsDelegate;
|
||||||
struct DraggableRegion;
|
struct DraggableRegion;
|
||||||
|
|
||||||
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
|
public brightray::InspectableWebContentsDelegate,
|
||||||
public content::WebContentsObserver,
|
public content::WebContentsObserver,
|
||||||
public content::NotificationObserver {
|
public content::NotificationObserver {
|
||||||
public:
|
public:
|
||||||
|
@ -220,6 +222,11 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
const content::NotificationSource& source,
|
const content::NotificationSource& source,
|
||||||
const content::NotificationDetails& details) OVERRIDE;
|
const content::NotificationDetails& details) OVERRIDE;
|
||||||
|
|
||||||
|
// Implementations of brightray::InspectableWebContentsDelegate.
|
||||||
|
virtual bool DevToolsSetDockSide(const std::string& dock_side,
|
||||||
|
bool* succeed) OVERRIDE;
|
||||||
|
virtual bool DevToolsShow(const std::string& side) OVERRIDE;
|
||||||
|
|
||||||
// Whether window has standard frame.
|
// Whether window has standard frame.
|
||||||
bool has_frame_;
|
bool has_frame_;
|
||||||
|
|
||||||
|
@ -232,9 +239,6 @@ class NativeWindow : public brightray::DefaultWebContentsDelegate,
|
||||||
bool succeed,
|
bool succeed,
|
||||||
const SkBitmap& bitmap);
|
const SkBitmap& bitmap);
|
||||||
|
|
||||||
// Handler for the requestSetDockSide message from devtools.
|
|
||||||
bool OnRequestSetDockSide(const base::ListValue&);
|
|
||||||
|
|
||||||
void OnRendererMessage(const string16& channel,
|
void OnRendererMessage(const string16& channel,
|
||||||
const base::ListValue& args);
|
const base::ListValue& args);
|
||||||
|
|
||||||
|
|
2
vendor/brightray
vendored
2
vendor/brightray
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 90ea5b1d3b9147ae935e5077fbb40fa70a15b4f2
|
Subproject commit 8111949e34a17bbeba9246494326bb891f55df34
|
Loading…
Add table
Add a link
Reference in a new issue