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 // The file contains the implementation of | 5 // The file contains the implementation of |
6 // fileBrowserHandlerInternal.selectFile extension function. | 6 // fileBrowserHandlerInternal.selectFile extension function. |
7 // When invoked, the function does the following: | 7 // When invoked, the function does the following: |
8 // - Verifies that the extension function was invoked as a result of user | 8 // - Verifies that the extension function was invoked as a result of user |
9 // gesture. | 9 // gesture. |
10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user | 10 // - Display 'save as' dialog using FileSelectorImpl which waits for the user |
(...skipping 27 matching lines...) Expand all Loading... |
38 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
39 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
40 #include "chrome/browser/ui/chrome_select_file_policy.h" | 40 #include "chrome/browser/ui/chrome_select_file_policy.h" |
41 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 41 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
42 #include "chrome/common/extensions/api/file_browser_handler_internal.h" | 42 #include "chrome/common/extensions/api/file_browser_handler_internal.h" |
43 #include "content/public/browser/browser_thread.h" | 43 #include "content/public/browser/browser_thread.h" |
44 #include "content/public/browser/child_process_security_policy.h" | 44 #include "content/public/browser/child_process_security_policy.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
46 #include "content/public/browser/render_view_host.h" | 46 #include "content/public/browser/render_view_host.h" |
47 #include "ui/shell_dialogs/select_file_dialog.h" | 47 #include "ui/shell_dialogs/select_file_dialog.h" |
48 #include "webkit/browser/fileapi/file_system_backend.h" | 48 #include "storage/browser/fileapi/file_system_backend.h" |
49 #include "webkit/browser/fileapi/file_system_context.h" | 49 #include "storage/browser/fileapi/file_system_context.h" |
50 #include "webkit/common/fileapi/file_system_info.h" | 50 #include "storage/common/fileapi/file_system_info.h" |
51 #include "webkit/common/fileapi/file_system_util.h" | 51 #include "storage/common/fileapi/file_system_util.h" |
52 | 52 |
53 using content::BrowserThread; | 53 using content::BrowserThread; |
54 using extensions::api::file_browser_handler_internal::FileEntryInfo; | 54 using extensions::api::file_browser_handler_internal::FileEntryInfo; |
55 using file_manager::FileSelector; | 55 using file_manager::FileSelector; |
56 using file_manager::FileSelectorFactory; | 56 using file_manager::FileSelectorFactory; |
57 using file_manager::util::EntryDefinition; | 57 using file_manager::util::EntryDefinition; |
58 using file_manager::util::FileDefinition; | 58 using file_manager::util::FileDefinition; |
59 | 59 |
60 namespace SelectFile = | 60 namespace SelectFile = |
61 extensions::api::file_browser_handler_internal::SelectFile; | 61 extensions::api::file_browser_handler_internal::SelectFile; |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 void FileBrowserHandlerInternalSelectFileFunction::OnFilePathSelected( | 308 void FileBrowserHandlerInternalSelectFileFunction::OnFilePathSelected( |
309 bool success, | 309 bool success, |
310 const base::FilePath& full_path) { | 310 const base::FilePath& full_path) { |
311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 311 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
312 | 312 |
313 if (!success) { | 313 if (!success) { |
314 Respond(EntryDefinition(), false); | 314 Respond(EntryDefinition(), false); |
315 return; | 315 return; |
316 } | 316 } |
317 | 317 |
318 fileapi::ExternalFileSystemBackend* external_backend = | 318 storage::ExternalFileSystemBackend* external_backend = |
319 file_manager::util::GetFileSystemContextForRenderViewHost( | 319 file_manager::util::GetFileSystemContextForRenderViewHost( |
320 GetProfile(), render_view_host())->external_backend(); | 320 GetProfile(), render_view_host())->external_backend(); |
321 DCHECK(external_backend); | 321 DCHECK(external_backend); |
322 | 322 |
323 FileDefinition file_definition; | 323 FileDefinition file_definition; |
324 file_definition.is_directory = false; | 324 file_definition.is_directory = false; |
325 | 325 |
326 external_backend->GetVirtualPath(full_path, &file_definition.virtual_path); | 326 external_backend->GetVirtualPath(full_path, &file_definition.virtual_path); |
327 DCHECK(!file_definition.virtual_path.empty()); | 327 DCHECK(!file_definition.virtual_path.empty()); |
328 | 328 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 result->entry->file_system_name = entry_definition.file_system_name; | 365 result->entry->file_system_name = entry_definition.file_system_name; |
366 result->entry->file_system_root = entry_definition.file_system_root_url; | 366 result->entry->file_system_root = entry_definition.file_system_root_url; |
367 result->entry->file_full_path = | 367 result->entry->file_full_path = |
368 "/" + entry_definition.full_path.AsUTF8Unsafe(); | 368 "/" + entry_definition.full_path.AsUTF8Unsafe(); |
369 result->entry->file_is_directory = entry_definition.is_directory; | 369 result->entry->file_is_directory = entry_definition.is_directory; |
370 } | 370 } |
371 | 371 |
372 results_ = SelectFile::Results::Create(*result); | 372 results_ = SelectFile::Results::Create(*result); |
373 SendResponse(true); | 373 SendResponse(true); |
374 } | 374 } |
OLD | NEW |