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

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

Issue 22523003: Enable Google Drive in all save-file dialogs of Chrome OS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fix Created 7 years, 4 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
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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" 9 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
10 #include "chrome/browser/chromeos/drive/file_errors.h" 10 #include "chrome/browser/chromeos/drive/file_errors.h"
(...skipping 30 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 =
52 drive::DriveIntegrationServiceFactory::GetForProfile(profile);
51 53
52 for (size_t i = params->selected_files.size(); 54 for (size_t i = params->selected_files.size();
53 i < params->file_paths.size(); ++i) { 55 i < params->file_paths.size(); ++i) {
54 const base::FilePath& file_path = params->file_paths[i]; 56 const base::FilePath& file_path = params->file_paths[i];
55 // When the caller of the select file dialog wants local file paths, 57
56 // we should retrieve Drive files onto the local cache. 58 if (!drive::util::IsUnderDriveMountPoint(file_path)) {
57 if (params->local_path_option == NO_LOCAL_PATH_RESOLUTION ||
58 !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 drive::DriveIntegrationService* integration_service =
63 drive::DriveIntegrationServiceFactory::GetForProfile(profile);
64 // |integration_service| is NULL if Drive is disabled. 62 // |integration_service| is NULL if Drive is disabled.
65 if (!integration_service) { 63 if (!integration_service) {
66 ContinueGetSelectedFileInfo(profile, 64 ContinueGetSelectedFileInfo(profile,
67 params.Pass(), 65 params.Pass(),
68 drive::FILE_ERROR_FAILED, 66 drive::FILE_ERROR_FAILED,
69 base::FilePath(), 67 base::FilePath(),
70 scoped_ptr<drive::ResourceEntry>()); 68 scoped_ptr<drive::ResourceEntry>());
71 return; 69 return;
72 } 70 }
73 // TODO(kinaba): crbug.com/140425 support FOR_SAVING 71 // When the caller of the select file dialog wants local file paths,
74 DCHECK(params->local_path_option == NEED_LOCAL_PATH_FOR_OPENING); 72 // we should retrieve Drive files onto the local cache.
75 integration_service->file_system()->GetFileByPath( 73 switch (params->local_path_option) {
76 drive::util::ExtractDrivePath(file_path), 74 case NO_LOCAL_PATH_RESOLUTION:
77 base::Bind(&ContinueGetSelectedFileInfo, 75 params->selected_files.push_back(
78 profile, 76 ui::SelectedFileInfo(file_path, base::FilePath()));
79 base::Passed(&params))); 77 break;
80 return; 78 case NEED_LOCAL_PATH_FOR_OPENING:
81 } 79 integration_service->file_system()->GetFileByPath(
80 drive::util::ExtractDrivePath(file_path),
81 base::Bind(&ContinueGetSelectedFileInfo,
82 profile,
83 base::Passed(&params)));
84 return; // Remaining work is done in ContinueGetSelectedFileInfo.
85 case NEED_LOCAL_PATH_FOR_SAVING:
86 integration_service->file_system()->GetFileByPathForSaving(
87 drive::util::ExtractDrivePath(file_path),
88 base::Bind(&ContinueGetSelectedFileInfo,
89 profile,
90 base::Passed(&params)));
91 return; // Remaining work is done in ContinueGetSelectedFileInfo.
92 }
93 }
82 } 94 }
83 params->callback.Run(params->selected_files); 95 params->callback.Run(params->selected_files);
84 } 96 }
85 97
86 // Part of GetSelectedFileInfo(). 98 // Part of GetSelectedFileInfo().
87 void ContinueGetSelectedFileInfo(Profile* profile, 99 void ContinueGetSelectedFileInfo(Profile* profile,
88 scoped_ptr<GetSelectedFileInfoParams> params, 100 scoped_ptr<GetSelectedFileInfoParams> params,
89 drive::FileError error, 101 drive::FileError error,
90 const base::FilePath& local_file_path, 102 const base::FilePath& local_file_path,
91 scoped_ptr<drive::ResourceEntry> entry) { 103 scoped_ptr<drive::ResourceEntry> entry) {
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 193
182 BrowserThread::PostTask( 194 BrowserThread::PostTask(
183 BrowserThread::UI, FROM_HERE, 195 BrowserThread::UI, FROM_HERE,
184 base::Bind(&GetSelectedFileInfoInternal, 196 base::Bind(&GetSelectedFileInfoInternal,
185 profile, 197 profile,
186 base::Passed(&params))); 198 base::Passed(&params)));
187 } 199 }
188 200
189 } // namespace util 201 } // namespace util
190 } // namespace file_manager 202 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/resources/file_manager/js/file_manager.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698