options->GetString(switches::kNodeIntegration, &node_integration_);
web_contents->SetDelegate(this);
+ inspectable_web_contents()->SetDelegate(this);
WindowList::AddWindow(this);
}
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.
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() {
}
}
+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,
bool succeed,
const SkBitmap& bitmap) {
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,
const base::ListValue& args) {
AtomBrowserMainParts::Get()->atom_bindings()->OnRendererMessage(
#include "content/public/browser/notification_observer.h"
#include "ui/gfx/image/image.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"
namespace base {
struct DraggableRegion;
class NativeWindow : public brightray::DefaultWebContentsDelegate,
+ public brightray::InspectableWebContentsDelegate,
public content::WebContentsObserver,
public content::NotificationObserver {
public:
const content::NotificationSource& source,
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.
bool has_frame_;
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);