| 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 "content/browser/tracing/tracing_ui.h" | 5 #include "content/browser/tracing/tracing_ui.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return; | 310 return; |
| 311 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 311 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
| 312 select_trace_file_dialog_ = ui::SelectFileDialog::Create( | 312 select_trace_file_dialog_ = ui::SelectFileDialog::Create( |
| 313 this, | 313 this, |
| 314 GetContentClient()->browser()->CreateSelectFilePolicy( | 314 GetContentClient()->browser()->CreateSelectFilePolicy( |
| 315 web_ui()->GetWebContents())); | 315 web_ui()->GetWebContents())); |
| 316 select_trace_file_dialog_->SelectFile( | 316 select_trace_file_dialog_->SelectFile( |
| 317 ui::SelectFileDialog::SELECT_OPEN_FILE, | 317 ui::SelectFileDialog::SELECT_OPEN_FILE, |
| 318 string16(), | 318 string16(), |
| 319 base::FilePath(), | 319 base::FilePath(), |
| 320 NULL, 0, FILE_PATH_LITERAL(""), | 320 NULL, |
| 321 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); | 321 0, |
| 322 base::FilePath::StringType(), |
| 323 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), |
| 324 NULL); |
| 322 } | 325 } |
| 323 | 326 |
| 324 void TracingMessageHandler::LoadTraceFileComplete(string16* contents) { | 327 void TracingMessageHandler::LoadTraceFileComplete(string16* contents) { |
| 325 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 328 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 326 | 329 |
| 327 // We need to pass contents to tracingController.onLoadTraceFileComplete, but | 330 // We need to pass contents to tracingController.onLoadTraceFileComplete, but |
| 328 // that may be arbitrarily big, and IPCs messages are limited in size. So we | 331 // that may be arbitrarily big, and IPCs messages are limited in size. So we |
| 329 // need to cut it into pieces and rebuild the string in Javascript. | 332 // need to cut it into pieces and rebuild the string in Javascript. |
| 330 // |contents| has already been escaped in ReadTraceFileCallback. | 333 // |contents| has already been escaped in ReadTraceFileCallback. |
| 331 // IPC::Channel::kMaximumMessageSize is in bytes, and we need to account for | 334 // IPC::Channel::kMaximumMessageSize is in bytes, and we need to account for |
| (...skipping 28 matching lines...) Expand all Loading... |
| 360 | 363 |
| 361 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 364 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
| 362 select_trace_file_dialog_ = ui::SelectFileDialog::Create( | 365 select_trace_file_dialog_ = ui::SelectFileDialog::Create( |
| 363 this, | 366 this, |
| 364 GetContentClient()->browser()->CreateSelectFilePolicy( | 367 GetContentClient()->browser()->CreateSelectFilePolicy( |
| 365 web_ui()->GetWebContents())); | 368 web_ui()->GetWebContents())); |
| 366 select_trace_file_dialog_->SelectFile( | 369 select_trace_file_dialog_->SelectFile( |
| 367 ui::SelectFileDialog::SELECT_SAVEAS_FILE, | 370 ui::SelectFileDialog::SELECT_SAVEAS_FILE, |
| 368 string16(), | 371 string16(), |
| 369 base::FilePath(), | 372 base::FilePath(), |
| 370 NULL, 0, FILE_PATH_LITERAL(""), | 373 NULL, |
| 371 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); | 374 0, |
| 375 base::FilePath::StringType(), |
| 376 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), |
| 377 NULL); |
| 372 } | 378 } |
| 373 | 379 |
| 374 void TracingMessageHandler::SaveTraceFileComplete() { | 380 void TracingMessageHandler::SaveTraceFileComplete() { |
| 375 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 376 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); | 382 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); |
| 377 } | 383 } |
| 378 | 384 |
| 379 void TracingMessageHandler::OnBeginTracing(const base::ListValue* args) { | 385 void TracingMessageHandler::OnBeginTracing(const base::ListValue* args) { |
| 380 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 381 DCHECK_GE(args->GetSize(), (size_t) 2); | 387 DCHECK_GE(args->GetSize(), (size_t) 2); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 530 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
| 525 web_ui->AddMessageHandler(new TracingMessageHandler()); | 531 web_ui->AddMessageHandler(new TracingMessageHandler()); |
| 526 | 532 |
| 527 // Set up the chrome://tracing/ source. | 533 // Set up the chrome://tracing/ source. |
| 528 BrowserContext* browser_context = | 534 BrowserContext* browser_context = |
| 529 web_ui->GetWebContents()->GetBrowserContext(); | 535 web_ui->GetWebContents()->GetBrowserContext(); |
| 530 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 536 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
| 531 } | 537 } |
| 532 | 538 |
| 533 } // namespace content | 539 } // namespace content |
| OLD | NEW |