summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/debugger/debugger.vcproj12
-rw-r--r--chrome/browser/debugger/debugger_contents.cc27
-rw-r--r--chrome/browser/debugger/debugger_host.h43
-rw-r--r--chrome/browser/debugger/debugger_host_impl.cpp188
-rw-r--r--chrome/browser/debugger/debugger_host_impl.h51
-rw-r--r--chrome/browser/debugger/debugger_io.h12
-rw-r--r--chrome/browser/debugger/debugger_io_socket.cc6
-rw-r--r--chrome/browser/debugger/debugger_io_socket.h4
-rw-r--r--chrome/browser/debugger/debugger_shell.h3
-rw-r--r--chrome/browser/debugger/debugger_view.cc46
-rw-r--r--chrome/browser/debugger/debugger_view.h9
-rw-r--r--chrome/browser/debugger/debugger_window.cc43
-rw-r--r--chrome/browser/debugger/debugger_window.h17
-rw-r--r--chrome/browser/debugger/debugger_wrapper.cc11
-rw-r--r--chrome/browser/debugger/debugger_wrapper.h8
15 files changed, 391 insertions, 89 deletions
diff --git a/chrome/browser/debugger/debugger.vcproj b/chrome/browser/debugger/debugger.vcproj
index 38c32fd..2ef5241 100644
--- a/chrome/browser/debugger/debugger.vcproj
+++ b/chrome/browser/debugger/debugger.vcproj
@@ -150,6 +150,18 @@
>
</File>
<File
+ RelativePath=".\debugger_host.h"
+ >
+ </File>
+ <File
+ RelativePath=".\debugger_host_impl.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\debugger_host_impl.h"
+ >
+ </File>
+ <File
RelativePath=".\debugger_io.h"
>
</File>
diff --git a/chrome/browser/debugger/debugger_contents.cc b/chrome/browser/debugger/debugger_contents.cc
index 2b3e998..37cb1d0 100644
--- a/chrome/browser/debugger/debugger_contents.cc
+++ b/chrome/browser/debugger/debugger_contents.cc
@@ -78,33 +78,32 @@ class DebuggerHTMLSource : public ChromeURLDataManager::DataSource {
class DebuggerHandler : public DOMMessageHandler {
public:
explicit DebuggerHandler(DOMUIHost* host) {
- host->RegisterMessageCallback("command",
- NewCallback(this, &DebuggerHandler::HandleCommand));
+ host->RegisterMessageCallback("DebuggerHostMessage",
+ NewCallback(this, &DebuggerHandler::HandleDebuggerHostMessage));
}
- void HandleCommand(const Value* content) {
- // Extract the parameters out of the input list.
+ void HandleDebuggerHostMessage(const Value* content) {
if (!content || !content->IsType(Value::TYPE_LIST)) {
NOTREACHED();
return;
}
const ListValue* args = static_cast<const ListValue*>(content);
- if (args->GetSize() != 1) {
+ if (args->GetSize() < 1) {
NOTREACHED();
return;
}
- std::wstring command;
- Value* value = NULL;
- if (!args->Get(0, &value) || !value->GetAsString(&command)) {
+
+#ifndef CHROME_DEBUGGER_DISABLED
+ DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
+ DebuggerHost* debugger_host = wrapper->GetDebugger();
+ if (!debugger_host) {
NOTREACHED();
return;
}
-#ifndef CHROME_DEBUGGER_DISABLED
- DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
- DebuggerShell* shell = wrapper->GetDebugger();
- shell->ProcessCommand(command);
+ debugger_host->OnDebuggerHostMsg(args);
#endif
}
+
private:
DISALLOW_EVIL_CONSTRUCTORS(DebuggerHandler);
};
@@ -127,8 +126,6 @@ void DebuggerContents::AttachMessageHandlers() {
// static
bool DebuggerContents::IsDebuggerUrl(const GURL& url) {
- if (url.SchemeIs("chrome-resource") && url.host() == "debugger")
- return true;
- return false;
+ return (url.SchemeIs("chrome-resource") && url.host() == "inspector");
}
diff --git a/chrome/browser/debugger/debugger_host.h b/chrome/browser/debugger/debugger_host.h
new file mode 100644
index 0000000..bfb2efa
--- /dev/null
+++ b/chrome/browser/debugger/debugger_host.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// A part of browser-side server debugger exposed to DebuggerWrapper.
+
+#ifndef CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_H_
+#define CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_H_
+
+#include "base/basictypes.h"
+#include "base/thread.h"
+
+class ListValue;
+
+class DebuggerHost : public base::RefCountedThreadSafe<DebuggerHost> {
+ public:
+ DebuggerHost() {};
+ virtual ~DebuggerHost() {};
+
+ // call before other methods
+ virtual void Start() = 0;
+
+ // A message from the V8 debugger in the renderer being debugged via
+ // RenderViewHost
+ virtual void DebugMessage(const std::wstring& msg) = 0;
+ // We've been successfully attached to a renderer.
+ virtual void OnDebugAttach() = 0;
+ // The renderer we're attached to is gone.
+ virtual void OnDebugDisconnect() = 0;
+
+ virtual void DidDisconnect() = 0;
+ virtual void DidConnect() {}
+ virtual void ProcessCommand(const std::wstring& data) {}
+
+ // Handles messages from debugger UI.
+ virtual void OnDebuggerHostMsg(const ListValue* args) {}
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(DebuggerHost);
+};
+
+#endif // CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_H_
+
diff --git a/chrome/browser/debugger/debugger_host_impl.cpp b/chrome/browser/debugger/debugger_host_impl.cpp
new file mode 100644
index 0000000..c2eb41d
--- /dev/null
+++ b/chrome/browser/debugger/debugger_host_impl.cpp
@@ -0,0 +1,188 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/debugger/debugger_host_impl.h"
+
+#include "base/json_reader.h"
+#include "base/string_util.h"
+#include "chrome/browser/debugger/debugger_io.h"
+#include "chrome/browser/debugger/debugger_wrapper.h"
+#include "chrome/browser/render_view_host.h"
+#include "chrome/browser/web_contents.h"
+#include "chrome/common/notification_service.h"
+
+class TabContentsReference : public NotificationObserver {
+ public:
+ TabContentsReference(TabContents *c) : navigation_controller_(NULL) {
+ navigation_controller_ = c->controller();
+
+ NotificationService* service = NotificationService::current();
+ DCHECK(service);
+ service->AddObserver(this, NOTIFY_TAB_CLOSING,
+ Source<NavigationController>(navigation_controller_));
+ observing_ = true;
+ }
+
+ virtual ~TabContentsReference() {
+ StopObserving();
+ }
+
+ // NotificationObserver impl
+ virtual void Observe(NotificationType type,
+ const NotificationSource& source,
+ const NotificationDetails& details) {
+ StopObserving();
+ navigation_controller_ = NULL;
+ }
+
+ TabContents* GetTabContents() {
+ if (navigation_controller_) {
+ return navigation_controller_->active_contents();
+ } else {
+ return NULL;
+ }
+ }
+ private:
+ void StopObserving() {
+ if (observing_ && navigation_controller_) {
+ NotificationService* service = NotificationService::current();
+ DCHECK(service);
+ service->RemoveObserver(
+ this,
+ NOTIFY_TAB_CLOSING,
+ Source<NavigationController>(navigation_controller_));
+ observing_ = false;
+ }
+ }
+
+ NavigationController* navigation_controller_;
+ bool observing_;
+
+ DISALLOW_COPY_AND_ASSIGN(TabContentsReference);
+};
+
+
+DebuggerHostImpl::DebuggerHostImpl(DebuggerInputOutput* io)
+ : io_(io),
+ debugger_ready_(true) {
+}
+
+DebuggerHostImpl::~DebuggerHostImpl() {
+ io_->Stop();
+ io_ = NULL;
+}
+
+void DebuggerHostImpl::Start() {
+ io_->Start(this);
+}
+
+void DebuggerHostImpl::Debug(TabContents* tab) {
+ tab_reference_.reset(new TabContentsReference(tab));
+}
+
+void DebuggerHostImpl::DebugMessage(const std::wstring& msg) {
+
+ Value* msg_value = NULL;
+ if (!JSONReader::Read(WideToUTF8(msg), &msg_value, false)) {
+ msg_value = Value::CreateStringValue(L"Message parse error!");
+ }
+ ListValue* argv = new ListValue;
+ argv->Append(msg_value);
+ io_->CallFunctionInPage(L"response", argv);
+}
+
+void DebuggerHostImpl::OnDebugAttach() {
+ std::wstring title;
+ const TabContents* t = GetTabContentsBeingDebugged();
+ if (t) {
+ title = t->GetTitle();
+ }
+
+ ListValue* argv = new ListValue;
+ argv->Append(Value::CreateStringValue(title));
+ io_->CallFunctionInPage(L"on_attach", argv);
+}
+
+void DebuggerHostImpl::OnDebugDisconnect() {
+ ListValue* argv = new ListValue;
+ io_->CallFunctionInPage(L"on_disconnect", argv);
+}
+
+void DebuggerHostImpl::DidDisconnect() {
+ // TODO(yurys): just send Detach from here?
+ ListValue* argv = new ListValue;
+ io_->CallFunctionInPage(L"exit", argv);
+}
+
+void DebuggerHostImpl::OnDebuggerHostMsg(const ListValue* args) {
+ if (args->GetSize() < 1) {
+ NOTREACHED();
+ return;
+ }
+ std::wstring methodName;
+ Value* value = NULL;
+ if (!args->Get(0, &value) || !value->GetAsString(&methodName)) {
+ NOTREACHED();
+ return;
+ }
+
+ const TabContents* t = GetTabContentsBeingDebugged();
+ if (t == NULL) {
+ NOTREACHED();
+ return;
+ }
+ const WebContents* web = t->AsWebContents();
+ if (web == NULL) {
+ NOTREACHED();
+ return;
+ }
+ RenderViewHost* host = web->render_view_host();
+
+ if (methodName == L"attach") {
+ host->DebugAttach();
+ } else if (methodName == L"detach") {
+ host->DebugDetach();
+ } else if (methodName == L"debugBreak") {
+ std::wstring force;
+ Value* value = NULL;
+ if (!args->Get(1, &value) || !value->GetAsString(&force)) {
+ NOTREACHED();
+ return;
+ }
+ host->DebugBreak(force == L"true");
+ } else if (methodName == L"sendToDebugger") {
+ std::wstring cmd;
+ Value* value = NULL;
+ if (!args->Get(1, &value) || !value->GetAsString(&cmd)) {
+ NOTREACHED();
+ return;
+ }
+ host->DebugCommand(cmd);
+
+ } else if (methodName == L"setDebuggerReady") {
+ std::wstring ready;
+ Value* value = NULL;
+ if (!args->Get(1, &value) || !value->GetAsString(&ready)) {
+ NOTREACHED();
+ return;
+ }
+ io_->SetDebuggerReady(ready == L"true");
+ } else if (methodName == L"setDebuggerBreak") {
+ std::wstring brk;
+ Value* value = NULL;
+ if (!args->Get(1, &value) || !value->GetAsString(&brk)) {
+ NOTREACHED();
+ return;
+ }
+ io_->SetDebuggerBreak(brk == L"true");
+ }
+}
+
+TabContents* DebuggerHostImpl::GetTabContentsBeingDebugged() const {
+ if (tab_reference_ != NULL) {
+ return tab_reference_->GetTabContents();
+ } else {
+ return NULL;
+ }
+}
diff --git a/chrome/browser/debugger/debugger_host_impl.h b/chrome/browser/debugger/debugger_host_impl.h
new file mode 100644
index 0000000..ce2c3bb
--- /dev/null
+++ b/chrome/browser/debugger/debugger_host_impl.h
@@ -0,0 +1,51 @@
+// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_IMPL_H__
+#define CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_IMPL_H__
+
+#include "base/scoped_ptr.h"
+#include "chrome/browser/debugger/debugger_host.h"
+
+class DebuggerInputOutput;
+class TabContents;
+class TabContentsReference;
+
+class DebuggerHostImpl : public DebuggerHost {
+ public:
+ DebuggerHostImpl(DebuggerInputOutput *io);
+ virtual ~DebuggerHostImpl();
+
+ virtual void Start();
+
+ // Start debugging the specified tab
+ virtual void Debug(TabContents* tab);
+ // A message from the V8 debugger in the renderer being debugged via
+ // RenderViewHost
+ virtual void DebugMessage(const std::wstring& msg);
+ // We've been successfully attached to a renderer.
+ virtual void OnDebugAttach();
+ // The renderer we're attached to is gone.
+ virtual void OnDebugDisconnect();
+
+ virtual void DidDisconnect();
+
+ // Handles messages from debugger UI.
+ virtual void OnDebuggerHostMsg(const ListValue* args);
+
+ private:
+
+ TabContents* GetTabContentsBeingDebugged() const;
+
+ scoped_refptr<DebuggerInputOutput> io_;
+ // reference to the tab being debugged by this instance
+ scoped_ptr<TabContentsReference> tab_reference_;
+ // If the debugger is ready to process another command or is busy.
+ bool debugger_ready_;
+
+ DISALLOW_COPY_AND_ASSIGN(DebuggerHostImpl);
+};
+
+#endif // CHROME_BROWSER_DEBUGGER_DEBUGGER_HOST_IMPL_H__
+
diff --git a/chrome/browser/debugger/debugger_io.h b/chrome/browser/debugger/debugger_io.h
index 1e4a5f4..b2ea381 100644
--- a/chrome/browser/debugger/debugger_io.h
+++ b/chrome/browser/debugger/debugger_io.h
@@ -6,11 +6,13 @@
#define CHROME_BROWSER_DEBUGGER_DEBUGGER_IO_H_
#include <string>
+#include <vector>
#include "base/basictypes.h"
#include "base/ref_counted.h"
-class DebuggerShell;
+class DebuggerHost;
+class ListValue;
class DebuggerInputOutput
: public base::RefCountedThreadSafe<DebuggerInputOutput> {
@@ -19,7 +21,7 @@ public:
virtual ~DebuggerInputOutput() {}
// Called when Debugger is ready to begin.
- virtual void Start(DebuggerShell* debugger) { debugger_ = debugger; }
+ virtual void Start(DebuggerHost* debugger) { debugger_ = debugger; }
// Called when Debugger is shutting down
virtual void Stop() {}
@@ -39,8 +41,12 @@ public:
// is running, and true when the page is stopped at a breakpoint
virtual void SetDebuggerBreak(bool brk) {}
+ // sends message to debugger UI page in order to invoke JS function in it
+ virtual void CallFunctionInPage(const std::wstring& name,
+ ListValue* argv) {}
+
protected:
- DebuggerShell* debugger_;
+ DebuggerHost* debugger_;
private:
DISALLOW_COPY_AND_ASSIGN(DebuggerInputOutput);
diff --git a/chrome/browser/debugger/debugger_io_socket.cc b/chrome/browser/debugger/debugger_io_socket.cc
index eb3431d..5280600 100644
--- a/chrome/browser/debugger/debugger_io_socket.cc
+++ b/chrome/browser/debugger/debugger_io_socket.cc
@@ -23,7 +23,7 @@ DebuggerInputOutputSocket::DebuggerInputOutputSocket(int port)
io_loop_ = g_browser_process->io_thread()->message_loop();
}
-void DebuggerInputOutputSocket::Start(DebuggerShell* debugger) {
+void DebuggerInputOutputSocket::Start(DebuggerHost* debugger) {
DebuggerInputOutput::Start(debugger);
io_loop_->PostTask(FROM_HERE, NewRunnableMethod(
this, &DebuggerInputOutputSocket::StartListening));
@@ -57,7 +57,7 @@ void DebuggerInputOutputSocket::DidAccept(ListenSocket *server,
connection_ = connection;
connection_->AddRef();
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- debugger_, &DebuggerShell::DidConnect));
+ debugger_, &DebuggerHost::DidConnect));
} else {
delete connection;
}
@@ -114,7 +114,7 @@ void DebuggerInputOutputSocket::DidRead(ListenSocket *connection,
if (connection == connection_) {
const std::wstring wstr = UTF8ToWide(data);
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- debugger_, &DebuggerShell::ProcessCommand, wstr));
+ debugger_, &DebuggerHost::ProcessCommand, wstr));
} else {
// TODO(erikkay): assert?
}
diff --git a/chrome/browser/debugger/debugger_io_socket.h b/chrome/browser/debugger/debugger_io_socket.h
index 884a5d5..551e14d 100644
--- a/chrome/browser/debugger/debugger_io_socket.h
+++ b/chrome/browser/debugger/debugger_io_socket.h
@@ -8,7 +8,7 @@
#include "chrome/browser/debugger/debugger_io.h"
#include "net/base/telnet_server.h"
-class DebuggerShell;
+class DebuggerHost;
class MessageLoop;
// Interaction with the underlying Socket object MUST happen in the IO thread.
@@ -35,7 +35,7 @@ public:
virtual void Output(const std::string& out);
virtual void OutputLine(const std::string& out);
virtual void OutputPrompt(const std::string& prompt);
- virtual void Start(DebuggerShell* debugger);
+ virtual void Start(DebuggerHost* debugger);
// Stop must be called prior to this object being released, so that cleanup
// can happen in the IO thread.
virtual void Stop();
diff --git a/chrome/browser/debugger/debugger_shell.h b/chrome/browser/debugger/debugger_shell.h
index 6068393..bdb5d8a 100644
--- a/chrome/browser/debugger/debugger_shell.h
+++ b/chrome/browser/debugger/debugger_shell.h
@@ -17,6 +17,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
+#include "chrome/browser/debugger/debugger_host.h"
#ifdef CHROME_DEBUGGER_DISABLED
@@ -44,7 +45,7 @@ class DebuggerInputOutput;
class MessageLoop;
class TabContents;
-class DebuggerShell : public base::RefCountedThreadSafe<DebuggerShell> {
+class DebuggerShell : public DebuggerHost {
public:
DebuggerShell(DebuggerInputOutput *io);
virtual ~DebuggerShell();
diff --git a/chrome/browser/debugger/debugger_view.cc b/chrome/browser/debugger/debugger_view.cc
index 6b59cd6..5fd62f1 100644
--- a/chrome/browser/debugger/debugger_view.cc
+++ b/chrome/browser/debugger/debugger_view.cc
@@ -70,6 +70,12 @@ void DebuggerView::SetOutputViewReady() {
Output(*i);
}
pending_output_.clear();
+
+ for (std::vector<std::string>::const_iterator i = pending_events_.begin();
+ i != pending_events_.end(); ++i) {
+ ExecuteJavascript(*i);
+ }
+ pending_events_.clear();
}
void DebuggerView::Output(const std::string& out) {
@@ -81,11 +87,10 @@ void DebuggerView::Output(const std::wstring& out) {
pending_output_.push_back(out);
return;
}
- Value* str_value = Value::CreateStringValue(out);
- std::string json;
- JSONWriter::Write(str_value, false, &json);
- const std::string js = StringPrintf("appendText(%s)", json.c_str());
- ExecuteJavascript(js);
+
+ DictionaryValue* body = new DictionaryValue;
+ body->Set(L"text", Value::CreateStringValue(out));
+ SendEventToPage(L"appendText", body);
}
void DebuggerView::OnInit() {
@@ -100,15 +105,14 @@ void DebuggerView::OnInit() {
web_container_->SetTabContents(web_contents_);
web_contents_->render_view_host()->AllowDOMUIBindings();
- GURL contents("chrome-resource://debugger/");
+ GURL contents("chrome-resource://inspector/debugger.html");
+
web_contents_->controller()->LoadURL(contents, GURL(),
PageTransition::START_PAGE);
}
void DebuggerView::OnShow() {
web_contents_->Focus();
- if (output_ready_)
- ExecuteJavascript("focusOnCommandLine()");
}
void DebuggerView::OnClose() {
@@ -116,12 +120,6 @@ void DebuggerView::OnClose() {
web_contents_->CloseContents();
}
-void DebuggerView::SetDebuggerBreak(bool is_broken) {
- const std::string js =
- StringPrintf("setDebuggerBreak(%s)", is_broken ? "true" : "false");
- ExecuteJavascript(js);
-}
-
void DebuggerView::OpenURLFromTab(TabContents* source,
const GURL& url,
const GURL& referrer,
@@ -131,6 +129,26 @@ void DebuggerView::OpenURLFromTab(TabContents* source,
transition);
}
+
+void DebuggerView::SendEventToPage(const std::wstring& name,
+ Value* body) {
+ DictionaryValue msg;
+ msg.SetString(L"type", L"event");
+ msg.SetString(L"event", name);
+ msg.Set(L"body", body);
+
+ std::string json;
+ JSONWriter::Write(&msg, false, &json);
+
+ const std::string js =
+ StringPrintf("DebuggerIPC.onMessageReceived(%s)", json.c_str());
+ if (output_ready_) {
+ ExecuteJavascript(js);
+ } else {
+ pending_events_.push_back(js);
+ }
+}
+
void DebuggerView::ExecuteJavascript(const std::string& js) {
web_contents_->render_view_host()->ExecuteJavascriptInWebFrame(L"",
UTF8ToWide(js));
diff --git a/chrome/browser/debugger/debugger_view.h b/chrome/browser/debugger/debugger_view.h
index 5a7f775..9603777 100644
--- a/chrome/browser/debugger/debugger_view.h
+++ b/chrome/browser/debugger/debugger_view.h
@@ -18,6 +18,7 @@
class DebuggerView;
class DebuggerWindow;
class TabContentsContainerView;
+class Value;
class WebContents;
class DebuggerView : public views::View,
@@ -38,9 +39,6 @@ class DebuggerView : public views::View,
// Called when the window is being closed.
void OnClose();
- // Called when the debugger hits a breakpoint or continues.
- void SetDebuggerBreak(bool is_broken);
-
void SetOutputViewReady();
// Overridden from views::View:
@@ -81,6 +79,10 @@ class DebuggerView : public views::View,
virtual void UpdateTargetURL(TabContents* source, const GURL& url) {}
virtual bool CanBlur() const { return false; }
+ // To pass messages from DebuggerHost to debugger UI.
+ // Note that this method will take ownership of body.
+ void SendEventToPage(const std::wstring& name, Value* body);
+
private:
void ExecuteJavascript(const std::string& js);
@@ -88,6 +90,7 @@ class DebuggerView : public views::View,
WebContents* web_contents_;
TabContentsContainerView* web_container_;
std::vector<std::wstring> pending_output_;
+ std::vector<std::string> pending_events_;
bool output_ready_;
DISALLOW_EVIL_CONSTRUCTORS(DebuggerView);
diff --git a/chrome/browser/debugger/debugger_window.cc b/chrome/browser/debugger/debugger_window.cc
index 731c907..e340bff 100644
--- a/chrome/browser/debugger/debugger_window.cc
+++ b/chrome/browser/debugger/debugger_window.cc
@@ -5,7 +5,7 @@
#include "base/string_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/constrained_window.h"
-#include "chrome/browser/debugger/debugger_shell.h"
+#include "chrome/browser/debugger/debugger_host_impl.h"
#include "chrome/browser/debugger/debugger_view.h"
#include "chrome/browser/debugger/debugger_window.h"
#include "chrome/browser/debugger/debugger_wrapper.h"
@@ -42,7 +42,7 @@ void DebuggerWindow::Show(TabContents* tab) {
view_->OnShow();
debugger_ready_ = true;
debugger_break_ = false;
- DebuggerShell* debugger = new DebuggerShell(this);
+ DebuggerHostImpl* debugger = new DebuggerHostImpl(this);
DebuggerWrapper* wrapper = g_browser_process->debugger_wrapper();
if (!wrapper) {
g_browser_process->InitDebuggerWrapper(0);
@@ -95,7 +95,7 @@ void DebuggerWindow::OutputLine(const std::string &out) {
void DebuggerWindow::OutputPrompt(const std::string& prompt) {
}
-void DebuggerWindow::Start(DebuggerShell* debugger) {
+void DebuggerWindow::Start(DebuggerHost* debugger) {
#ifndef CHROME_DEBUGGER_DISABLED
DebuggerInputOutput::Start(debugger);
#endif
@@ -116,8 +116,6 @@ void DebuggerWindow::SetDebuggerBreak(bool brk) {
if (debugger_break_ != brk) {
debugger_break_ = brk;
if (window_) {
- if (view_)
- view_->SetDebuggerBreak(brk);
window_->UpdateWindowTitle();
if (brk)
window_->Activate();
@@ -126,6 +124,17 @@ void DebuggerWindow::SetDebuggerBreak(bool brk) {
#endif
}
+void DebuggerWindow::CallFunctionInPage(const std::wstring& name,
+ ListValue* argv) {
+ if (view_) {
+ DictionaryValue* body = new DictionaryValue;
+ body->Set(L"arguments", argv);
+ view_->SendEventToPage(name, body);
+ } else {
+ delete argv;
+ }
+}
+
///////////////////////////////////////////////////////////////////
// views::WindowDelegate methods
@@ -160,27 +169,3 @@ bool DebuggerWindow::CanResize() const {
views::View* DebuggerWindow::GetContentsView() {
return view_;
}
-
-///////////////////////////////////////////////////////////////////
-// Overridden from views::TextField::Controller:
-
-void DebuggerWindow::ContentsChanged(views::TextField* sender,
- const std::wstring& new_contents) {
- //
-}
-
-void DebuggerWindow::HandleKeystroke(views::TextField* sender, UINT message,
- TCHAR key, UINT repeat_count,
- UINT flags) {
-#ifndef CHROME_DEBUGGER_DISABLED
- if (key == VK_RETURN) {
- std::wstring txt = sender->GetText();
- if (txt.length()) {
- view_->Output(L"$ " + txt);
- debugger_->ProcessCommand(txt);
- sender->SetText(L"");
- }
- }
-#endif
-}
-
diff --git a/chrome/browser/debugger/debugger_window.h b/chrome/browser/debugger/debugger_window.h
index 5ea1e57..4b980f3 100644
--- a/chrome/browser/debugger/debugger_window.h
+++ b/chrome/browser/debugger/debugger_window.h
@@ -6,16 +6,15 @@
#define CHROME_BROWSER_DEBUGGER_DEBUGGER_WINDOW_H__
#include "chrome/browser/debugger/debugger_io.h"
-#include "chrome/views/text_field.h"
#include "chrome/views/window.h"
#include "chrome/views/window_delegate.h"
class DebuggerView;
+class ListValue;
class TabContents;
class DebuggerWindow : public DebuggerInputOutput,
- public views::WindowDelegate,
- public views::TextField::Controller {
+ public views::WindowDelegate {
public:
DebuggerWindow();
virtual ~DebuggerWindow();
@@ -33,22 +32,20 @@ class DebuggerWindow : public DebuggerInputOutput,
virtual void Output(const std::string& out);
virtual void OutputLine(const std::string& out);
virtual void OutputPrompt(const std::string& prompt);
- virtual void Start(DebuggerShell* debugger);
+ virtual void Start(DebuggerHost* debugger);
virtual void SetDebuggerReady(bool ready);
virtual void SetDebuggerBreak(bool brk);
+ // Note that this method will take ownership of argv.
+ virtual void CallFunctionInPage(const std::wstring& name,
+ ListValue* argv);
+
// views::WindowDelegate methods:
virtual std::wstring GetWindowTitle() const;
virtual void WindowClosing();
virtual bool CanResize() const;
virtual views::View* GetContentsView();
- // Overridden from views::TextField::Controller:
- virtual void ContentsChanged(views::TextField* sender,
- const std::wstring& new_contents);
- virtual void HandleKeystroke(views::TextField* sender, UINT message,
- TCHAR key, UINT repeat_count, UINT flags);
-
private:
views::Window* window_;
DebuggerView* view_;
diff --git a/chrome/browser/debugger/debugger_wrapper.cc b/chrome/browser/debugger/debugger_wrapper.cc
index 9b29903..674b092 100644
--- a/chrome/browser/debugger/debugger_wrapper.cc
+++ b/chrome/browser/debugger/debugger_wrapper.cc
@@ -2,9 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "debugger_wrapper.h"
-#include "debugger_shell.h"
-#include "debugger_io_socket.h"
+#include "chrome/browser/debugger/debugger_wrapper.h"
+#include "chrome/browser/debugger/debugger_shell.h"
+#include "chrome/browser/debugger/debugger_io_socket.h"
+#include "chrome/browser/debugger/debugger_host.h"
DebuggerWrapper::DebuggerWrapper(int port) {
#ifndef CHROME_DEBUGGER_DISABLED
@@ -19,11 +20,11 @@ DebuggerWrapper::DebuggerWrapper(int port) {
DebuggerWrapper::~DebuggerWrapper() {
}
-void DebuggerWrapper::SetDebugger(DebuggerShell* debugger) {
+void DebuggerWrapper::SetDebugger(DebuggerHost* debugger) {
debugger_ = debugger;
}
-DebuggerShell* DebuggerWrapper::GetDebugger() {
+DebuggerHost* DebuggerWrapper::GetDebugger() {
return debugger_.get();
}
diff --git a/chrome/browser/debugger/debugger_wrapper.h b/chrome/browser/debugger/debugger_wrapper.h
index 2befe70..f1e68cc 100644
--- a/chrome/browser/debugger/debugger_wrapper.h
+++ b/chrome/browser/debugger/debugger_wrapper.h
@@ -23,7 +23,7 @@
#include "base/basictypes.h"
#include "base/ref_counted.h"
-class DebuggerShell;
+class DebuggerHost;
class DebuggerWrapper : public base::RefCountedThreadSafe<DebuggerWrapper> {
public:
@@ -31,8 +31,8 @@ class DebuggerWrapper : public base::RefCountedThreadSafe<DebuggerWrapper> {
virtual ~DebuggerWrapper();
- void SetDebugger(DebuggerShell* debugger);
- DebuggerShell* GetDebugger();
+ void SetDebugger(DebuggerHost* debugger);
+ DebuggerHost* GetDebugger();
void DebugMessage(const std::wstring& msg);
@@ -40,7 +40,7 @@ class DebuggerWrapper : public base::RefCountedThreadSafe<DebuggerWrapper> {
void OnDebugDisconnect();
private:
- scoped_refptr<DebuggerShell> debugger_;
+ scoped_refptr<DebuggerHost> debugger_;
};
#endif // CHROME_BROWSER_DEBUGGER_DEBUGGER_INTERFACE_H_