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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
298 web_ui()->CallJavascriptFunction( | 298 web_ui()->CallJavascriptFunction( |
299 "tracingController.onLoadTraceFileCanceled"); | 299 "tracingController.onLoadTraceFileCanceled"); |
300 } else { | 300 } else { |
301 web_ui()->CallJavascriptFunction( | 301 web_ui()->CallJavascriptFunction( |
302 "tracingController.onSaveTraceFileCanceled"); | 302 "tracingController.onSaveTraceFileCanceled"); |
303 } | 303 } |
304 } | 304 } |
305 | 305 |
306 void TracingMessageHandler::OnLoadTraceFile(const base::ListValue* list) { | 306 void TracingMessageHandler::OnLoadTraceFile(const base::ListValue* list) { |
307 // Only allow a single dialog at a time. | 307 // Only allow a single dialog at a time. |
308 if (select_trace_file_dialog_.get()) | 308 if (select_trace_file_dialog_) |
309 return; | 309 return; |
310 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; | 310 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_OPEN_FILE; |
311 select_trace_file_dialog_ = ui::SelectFileDialog::Create( | 311 select_trace_file_dialog_ = ui::SelectFileDialog::Create( |
312 this, | 312 this, |
313 GetContentClient()->browser()->CreateSelectFilePolicy( | 313 GetContentClient()->browser()->CreateSelectFilePolicy( |
314 web_ui()->GetWebContents())); | 314 web_ui()->GetWebContents())); |
315 select_trace_file_dialog_->SelectFile( | 315 select_trace_file_dialog_->SelectFile( |
316 ui::SelectFileDialog::SELECT_OPEN_FILE, | 316 ui::SelectFileDialog::SELECT_OPEN_FILE, |
317 string16(), | 317 string16(), |
318 base::FilePath(), | 318 base::FilePath(), |
(...skipping 24 matching lines...) Expand all Loading... |
343 javascript += contents->substr(i, kMaxSize) + suffix; | 343 javascript += contents->substr(i, kMaxSize) + suffix; |
344 rvh->ExecuteJavascriptInWebFrame(string16(), javascript); | 344 rvh->ExecuteJavascriptInWebFrame(string16(), javascript); |
345 } | 345 } |
346 rvh->ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16( | 346 rvh->ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16( |
347 "tracingController.onLoadTraceFileComplete(JSON.parse(window.traceData));" | 347 "tracingController.onLoadTraceFileComplete(JSON.parse(window.traceData));" |
348 "delete window.traceData;")); | 348 "delete window.traceData;")); |
349 } | 349 } |
350 | 350 |
351 void TracingMessageHandler::OnSaveTraceFile(const base::ListValue* list) { | 351 void TracingMessageHandler::OnSaveTraceFile(const base::ListValue* list) { |
352 // Only allow a single dialog at a time. | 352 // Only allow a single dialog at a time. |
353 if (select_trace_file_dialog_.get()) | 353 if (select_trace_file_dialog_) |
354 return; | 354 return; |
355 | 355 |
356 DCHECK(list->GetSize() == 1); | 356 DCHECK(list->GetSize() == 1); |
357 | 357 |
358 std::string* trace_data = new std::string(); | 358 std::string* trace_data = new std::string(); |
359 bool ok = list->GetString(0, trace_data); | 359 bool ok = list->GetString(0, trace_data); |
360 DCHECK(ok); | 360 DCHECK(ok); |
361 trace_data_to_save_.reset(trace_data); | 361 trace_data_to_save_.reset(trace_data); |
362 | 362 |
363 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; | 363 select_trace_file_dialog_type_ = ui::SelectFileDialog::SELECT_SAVEAS_FILE; |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { | 529 TracingUI::TracingUI(WebUI* web_ui) : WebUIController(web_ui) { |
530 web_ui->AddMessageHandler(new TracingMessageHandler()); | 530 web_ui->AddMessageHandler(new TracingMessageHandler()); |
531 | 531 |
532 // Set up the chrome://tracing/ source. | 532 // Set up the chrome://tracing/ source. |
533 BrowserContext* browser_context = | 533 BrowserContext* browser_context = |
534 web_ui->GetWebContents()->GetBrowserContext(); | 534 web_ui->GetWebContents()->GetBrowserContext(); |
535 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); | 535 WebUIDataSource::Add(browser_context, CreateTracingHTMLSource()); |
536 } | 536 } |
537 | 537 |
538 } // namespace content | 538 } // namespace content |
OLD | NEW |