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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/private_api_util.cc

Issue 23523022: Replace GetForProfile by Get{FileSystem,DriveAppRegistry,DriveService)ByProfile. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/chromeos/extensions/file_manager/private_api_util.h" 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h"
6 6
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "chrome/browser/chromeos/drive/drive.pb.h" 8 #include "chrome/browser/chromeos/drive/drive.pb.h"
9 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
10 #include "chrome/browser/chromeos/drive/file_errors.h" 9 #include "chrome/browser/chromeos/drive/file_errors.h"
10 #include "chrome/browser/chromeos/drive/file_system_interface.h"
11 #include "chrome/browser/chromeos/drive/file_system_util.h" 11 #include "chrome/browser/chromeos/drive/file_system_util.h"
12 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" 12 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
13 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" 13 #include "chrome/browser/chromeos/fileapi/file_system_backend.h"
14 #include "chrome/browser/extensions/extension_function_dispatcher.h" 14 #include "chrome/browser/extensions/extension_function_dispatcher.h"
15 #include "chrome/browser/extensions/extension_tab_util.h" 15 #include "chrome/browser/extensions/extension_tab_util.h"
16 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "content/public/browser/browser_context.h" 17 #include "content/public/browser/browser_context.h"
18 #include "content/public/browser/browser_thread.h" 18 #include "content/public/browser/browser_thread.h"
19 #include "content/public/browser/render_view_host.h" 19 #include "content/public/browser/render_view_host.h"
20 #include "content/public/browser/storage_partition.h" 20 #include "content/public/browser/storage_partition.h"
(...skipping 20 matching lines...) Expand all
41 void ContinueGetSelectedFileInfo(Profile* profile, 41 void ContinueGetSelectedFileInfo(Profile* profile,
42 scoped_ptr<GetSelectedFileInfoParams> params, 42 scoped_ptr<GetSelectedFileInfoParams> params,
43 drive::FileError error, 43 drive::FileError error,
44 const base::FilePath& local_file_path, 44 const base::FilePath& local_file_path,
45 scoped_ptr<drive::ResourceEntry> entry); 45 scoped_ptr<drive::ResourceEntry> entry);
46 46
47 // Part of GetSelectedFileInfo(). 47 // Part of GetSelectedFileInfo().
48 void GetSelectedFileInfoInternal(Profile* profile, 48 void GetSelectedFileInfoInternal(Profile* profile,
49 scoped_ptr<GetSelectedFileInfoParams> params) { 49 scoped_ptr<GetSelectedFileInfoParams> params) {
50 DCHECK(profile); 50 DCHECK(profile);
51 drive::DriveIntegrationService* integration_service = 51 drive::FileSystemInterface* file_system =
52 drive::DriveIntegrationServiceFactory::GetForProfile(profile); 52 drive::util::GetFileSystemByProfile(profile);
53 53
54 for (size_t i = params->selected_files.size(); 54 for (size_t i = params->selected_files.size();
55 i < params->file_paths.size(); ++i) { 55 i < params->file_paths.size(); ++i) {
56 const base::FilePath& file_path = params->file_paths[i]; 56 const base::FilePath& file_path = params->file_paths[i];
57 57
58 if (!drive::util::IsUnderDriveMountPoint(file_path)) { 58 if (!drive::util::IsUnderDriveMountPoint(file_path)) {
59 params->selected_files.push_back( 59 params->selected_files.push_back(
60 ui::SelectedFileInfo(file_path, base::FilePath())); 60 ui::SelectedFileInfo(file_path, base::FilePath()));
61 } else { 61 } else {
62 // |integration_service| is NULL if Drive is disabled. 62 // |file_system| is NULL if Drive is disabled.
63 if (!integration_service) { 63 if (!file_system) {
64 ContinueGetSelectedFileInfo(profile, 64 ContinueGetSelectedFileInfo(profile,
65 params.Pass(), 65 params.Pass(),
66 drive::FILE_ERROR_FAILED, 66 drive::FILE_ERROR_FAILED,
67 base::FilePath(), 67 base::FilePath(),
68 scoped_ptr<drive::ResourceEntry>()); 68 scoped_ptr<drive::ResourceEntry>());
69 return; 69 return;
70 } 70 }
71 // When the caller of the select file dialog wants local file paths, 71 // When the caller of the select file dialog wants local file paths,
72 // we should retrieve Drive files onto the local cache. 72 // we should retrieve Drive files onto the local cache.
73 switch (params->local_path_option) { 73 switch (params->local_path_option) {
74 case NO_LOCAL_PATH_RESOLUTION: 74 case NO_LOCAL_PATH_RESOLUTION:
75 params->selected_files.push_back( 75 params->selected_files.push_back(
76 ui::SelectedFileInfo(file_path, base::FilePath())); 76 ui::SelectedFileInfo(file_path, base::FilePath()));
77 break; 77 break;
78 case NEED_LOCAL_PATH_FOR_OPENING: 78 case NEED_LOCAL_PATH_FOR_OPENING:
79 integration_service->file_system()->GetFileByPath( 79 file_system->GetFileByPath(
80 drive::util::ExtractDrivePath(file_path), 80 drive::util::ExtractDrivePath(file_path),
81 base::Bind(&ContinueGetSelectedFileInfo, 81 base::Bind(&ContinueGetSelectedFileInfo,
82 profile, 82 profile,
83 base::Passed(&params))); 83 base::Passed(&params)));
84 return; // Remaining work is done in ContinueGetSelectedFileInfo. 84 return; // Remaining work is done in ContinueGetSelectedFileInfo.
85 case NEED_LOCAL_PATH_FOR_SAVING: 85 case NEED_LOCAL_PATH_FOR_SAVING:
86 integration_service->file_system()->GetFileByPathForSaving( 86 file_system->GetFileByPathForSaving(
87 drive::util::ExtractDrivePath(file_path), 87 drive::util::ExtractDrivePath(file_path),
88 base::Bind(&ContinueGetSelectedFileInfo, 88 base::Bind(&ContinueGetSelectedFileInfo,
89 profile, 89 profile,
90 base::Passed(&params))); 90 base::Passed(&params)));
91 return; // Remaining work is done in ContinueGetSelectedFileInfo. 91 return; // Remaining work is done in ContinueGetSelectedFileInfo.
92 } 92 }
93 } 93 }
94 } 94 }
95 params->callback.Run(params->selected_files); 95 params->callback.Run(params->selected_files);
96 } 96 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 BrowserThread::PostTask( 180 BrowserThread::PostTask(
181 BrowserThread::UI, FROM_HERE, 181 BrowserThread::UI, FROM_HERE,
182 base::Bind(&GetSelectedFileInfoInternal, 182 base::Bind(&GetSelectedFileInfoInternal,
183 profile, 183 profile,
184 base::Passed(&params))); 184 base::Passed(&params)));
185 } 185 }
186 186
187 } // namespace util 187 } // namespace util
188 } // namespace file_manager 188 } // namespace file_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698