OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/webui/workers_ui.h" | 5 #include "chrome/browser/ui/webui/workers_ui.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
11 #include "base/values.h" | 11 #include "base/values.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" | 13 #include "chrome/browser/ui/webui/chrome_url_data_manager_backend.h" |
14 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 14 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "content/browser/debugger/worker_devtools_manager_io.h" |
16 #include "content/browser/tab_contents/tab_contents.h" | 17 #include "content/browser/tab_contents/tab_contents.h" |
17 #include "content/browser/worker_host/worker_process_host.h" | 18 #include "content/browser/worker_host/worker_process_host.h" |
18 #include "content/common/devtools_messages.h" | 19 #include "content/common/devtools_messages.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/workers_resources.h" | 21 #include "grit/workers_resources.h" |
21 #include "ui/base/resource/resource_bundle.h" | 22 #include "ui/base/resource/resource_bundle.h" |
22 | 23 |
23 static const char kWorkersDataFile[] = "workers_data.json"; | 24 static const char kWorkersDataFile[] = "workers_data.json"; |
24 | 25 |
25 static const char kOpenDevToolsCommand[] = "openDevTools"; | 26 static const char kOpenDevToolsCommand[] = "openDevTools"; |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 DISALLOW_COPY_AND_ASSIGN(WorkersDOMHandler); | 123 DISALLOW_COPY_AND_ASSIGN(WorkersDOMHandler); |
123 }; | 124 }; |
124 | 125 |
125 void WorkersDOMHandler::RegisterMessages() { | 126 void WorkersDOMHandler::RegisterMessages() { |
126 web_ui_->RegisterMessageCallback(kOpenDevToolsCommand, | 127 web_ui_->RegisterMessageCallback(kOpenDevToolsCommand, |
127 NewCallback(this, &WorkersDOMHandler::HandleOpenDevTools)); | 128 NewCallback(this, &WorkersDOMHandler::HandleOpenDevTools)); |
128 } | 129 } |
129 | 130 |
130 static void OpenDevToolsOnIOThread(int worker_process_host_id, | 131 static void OpenDevToolsOnIOThread(int worker_process_host_id, |
131 int worker_route_id) { | 132 int worker_route_id) { |
132 // TODO(yurys): implement. | 133 WorkerDevToolsManagerIO::GetInstance()->OpenDevToolsForWorker( |
133 NOTIMPLEMENTED(); | 134 worker_process_host_id, worker_route_id); |
134 } | 135 } |
135 | 136 |
136 void WorkersDOMHandler::HandleOpenDevTools(const ListValue* args) { | 137 void WorkersDOMHandler::HandleOpenDevTools(const ListValue* args) { |
137 std::string worker_process_host_id_str; | 138 std::string worker_process_host_id_str; |
138 std::string worker_route_id_str; | 139 std::string worker_route_id_str; |
139 int worker_process_host_id; | 140 int worker_process_host_id; |
140 int worker_route_id; | 141 int worker_route_id; |
141 CHECK(args->GetSize() == 2); | 142 CHECK(args->GetSize() == 2); |
142 CHECK(args->GetString(0, &worker_process_host_id_str)); | 143 CHECK(args->GetString(0, &worker_process_host_id_str)); |
143 CHECK(args->GetString(1, &worker_route_id_str)); | 144 CHECK(args->GetString(1, &worker_route_id_str)); |
144 CHECK(base::StringToInt(worker_process_host_id_str, | 145 CHECK(base::StringToInt(worker_process_host_id_str, |
145 &worker_process_host_id)); | 146 &worker_process_host_id)); |
146 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id)); | 147 CHECK(base::StringToInt(worker_route_id_str, &worker_route_id)); |
147 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableFunction( | 148 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, NewRunnableFunction( |
148 &OpenDevToolsOnIOThread, worker_process_host_id, worker_route_id)); | 149 &OpenDevToolsOnIOThread, worker_process_host_id, worker_route_id)); |
149 } | 150 } |
150 | 151 |
151 } // namespace | 152 } // namespace |
152 | 153 |
153 WorkersUI::WorkersUI(TabContents* contents) : ChromeWebUI(contents) { | 154 WorkersUI::WorkersUI(TabContents* contents) : ChromeWebUI(contents) { |
154 WorkersDOMHandler* handler = new WorkersDOMHandler(); | 155 WorkersDOMHandler* handler = new WorkersDOMHandler(); |
155 AddMessageHandler(handler); | 156 AddMessageHandler(handler); |
156 handler->Attach(this); | 157 handler->Attach(this); |
157 | 158 |
158 WorkersUIHTMLSource* html_source = new WorkersUIHTMLSource(); | 159 WorkersUIHTMLSource* html_source = new WorkersUIHTMLSource(); |
159 | 160 |
160 // Set up the chrome://workers/ source. | 161 // Set up the chrome://workers/ source. |
161 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); | 162 contents->profile()->GetChromeURLDataManager()->AddDataSource(html_source); |
162 } | 163 } |
OLD | NEW |