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

Side by Side Diff: chrome/browser/extensions/api/file_handlers/app_file_handler_util.cc

Issue 137343008: Make chrome.fileSystem.chooseEntry work on Google Drive directories. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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_handlers/app_file_handler_util.h" 5 #include "chrome/browser/extensions/api/file_handlers/app_file_handler_util.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/extensions/extension_prefs.h" 9 #include "chrome/browser/extensions/extension_prefs.h"
10 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 // Reports an error in completing a work item. This may be called more than 117 // Reports an error in completing a work item. This may be called more than
118 // once, but only the last message will be retained. 118 // once, but only the last message will be retained.
119 void Error(const base::FilePath& error_path); 119 void Error(const base::FilePath& error_path);
120 120
121 void CheckLocalWritableFiles(); 121 void CheckLocalWritableFiles();
122 122
123 #if defined(OS_CHROMEOS) 123 #if defined(OS_CHROMEOS)
124 void CheckRemoteWritableFile(const base::FilePath& remote_path, 124 void CheckRemoteWritableFile(const base::FilePath& remote_path,
125 drive::FileError error, 125 drive::FileError error,
126 const base::FilePath& local_path); 126 const base::FilePath& local_path);
127 void RemoteCheckDone(const base::FilePath& remote_path,
128 drive::FileError error);
127 #endif 129 #endif
128 130
129 const std::vector<base::FilePath> paths_; 131 const std::vector<base::FilePath> paths_;
130 Profile* profile_; 132 Profile* profile_;
131 const bool is_directory_; 133 const bool is_directory_;
132 int outstanding_tasks_; 134 int outstanding_tasks_;
133 base::FilePath error_path_; 135 base::FilePath error_path_;
134 base::Closure on_success_; 136 base::Closure on_success_;
135 base::Callback<void(const base::FilePath&)> on_failure_; 137 base::Callback<void(const base::FilePath&)> on_failure_;
136 }; 138 };
(...skipping 12 matching lines...) Expand all
149 on_failure_(on_failure) {} 151 on_failure_(on_failure) {}
150 152
151 void WritableFileChecker::Check() { 153 void WritableFileChecker::Check() {
152 #if defined(OS_CHROMEOS) 154 #if defined(OS_CHROMEOS)
153 if (drive::util::IsUnderDriveMountPoint(paths_[0])) { 155 if (drive::util::IsUnderDriveMountPoint(paths_[0])) {
154 outstanding_tasks_ = paths_.size(); 156 outstanding_tasks_ = paths_.size();
155 for (std::vector<base::FilePath>::const_iterator it = paths_.begin(); 157 for (std::vector<base::FilePath>::const_iterator it = paths_.begin();
156 it != paths_.end(); 158 it != paths_.end();
157 ++it) { 159 ++it) {
158 DCHECK(drive::util::IsUnderDriveMountPoint(*it)); 160 DCHECK(drive::util::IsUnderDriveMountPoint(*it));
159 drive::util::PrepareWritableFileAndRun( 161 if (is_directory_) {
160 profile_, 162 drive::util::CheckDirectoryExists(
161 *it, 163 profile_,
162 base::Bind(&WritableFileChecker::CheckRemoteWritableFile, this, *it)); 164 *it,
165 base::Bind(&WritableFileChecker::RemoteCheckDone, this, *it));
166 } else {
167 drive::util::PrepareWritableFileAndRun(
168 profile_,
169 *it,
170 base::Bind(&WritableFileChecker::CheckRemoteWritableFile, this,
171 *it));
172 }
163 } 173 }
164 return; 174 return;
165 } 175 }
166 #endif 176 #endif
167 content::BrowserThread::PostTask( 177 content::BrowserThread::PostTask(
168 content::BrowserThread::FILE, 178 content::BrowserThread::FILE,
169 FROM_HERE, 179 FROM_HERE,
170 base::Bind(&WritableFileChecker::CheckLocalWritableFiles, this)); 180 base::Bind(&WritableFileChecker::CheckLocalWritableFiles, this));
171 } 181 }
172 182
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 content::BrowserThread::UI, 218 content::BrowserThread::UI,
209 FROM_HERE, 219 FROM_HERE,
210 base::Bind(&WritableFileChecker::TaskDone, this)); 220 base::Bind(&WritableFileChecker::TaskDone, this));
211 } 221 }
212 222
213 #if defined(OS_CHROMEOS) 223 #if defined(OS_CHROMEOS)
214 void WritableFileChecker::CheckRemoteWritableFile( 224 void WritableFileChecker::CheckRemoteWritableFile(
215 const base::FilePath& remote_path, 225 const base::FilePath& remote_path,
216 drive::FileError error, 226 drive::FileError error,
217 const base::FilePath& /* local_path */) { 227 const base::FilePath& /* local_path */) {
228 RemoteCheckDone(remote_path, error);
229 }
230
231 void WritableFileChecker::RemoteCheckDone(
232 const base::FilePath& remote_path,
233 drive::FileError error) {
218 if (error == drive::FILE_ERROR_OK) { 234 if (error == drive::FILE_ERROR_OK) {
219 content::BrowserThread::PostTask( 235 content::BrowserThread::PostTask(
220 content::BrowserThread::UI, 236 content::BrowserThread::UI,
221 FROM_HERE, 237 FROM_HERE,
222 base::Bind(&WritableFileChecker::TaskDone, this)); 238 base::Bind(&WritableFileChecker::TaskDone, this));
223 } else { 239 } else {
224 content::BrowserThread::PostTask( 240 content::BrowserThread::PostTask(
225 content::BrowserThread::UI, 241 content::BrowserThread::UI,
226 FROM_HERE, 242 FROM_HERE,
227 base::Bind(&WritableFileChecker::Error, this, remote_path)); 243 base::Bind(&WritableFileChecker::Error, this, remote_path));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 *error = kInvalidParameters; 403 *error = kInvalidParameters;
388 return false; 404 return false;
389 } 405 }
390 406
391 return true; 407 return true;
392 } 408 }
393 409
394 } // namespace app_file_handler_util 410 } // namespace app_file_handler_util
395 411
396 } // namespace extensions 412 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698