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/file_select_helper.h" | 5 #include "chrome/browser/file_select_helper.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/string_split.h" | 10 #include "base/string_split.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) | 310 IPC_MESSAGE_HANDLER(ViewHostMsg_RunFileChooser, OnRunFileChooser) |
311 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) | 311 IPC_MESSAGE_HANDLER(ViewHostMsg_EnumerateDirectory, OnEnumerateDirectory) |
312 IPC_MESSAGE_UNHANDLED(handled = false) | 312 IPC_MESSAGE_UNHANDLED(handled = false) |
313 IPC_END_MESSAGE_MAP() | 313 IPC_END_MESSAGE_MAP() |
314 | 314 |
315 return handled; | 315 return handled; |
316 } | 316 } |
317 | 317 |
318 void FileSelectObserver::OnRunFileChooser( | 318 void FileSelectObserver::OnRunFileChooser( |
319 const ViewHostMsg_RunFileChooser_Params& params) { | 319 const ViewHostMsg_RunFileChooser_Params& params) { |
320 if (!file_select_helper_.get()) | 320 if (!file_select_helper_.get()) { |
321 file_select_helper_.reset(new FileSelectHelper(tab_contents()->profile())); | 321 Profile* profile = static_cast<Profile*>(tab_contents()->context()); |
| 322 file_select_helper_.reset(new FileSelectHelper(profile)); |
| 323 } |
322 file_select_helper_->RunFileChooser(tab_contents()->render_view_host(), | 324 file_select_helper_->RunFileChooser(tab_contents()->render_view_host(), |
323 tab_contents(), | 325 tab_contents(), |
324 params); | 326 params); |
325 } | 327 } |
326 | 328 |
327 void FileSelectObserver::OnEnumerateDirectory(int request_id, | 329 void FileSelectObserver::OnEnumerateDirectory(int request_id, |
328 const FilePath& path) { | 330 const FilePath& path) { |
329 ChildProcessSecurityPolicy* policy = | 331 ChildProcessSecurityPolicy* policy = |
330 ChildProcessSecurityPolicy::GetInstance(); | 332 ChildProcessSecurityPolicy::GetInstance(); |
331 if (!policy->CanReadDirectory( | 333 if (!policy->CanReadDirectory( |
332 tab_contents()->render_view_host()->process()->id(), | 334 tab_contents()->render_view_host()->process()->id(), |
333 path)) { | 335 path)) { |
334 return; | 336 return; |
335 } | 337 } |
336 | 338 |
337 if (!file_select_helper_.get()) | 339 if (!file_select_helper_.get()) { |
338 file_select_helper_.reset(new FileSelectHelper(tab_contents()->profile())); | 340 Profile* profile = static_cast<Profile*>(tab_contents()->context()); |
| 341 file_select_helper_.reset(new FileSelectHelper(profile)); |
| 342 } |
339 file_select_helper_->EnumerateDirectory(request_id, | 343 file_select_helper_->EnumerateDirectory(request_id, |
340 tab_contents()->render_view_host(), | 344 tab_contents()->render_view_host(), |
341 path); | 345 path); |
342 } | 346 } |
OLD | NEW |