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/tracing_ui.h" | 5 #include "chrome/browser/ui/webui/tracing_ui.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
419 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); | 419 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); |
420 } | 420 } |
421 | 421 |
422 void TracingMessageHandler::LoadTraceFileComplete(std::string* file_contents) { | 422 void TracingMessageHandler::LoadTraceFileComplete(std::string* file_contents) { |
423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 423 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
424 std::wstring javascript; | 424 std::wstring javascript; |
425 javascript += L"tracingController.onLoadTraceFileComplete("; | 425 javascript += L"tracingController.onLoadTraceFileComplete("; |
426 javascript += UTF8ToWide(*file_contents); | 426 javascript += UTF8ToWide(*file_contents); |
427 javascript += L");"; | 427 javascript += L");"; |
428 | 428 |
429 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), | 429 web_ui_->tab_contents()->render_view_host()-> |
430 WideToUTF16Hack(javascript)); | 430 ExecuteJavascriptInWebFrame(string16(), |
| 431 WideToUTF16Hack(javascript)); |
431 } | 432 } |
432 | 433 |
433 void TracingMessageHandler::OnSaveTraceFile(const ListValue* list) { | 434 void TracingMessageHandler::OnSaveTraceFile(const ListValue* list) { |
434 // Only allow a single dialog at a time. | 435 // Only allow a single dialog at a time. |
435 if (select_trace_file_dialog_.get()) | 436 if (select_trace_file_dialog_.get()) |
436 return; | 437 return; |
437 | 438 |
438 DCHECK(list->GetSize() == 1); | 439 DCHECK(list->GetSize() == 1); |
439 | 440 |
440 std::string* trace_data = new std::string(); | 441 std::string* trace_data = new std::string(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 } | 490 } |
490 | 491 |
491 void TracingMessageHandler::OnTraceDataCollected( | 492 void TracingMessageHandler::OnTraceDataCollected( |
492 const std::string& json_events) { | 493 const std::string& json_events) { |
493 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 494 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
494 std::wstring javascript; | 495 std::wstring javascript; |
495 javascript += L"tracingController.onTraceDataCollected("; | 496 javascript += L"tracingController.onTraceDataCollected("; |
496 javascript += UTF8ToWide(json_events); | 497 javascript += UTF8ToWide(json_events); |
497 javascript += L");"; | 498 javascript += L");"; |
498 | 499 |
499 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), | 500 web_ui_->tab_contents()->render_view_host()-> |
500 WideToUTF16Hack(javascript)); | 501 ExecuteJavascriptInWebFrame(string16(), |
| 502 WideToUTF16Hack(javascript)); |
501 } | 503 } |
502 | 504 |
503 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { | 505 void TracingMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { |
504 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 506 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
505 web_ui_->CallJavascriptFunction( | 507 web_ui_->CallJavascriptFunction( |
506 "tracingController.onRequestBufferPercentFullComplete", | 508 "tracingController.onRequestBufferPercentFullComplete", |
507 *scoped_ptr<Value>(Value::CreateDoubleValue(percent_full))); | 509 *scoped_ptr<Value>(Value::CreateDoubleValue(percent_full))); |
508 } | 510 } |
509 | 511 |
510 } // namespace | 512 } // namespace |
511 | 513 |
512 | 514 |
513 //////////////////////////////////////////////////////////////////////////////// | 515 //////////////////////////////////////////////////////////////////////////////// |
514 // | 516 // |
515 // TracingUI | 517 // TracingUI |
516 // | 518 // |
517 //////////////////////////////////////////////////////////////////////////////// | 519 //////////////////////////////////////////////////////////////////////////////// |
518 | 520 |
519 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { | 521 TracingUI::TracingUI(TabContents* contents) : ChromeWebUI(contents) { |
520 AddMessageHandler((new TracingMessageHandler())->Attach(this)); | 522 AddMessageHandler((new TracingMessageHandler())->Attach(this)); |
521 | 523 |
522 // Set up the chrome://tracing/ source. | 524 // Set up the chrome://tracing/ source. |
523 Profile::FromBrowserContext(contents->browser_context())-> | 525 Profile::FromBrowserContext(contents->browser_context())-> |
524 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); | 526 GetChromeURLDataManager()->AddDataSource(CreateTracingHTMLSource()); |
525 } | 527 } |
OLD | NEW |