Chromium Code Reviews| Index: content/browser/tracing/tracing_ui.cc |
| diff --git a/content/browser/tracing/tracing_ui.cc b/content/browser/tracing/tracing_ui.cc |
| index 5b7e359651ddce5ca2c4108664168dc3383380e9..b42a1e795ffa556d3f60a22efd6b0da167b194ff 100644 |
| --- a/content/browser/tracing/tracing_ui.cc |
| +++ b/content/browser/tracing/tracing_ui.cc |
| @@ -88,7 +88,8 @@ class TracingMessageHandler |
| void OnGetKnownCategories(const base::ListValue* list); |
| // Callbacks. |
| - void LoadTraceFileComplete(string16* file_contents); |
| + void LoadTraceFileComplete(string16* file_contents, |
| + const base::FilePath &path); |
| void SaveTraceFileComplete(); |
| private: |
| @@ -120,9 +121,10 @@ class TaskProxy : public base::RefCountedThreadSafe<TaskProxy> { |
| public: |
| explicit TaskProxy(const base::WeakPtr<TracingMessageHandler>& handler) |
| : handler_(handler) {} |
| - void LoadTraceFileCompleteProxy(string16* file_contents) { |
| + void LoadTraceFileCompleteProxy(string16* file_contents, |
| + const base::FilePath& path) { |
| if (handler_) |
| - handler_->LoadTraceFileComplete(file_contents); |
| + handler_->LoadTraceFileComplete(file_contents, path); |
| delete file_contents; |
| } |
| @@ -257,7 +259,8 @@ void ReadTraceFileCallback(TaskProxy* proxy, const base::FilePath& path) { |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(&TaskProxy::LoadTraceFileCompleteProxy, proxy, |
| - contents16.release())); |
| + contents16.release(), |
| + path)); |
| } |
| // A callback used for asynchronously writing a file from a string. Calls the |
| @@ -324,7 +327,8 @@ void TracingMessageHandler::OnLoadTraceFile(const base::ListValue* list) { |
| NULL); |
| } |
| -void TracingMessageHandler::LoadTraceFileComplete(string16* contents) { |
| +void TracingMessageHandler::LoadTraceFileComplete(string16* contents, |
| + const base::FilePath& path) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| // We need to pass contents to tracingController.onLoadTraceFileComplete, but |
| @@ -344,8 +348,24 @@ void TracingMessageHandler::LoadTraceFileComplete(string16* contents) { |
| javascript += contents->substr(i, kMaxSize) + suffix; |
| rvh->ExecuteJavascriptInWebFrame(string16(), javascript); |
| } |
| + |
| + std::string escaped_path; |
| + size_t size = path.value().size(); |
| + escaped_path.reserve(size); |
| + for (size_t i = 0; i < size; ++i) { |
| + char c = path.value()[i]; |
| + if (c < ' ') { |
| + escaped_path += base::StringPrintf("\\u%04x", c); |
| + continue; |
| + } |
| + if (c == '\\' || c == '\'') |
| + escaped_path.push_back('\\'); |
| + escaped_path.push_back(c); |
| + } |
| + |
|
nduca
2013/05/13 19:43:46
i think if we switch from ExecuteJavascriptInWebFr
|
| rvh->ExecuteJavascriptInWebFrame(string16(), UTF8ToUTF16( |
| - "tracingController.onLoadTraceFileComplete(window.traceData);" |
| + "tracingController.onLoadTraceFileComplete(window.traceData,'" + |
| + escaped_path + "');" + |
| "delete window.traceData;")); |
| } |