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/gpu_internals_ui.h" | 5 #include "chrome/browser/ui/webui/gpu_internals_ui.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
347 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); | 347 web_ui_->tab_contents()->view()->GetTopLevelNativeWindow(), NULL); |
348 } | 348 } |
349 | 349 |
350 void GpuMessageHandler::LoadTraceFileComplete(std::string* file_contents) { | 350 void GpuMessageHandler::LoadTraceFileComplete(std::string* file_contents) { |
351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 351 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
352 std::wstring javascript; | 352 std::wstring javascript; |
353 javascript += L"tracingController.onLoadTraceFileComplete("; | 353 javascript += L"tracingController.onLoadTraceFileComplete("; |
354 javascript += UTF8ToWide(*file_contents); | 354 javascript += UTF8ToWide(*file_contents); |
355 javascript += L");"; | 355 javascript += L");"; |
356 | 356 |
357 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), | 357 web_ui_->tab_contents()->render_view_host()-> |
358 WideToUTF16Hack(javascript)); | 358 ExecuteJavascriptInWebFrame(string16(), WideToUTF16Hack(javascript)); |
359 } | 359 } |
360 | 360 |
361 void GpuMessageHandler::OnSaveTraceFile(const ListValue* list) { | 361 void GpuMessageHandler::OnSaveTraceFile(const ListValue* list) { |
362 // Only allow a single dialog at a time. | 362 // Only allow a single dialog at a time. |
363 if (select_trace_file_dialog_.get()) | 363 if (select_trace_file_dialog_.get()) |
364 return; | 364 return; |
365 | 365 |
366 DCHECK(list->GetSize() == 1); | 366 DCHECK(list->GetSize() == 1); |
367 | 367 |
368 std::string* trace_data = new std::string(); | 368 std::string* trace_data = new std::string(); |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete"); | 573 web_ui_->CallJavascriptFunction("tracingController.onEndTracingComplete"); |
574 } | 574 } |
575 | 575 |
576 void GpuMessageHandler::OnTraceDataCollected(const std::string& json_events) { | 576 void GpuMessageHandler::OnTraceDataCollected(const std::string& json_events) { |
577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 577 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
578 std::wstring javascript; | 578 std::wstring javascript; |
579 javascript += L"tracingController.onTraceDataCollected("; | 579 javascript += L"tracingController.onTraceDataCollected("; |
580 javascript += UTF8ToWide(json_events); | 580 javascript += UTF8ToWide(json_events); |
581 javascript += L");"; | 581 javascript += L");"; |
582 | 582 |
583 web_ui_->GetRenderViewHost()->ExecuteJavascriptInWebFrame(string16(), | 583 web_ui_->tab_contents()->render_view_host()-> |
584 WideToUTF16Hack(javascript)); | 584 ExecuteJavascriptInWebFrame(string16(), WideToUTF16Hack(javascript)); |
585 } | 585 } |
586 | 586 |
587 void GpuMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { | 587 void GpuMessageHandler::OnTraceBufferPercentFullReply(float percent_full) { |
588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 588 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
589 web_ui_->CallJavascriptFunction( | 589 web_ui_->CallJavascriptFunction( |
590 "tracingController.onRequestBufferPercentFullComplete", | 590 "tracingController.onRequestBufferPercentFullComplete", |
591 *scoped_ptr<Value>(Value::CreateDoubleValue(percent_full))); | 591 *scoped_ptr<Value>(Value::CreateDoubleValue(percent_full))); |
592 } | 592 } |
593 | 593 |
594 } // namespace | 594 } // namespace |
595 | 595 |
596 | 596 |
597 //////////////////////////////////////////////////////////////////////////////// | 597 //////////////////////////////////////////////////////////////////////////////// |
598 // | 598 // |
599 // GpuInternalsUI | 599 // GpuInternalsUI |
600 // | 600 // |
601 //////////////////////////////////////////////////////////////////////////////// | 601 //////////////////////////////////////////////////////////////////////////////// |
602 | 602 |
603 GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) { | 603 GpuInternalsUI::GpuInternalsUI(TabContents* contents) : ChromeWebUI(contents) { |
604 AddMessageHandler((new GpuMessageHandler())->Attach(this)); | 604 AddMessageHandler((new GpuMessageHandler())->Attach(this)); |
605 | 605 |
606 // Set up the chrome://gpu-internals/ source. | 606 // Set up the chrome://gpu-internals/ source. |
607 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); | 607 Profile* profile = Profile::FromBrowserContext(contents->browser_context()); |
608 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); | 608 profile->GetChromeURLDataManager()->AddDataSource(CreateGpuHTMLSource()); |
609 } | 609 } |
OLD | NEW |