| Index: chrome/browser/ui/webui/workers_ui.cc
|
| diff --git a/chrome/browser/ui/webui/workers_ui.cc b/chrome/browser/ui/webui/workers_ui.cc
|
| index 0dd34a69db58b188720d890fe48e63830deae7c3..62cde037284319addcab6156cb190d9e48472099 100644
|
| --- a/chrome/browser/ui/webui/workers_ui.cc
|
| +++ b/chrome/browser/ui/webui/workers_ui.cc
|
| @@ -6,14 +6,17 @@
|
|
|
| #include "base/json/json_writer.h"
|
| #include "base/memory/ref_counted_memory.h"
|
| +#include "base/string_number_conversions.h"
|
| #include "base/string_util.h"
|
| #include "base/values.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h"
|
| #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h"
|
| #include "chrome/common/url_constants.h"
|
| +#include "content/browser/debugger/worker_devtools_manager.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
| #include "content/browser/worker_host/worker_process_host.h"
|
| +#include "content/common/devtools_messages.h"
|
| #include "grit/generated_resources.h"
|
| #include "grit/workers_resources.h"
|
| #include "ui/base/resource/resource_bundle.h"
|
| @@ -79,7 +82,8 @@ void WorkersUIHTMLSource::SendSharedWorkersData(int request_id) {
|
| if (!i->shared())
|
| continue;
|
| DictionaryValue* worker_data = new DictionaryValue();
|
| - worker_data->SetInteger("id", i->worker_route_id());
|
| + worker_data->SetInteger("workerProcessHostId", worker->id());
|
| + worker_data->SetInteger("workerRouteId", i->worker_route_id());
|
| worker_data->SetString("url", i->url().spec());
|
| worker_data->SetString("name", i->name());
|
| worker_data->SetInteger("pid", worker->pid());
|
| @@ -97,9 +101,54 @@ void WorkersUIHTMLSource::SendSharedWorkersData(int request_id) {
|
| SendResponse(request_id, json_bytes);
|
| }
|
|
|
| +class WorkersDOMHandler : public WebUIMessageHandler {
|
| + public:
|
| + WorkersDOMHandler() {}
|
| + virtual ~WorkersDOMHandler() {}
|
| +
|
| + private:
|
| + // WebUIMessageHandler implementation.
|
| + virtual void RegisterMessages();
|
| +
|
| + // Callback for "openDevTools" message.
|
| + void HandleOpenDevTools(const ListValue* args);
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(WorkersDOMHandler);
|
| +};
|
| +
|
| +void WorkersDOMHandler::RegisterMessages() {
|
| + web_ui_->RegisterMessageCallback("openDevTools",
|
| + NewCallback(this, &WorkersDOMHandler::HandleOpenDevTools));
|
| +}
|
| +
|
| +static void OpenDevToolsOnIOThread(int worker_process_host_id,
|
| + int worker_route_id) {
|
| + WorkerDevToolsManager::GetInstance()->OpenDevToolsForWorker(
|
| + worker_process_host_id, worker_route_id);
|
| +}
|
| +
|
| +void WorkersDOMHandler::HandleOpenDevTools(const ListValue* args) {
|
| + std::string worker_process_host_id_str;
|
| + std::string worker_route_id_str;
|
| + int worker_process_host_id;
|
| + int worker_route_id;
|
| + CHECK(args->GetSize() == 2);
|
| + CHECK(args->GetString(0, &worker_process_host_id_str));
|
| + CHECK(args->GetString(1, &worker_route_id_str));
|
| + CHECK(base::StringToInt(worker_process_host_id_str,
|
| + &worker_process_host_id));
|
| + CHECK(base::StringToInt(worker_route_id_str, &worker_route_id));
|
| + BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableFunction(
|
| + &OpenDevToolsOnIOThread, worker_process_host_id, worker_route_id));
|
| +}
|
| +
|
| } // namespace
|
|
|
| WorkersUI::WorkersUI(TabContents* contents) : ChromeWebUI(contents) {
|
| + WorkersDOMHandler* handler = new WorkersDOMHandler();
|
| + AddMessageHandler(handler);
|
| + handler->Attach(this);
|
| +
|
| WorkersUIHTMLSource* html_source = new WorkersUIHTMLSource();
|
|
|
| // Set up the chrome://workers/ source.
|
|
|