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/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/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
12 #include "base/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/file_util.h" | 13 #include "base/file_util.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
16 #include "base/utf_string_conversions.h" | 16 #include "base/utf_string_conversions.h" |
| 17 #include "chrome/browser/chrome_select_file_policy.h" |
17 #include "chrome/browser/gpu_blacklist.h" | 18 #include "chrome/browser/gpu_blacklist.h" |
18 #include "chrome/browser/gpu_util.h" | 19 #include "chrome/browser/gpu_util.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/ui/select_file_dialog.h" | 21 #include "chrome/browser/ui/select_file_dialog.h" |
21 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 22 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
22 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 23 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
23 #include "chrome/common/chrome_version_info.h" | 24 #include "chrome/common/chrome_version_info.h" |
24 #include "chrome/common/url_constants.h" | 25 #include "chrome/common/url_constants.h" |
25 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
26 #include "content/public/browser/gpu_data_manager.h" | 27 #include "content/public/browser/gpu_data_manager.h" |
(...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 void TracingMessageHandler::OnLoadTraceFile(const ListValue* list) { | 336 void TracingMessageHandler::OnLoadTraceFile(const ListValue* list) { |
336 // Only allow a single dialog at a time. | 337 // Only allow a single dialog at a time. |
337 if (select_trace_file_dialog_.get()) | 338 if (select_trace_file_dialog_.get()) |
338 return; | 339 return; |
339 select_trace_file_dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE; | 340 select_trace_file_dialog_type_ = SelectFileDialog::SELECT_OPEN_FILE; |
340 select_trace_file_dialog_ = SelectFileDialog::Create(this); | 341 select_trace_file_dialog_ = SelectFileDialog::Create(this); |
341 select_trace_file_dialog_->SelectFile( | 342 select_trace_file_dialog_->SelectFile( |
342 SelectFileDialog::SELECT_OPEN_FILE, | 343 SelectFileDialog::SELECT_OPEN_FILE, |
343 string16(), | 344 string16(), |
344 FilePath(), | 345 FilePath(), |
345 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->GetWebContents(), | 346 NULL, 0, FILE_PATH_LITERAL(""), |
| 347 ChromeSelectFilePolicy::DisplayInfobarCallback( |
| 348 web_ui()->GetWebContents()), |
346 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); | 349 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); |
347 } | 350 } |
348 | 351 |
349 void TracingMessageHandler::LoadTraceFileComplete(std::string* file_contents) { | 352 void TracingMessageHandler::LoadTraceFileComplete(std::string* file_contents) { |
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 353 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
351 std::string javascript = "tracingController.onLoadTraceFileComplete(" | 354 std::string javascript = "tracingController.onLoadTraceFileComplete(" |
352 + *file_contents + ");"; | 355 + *file_contents + ");"; |
353 | 356 |
354 web_ui()->GetWebContents()->GetRenderViewHost()-> | 357 web_ui()->GetWebContents()->GetRenderViewHost()-> |
355 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(javascript)); | 358 ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16(javascript)); |
(...skipping 10 matching lines...) Expand all Loading... |
366 bool ok = list->GetString(0, trace_data); | 369 bool ok = list->GetString(0, trace_data); |
367 DCHECK(ok); | 370 DCHECK(ok); |
368 trace_data_to_save_.reset(trace_data); | 371 trace_data_to_save_.reset(trace_data); |
369 | 372 |
370 select_trace_file_dialog_type_ = SelectFileDialog::SELECT_SAVEAS_FILE; | 373 select_trace_file_dialog_type_ = SelectFileDialog::SELECT_SAVEAS_FILE; |
371 select_trace_file_dialog_ = SelectFileDialog::Create(this); | 374 select_trace_file_dialog_ = SelectFileDialog::Create(this); |
372 select_trace_file_dialog_->SelectFile( | 375 select_trace_file_dialog_->SelectFile( |
373 SelectFileDialog::SELECT_SAVEAS_FILE, | 376 SelectFileDialog::SELECT_SAVEAS_FILE, |
374 string16(), | 377 string16(), |
375 FilePath(), | 378 FilePath(), |
376 NULL, 0, FILE_PATH_LITERAL(""), web_ui()->GetWebContents(), | 379 NULL, 0, FILE_PATH_LITERAL(""), |
| 380 ChromeSelectFilePolicy::DisplayInfobarCallback( |
| 381 web_ui()->GetWebContents()), |
377 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); | 382 web_ui()->GetWebContents()->GetView()->GetTopLevelNativeWindow(), NULL); |
378 } | 383 } |
379 | 384 |
380 void TracingMessageHandler::SaveTraceFileComplete() { | 385 void TracingMessageHandler::SaveTraceFileComplete() { |
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
382 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); | 387 web_ui()->CallJavascriptFunction("tracingController.onSaveTraceFileComplete"); |
383 } | 388 } |
384 | 389 |
385 void TracingMessageHandler::OnBeginTracing(const ListValue* args) { | 390 void TracingMessageHandler::OnBeginTracing(const ListValue* args) { |
386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 // | 494 // |
490 //////////////////////////////////////////////////////////////////////////////// | 495 //////////////////////////////////////////////////////////////////////////////// |
491 | 496 |
492 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 497 TracingUI::TracingUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
493 web_ui->AddMessageHandler(new TracingMessageHandler()); | 498 web_ui->AddMessageHandler(new TracingMessageHandler()); |
494 | 499 |
495 // Set up the chrome://tracing/ source. | 500 // Set up the chrome://tracing/ source. |
496 Profile* profile = Profile::FromWebUI(web_ui); | 501 Profile* profile = Profile::FromWebUI(web_ui); |
497 ChromeURLDataManager::AddDataSource(profile, CreateTracingHTMLSource()); | 502 ChromeURLDataManager::AddDataSource(profile, CreateTracingHTMLSource()); |
498 } | 503 } |
OLD | NEW |