Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1780)

Side by Side Diff: chrome/browser/extensions/api/file_system/file_system_api.cc

Issue 294163010: Refactor "IsUnderDriveMountPoint" in v2 app code for generalization to non-Drive volumes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/extensions/api/file_system/file_system_api.h" 5 #include "chrome/browser/extensions/api/file_system/file_system_api.h"
6 6
7 #include "apps/app_window.h" 7 #include "apps/app_window.h"
8 #include "apps/app_window_registry.h" 8 #include "apps/app_window_registry.h"
9 #include "apps/browser/file_handler_util.h" 9 #include "apps/browser/file_handler_util.h"
10 #include "apps/saved_files_service.h" 10 #include "apps/saved_files_service.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 #include "webkit/browser/fileapi/isolated_context.h" 43 #include "webkit/browser/fileapi/isolated_context.h"
44 #include "webkit/common/fileapi/file_system_types.h" 44 #include "webkit/common/fileapi/file_system_types.h"
45 #include "webkit/common/fileapi/file_system_util.h" 45 #include "webkit/common/fileapi/file_system_util.h"
46 46
47 #if defined(OS_MACOSX) 47 #if defined(OS_MACOSX)
48 #include <CoreFoundation/CoreFoundation.h> 48 #include <CoreFoundation/CoreFoundation.h>
49 #include "base/mac/foundation_util.h" 49 #include "base/mac/foundation_util.h"
50 #endif 50 #endif
51 51
52 #if defined(OS_CHROMEOS) 52 #if defined(OS_CHROMEOS)
53 #include "chrome/browser/chromeos/drive/file_system_util.h" 53 #include "chrome/browser/chromeos/file_manager/filesystem_api_util.h"
54 #endif 54 #endif
55 55
56 using apps::SavedFileEntry; 56 using apps::SavedFileEntry;
57 using apps::SavedFilesService; 57 using apps::SavedFilesService;
58 using apps::AppWindow; 58 using apps::AppWindow;
59 using fileapi::IsolatedContext; 59 using fileapi::IsolatedContext;
60 60
61 const char kInvalidCallingPage[] = "Invalid calling page. This function can't " 61 const char kInvalidCallingPage[] = "Invalid calling page. This function can't "
62 "be called from a background page."; 62 "be called from a background page.";
63 const char kUserCancelled[] = "User cancelled"; 63 const char kUserCancelled[] = "User cancelled";
(...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 DCHECK(registry); 673 DCHECK(registry);
674 AppWindow* app_window = 674 AppWindow* app_window =
675 registry->GetAppWindowForRenderViewHost(render_view_host()); 675 registry->GetAppWindowForRenderViewHost(render_view_host());
676 if (!app_window) { 676 if (!app_window) {
677 error_ = kInvalidCallingPage; 677 error_ = kInvalidCallingPage;
678 SendResponse(false); 678 SendResponse(false);
679 return; 679 return;
680 } 680 }
681 content::WebContents* web_contents = app_window->web_contents(); 681 content::WebContents* web_contents = app_window->web_contents();
682 682
683 DCHECK_EQ(paths.size(), 1u);
684 std::vector<base::FilePath> check_paths;
685 #if defined(OS_CHROMEOS)
686 check_paths.push_back(
687 file_manager::util::IsUnderSpecialPath(GetProfile(), paths[0])
688 ? paths[0]
689 : base::MakeAbsoluteFilePath(paths[0]));
690 #else
691 check_paths.push_back(base::MakeAbsoluteFilePath(paths[0]));
692 #endif
693
683 content::BrowserThread::PostTask( 694 content::BrowserThread::PostTask(
684 content::BrowserThread::FILE, 695 content::BrowserThread::FILE,
685 FROM_HERE, 696 FROM_HERE,
686 base::Bind( 697 base::Bind(
687 &FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread, 698 &FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread,
688 this, 699 this,
689 paths, 700 check_paths,
690 web_contents)); 701 web_contents));
691 return; 702 return;
692 } 703 }
693 704
694 OnDirectoryAccessConfirmed(paths); 705 OnDirectoryAccessConfirmed(paths);
695 } 706 }
696 707
697 void FileSystemChooseEntryFunction::FileSelectionCanceled() { 708 void FileSystemChooseEntryFunction::FileSelectionCanceled() {
698 error_ = kUserCancelled; 709 error_ = kUserCancelled;
699 SendResponse(false); 710 SendResponse(false);
700 } 711 }
701 712
702 void FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread( 713 void FileSystemChooseEntryFunction::ConfirmDirectoryAccessOnFileThread(
703 const std::vector<base::FilePath>& paths, 714 const std::vector<base::FilePath>& paths,
704 content::WebContents* web_contents) { 715 content::WebContents* web_contents) {
705 DCHECK_EQ(paths.size(), 1u); 716 DCHECK_EQ(paths.size(), 1u);
706 #if defined(OS_CHROMEOS) 717 const base::FilePath& path = paths[0];
707 const base::FilePath path = 718
708 drive::util::IsUnderDriveMountPoint(paths[0]) ? paths[0] :
709 base::MakeAbsoluteFilePath(paths[0]);
710 #else
711 const base::FilePath path = base::MakeAbsoluteFilePath(paths[0]);
712 #endif
713 if (path.empty()) { 719 if (path.empty()) {
714 content::BrowserThread::PostTask( 720 content::BrowserThread::PostTask(
715 content::BrowserThread::UI, 721 content::BrowserThread::UI,
716 FROM_HERE, 722 FROM_HERE,
717 base::Bind(&FileSystemChooseEntryFunction::FileSelectionCanceled, 723 base::Bind(&FileSystemChooseEntryFunction::FileSelectionCanceled,
718 this)); 724 this));
719 return; 725 return;
720 } 726 }
721 727
722 for (size_t i = 0; i < arraysize(kGraylistedPaths); i++) { 728 for (size_t i = 0; i < arraysize(kGraylistedPaths); i++) {
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 if (needs_new_entry) { 983 if (needs_new_entry) {
978 is_directory_ = file_entry->is_directory; 984 is_directory_ = file_entry->is_directory;
979 CreateResponse(); 985 CreateResponse();
980 AddEntryToResponse(file_entry->path, file_entry->id); 986 AddEntryToResponse(file_entry->path, file_entry->id);
981 } 987 }
982 SendResponse(true); 988 SendResponse(true);
983 return true; 989 return true;
984 } 990 }
985 991
986 } // namespace extensions 992 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698