| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/inspect_ui.h" | 5 #include "chrome/browser/ui/webui/inspect_ui.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 if (rvh) { | 259 if (rvh) { |
| 260 DevToolsWindow::OpenDevToolsWindow(rvh); | 260 DevToolsWindow::OpenDevToolsWindow(rvh); |
| 261 return; | 261 return; |
| 262 } | 262 } |
| 263 | 263 |
| 264 Profile* profile = Profile::FromWebUI(web_ui()); | 264 Profile* profile = Profile::FromWebUI(web_ui()); |
| 265 if (!profile) | 265 if (!profile) |
| 266 return; | 266 return; |
| 267 scoped_refptr<DevToolsAgentHost> agent_host( | 267 scoped_refptr<DevToolsAgentHost> agent_host( |
| 268 DevToolsAgentHost::GetForWorker(process_id, route_id)); | 268 DevToolsAgentHost::GetForWorker(process_id, route_id)); |
| 269 if (!agent_host) | 269 if (!agent_host.get()) |
| 270 return; | 270 return; |
| 271 | 271 |
| 272 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host); | 272 DevToolsWindow::OpenDevToolsWindowForWorker(profile, agent_host.get()); |
| 273 } | 273 } |
| 274 | 274 |
| 275 static void TerminateWorker(int process_id, int route_id) { | 275 static void TerminateWorker(int process_id, int route_id) { |
| 276 WorkerService::GetInstance()->TerminateWorker(process_id, route_id); | 276 WorkerService::GetInstance()->TerminateWorker(process_id, route_id); |
| 277 } | 277 } |
| 278 | 278 |
| 279 void InspectMessageHandler::HandleTerminateCommand(const ListValue* args) { | 279 void InspectMessageHandler::HandleTerminateCommand(const ListValue* args) { |
| 280 int process_id; | 280 int process_id; |
| 281 int route_id; | 281 int route_id; |
| 282 if (!GetProcessAndRouteId(args, &process_id, &route_id)) | 282 if (!GetProcessAndRouteId(args, &process_id, &route_id)) |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 const content::NotificationSource& source, | 400 const content::NotificationSource& source, |
| 401 const content::NotificationDetails& details) { | 401 const content::NotificationDetails& details) { |
| 402 if (source != content::Source<WebContents>(web_ui()->GetWebContents())) | 402 if (source != content::Source<WebContents>(web_ui()->GetWebContents())) |
| 403 RefreshUI(); | 403 RefreshUI(); |
| 404 else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) | 404 else if (type == content::NOTIFICATION_WEB_CONTENTS_DISCONNECTED) |
| 405 StopListeningNotifications(); | 405 StopListeningNotifications(); |
| 406 } | 406 } |
| 407 | 407 |
| 408 void InspectUI::StopListeningNotifications() | 408 void InspectUI::StopListeningNotifications() |
| 409 { | 409 { |
| 410 if (!observer_) | 410 if (!observer_.get()) |
| 411 return; | 411 return; |
| 412 adb_bridge_.reset(); | 412 adb_bridge_.reset(); |
| 413 observer_->InspectUIDestroyed(); | 413 observer_->InspectUIDestroyed(); |
| 414 observer_ = NULL; | 414 observer_ = NULL; |
| 415 registrar_.RemoveAll(); | 415 registrar_.RemoveAll(); |
| 416 } | 416 } |
| 417 | 417 |
| 418 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { | 418 content::WebUIDataSource* InspectUI::CreateInspectUIHTMLSource() { |
| 419 content::WebUIDataSource* source = | 419 content::WebUIDataSource* source = |
| 420 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); | 420 content::WebUIDataSource::Create(chrome::kChromeUIInspectHost); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 target_data->SetString(kAdbSocketField, page->socket()); | 465 target_data->SetString(kAdbSocketField, page->socket()); |
| 466 target_data->SetString(kAdbDebugUrlField, page->debug_url()); | 466 target_data->SetString(kAdbDebugUrlField, page->debug_url()); |
| 467 target_data->SetString(kAdbFrontendUrlField, page->frontend_url()); | 467 target_data->SetString(kAdbFrontendUrlField, page->frontend_url()); |
| 468 targets.Append(target_data); | 468 targets.Append(target_data); |
| 469 } | 469 } |
| 470 | 470 |
| 471 std::string json_string; | 471 std::string json_string; |
| 472 base::JSONWriter::Write(&targets, &json_string); | 472 base::JSONWriter::Write(&targets, &json_string); |
| 473 callback.Run(base::RefCountedString::TakeString(&json_string)); | 473 callback.Run(base::RefCountedString::TakeString(&json_string)); |
| 474 } | 474 } |
| OLD | NEW |