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

Side by Side Diff: chrome/browser/extensions/extension_file_browser_private_api.cc

Issue 6767010: More filesystem cleanup: convert URL-encoded-as-FilePath to actual URL, where (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/extension_file_browser_private_api.h" 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h"
6 6
7 #include "base/json/json_writer.h" 7 #include "base/json/json_writer.h"
8 #include "base/task.h" 8 #include "base/task.h"
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/common/extensions/extension.h" 11 #include "chrome/common/extensions/extension.h"
12 #include "content/browser/browser_thread.h" 12 #include "content/browser/browser_thread.h"
13 #include "googleurl/src/gurl.h"
13 #include "webkit/fileapi/file_system_operation.h" 14 #include "webkit/fileapi/file_system_operation.h"
14 #include "webkit/fileapi/file_system_types.h" 15 #include "webkit/fileapi/file_system_types.h"
15 16
16 class LocalFileSystemCallbackDispatcher 17 class LocalFileSystemCallbackDispatcher
17 : public fileapi::FileSystemCallbackDispatcher { 18 : public fileapi::FileSystemCallbackDispatcher {
18 public: 19 public:
19 explicit LocalFileSystemCallbackDispatcher( 20 explicit LocalFileSystemCallbackDispatcher(
20 RequestLocalFileSystemFunction* function) : function_(function) { 21 RequestLocalFileSystemFunction* function) : function_(function) {
21 DCHECK(function_); 22 DCHECK(function_);
22 } 23 }
23 // fileapi::FileSystemCallbackDispatcher overrides. 24 // fileapi::FileSystemCallbackDispatcher overrides.
24 virtual void DidSucceed() OVERRIDE { 25 virtual void DidSucceed() OVERRIDE {
25 NOTREACHED(); 26 NOTREACHED();
26 } 27 }
27 virtual void DidReadMetadata(const base::PlatformFileInfo& info, 28 virtual void DidReadMetadata(const base::PlatformFileInfo& info,
28 const FilePath& unused) OVERRIDE { 29 const FilePath& unused) OVERRIDE {
29 NOTREACHED(); 30 NOTREACHED();
30 } 31 }
31 virtual void DidReadDirectory( 32 virtual void DidReadDirectory(
32 const std::vector<base::FileUtilProxy::Entry>& entries, 33 const std::vector<base::FileUtilProxy::Entry>& entries,
33 bool has_more) OVERRIDE { 34 bool has_more) OVERRIDE {
34 NOTREACHED(); 35 NOTREACHED();
35 } 36 }
36 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE { 37 virtual void DidWrite(int64 bytes, bool complete) OVERRIDE {
37 NOTREACHED(); 38 NOTREACHED();
38 } 39 }
39 virtual void DidOpenFileSystem(const std::string& name, 40 virtual void DidOpenFileSystem(const std::string& name,
40 const FilePath& path) OVERRIDE { 41 const GURL& root) OVERRIDE {
41 BrowserThread::PostTask( 42 BrowserThread::PostTask(
42 BrowserThread::UI, FROM_HERE, 43 BrowserThread::UI, FROM_HERE,
43 NewRunnableMethod(function_, 44 NewRunnableMethod(function_,
44 &RequestLocalFileSystemFunction::RespondSuccessOnUIThread, 45 &RequestLocalFileSystemFunction::RespondSuccessOnUIThread,
45 name, 46 name,
46 path)); 47 root));
47 } 48 }
48 virtual void DidFail(base::PlatformFileError error_code) OVERRIDE { 49 virtual void DidFail(base::PlatformFileError error_code) OVERRIDE {
49 BrowserThread::PostTask( 50 BrowserThread::PostTask(
50 BrowserThread::UI, FROM_HERE, 51 BrowserThread::UI, FROM_HERE,
51 NewRunnableMethod(function_, 52 NewRunnableMethod(function_,
52 &RequestLocalFileSystemFunction::RespondFailedOnUIThread, 53 &RequestLocalFileSystemFunction::RespondFailedOnUIThread,
53 error_code)); 54 error_code));
54 } 55 }
55 private: 56 private:
56 RequestLocalFileSystemFunction* function_; 57 RequestLocalFileSystemFunction* function_;
(...skipping 14 matching lines...) Expand all
71 profile()->GetFileSystemContext(), 72 profile()->GetFileSystemContext(),
72 NULL); 73 NULL);
73 GURL origin_url = source_url().GetOrigin(); 74 GURL origin_url = source_url().GetOrigin();
74 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeLocal, 75 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeLocal,
75 false); // create 76 false); // create
76 // Will finish asynchronously. 77 // Will finish asynchronously.
77 return true; 78 return true;
78 } 79 }
79 80
80 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( 81 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread(
81 const std::string& name, const FilePath& path) { 82 const std::string& name, const GURL& root) {
82 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 83 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
83 result_.reset(new DictionaryValue()); 84 result_.reset(new DictionaryValue());
84 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); 85 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());
85 dict->SetString("name", name); 86 dict->SetString("name", name);
86 dict->SetString("path", path.value()); 87 dict->SetString("path", root.spec());
87 dict->SetInteger("error", base::PLATFORM_FILE_OK); 88 dict->SetInteger("error", base::PLATFORM_FILE_OK);
88 SendResponse(true); 89 SendResponse(true);
89 } 90 }
90 91
91 void RequestLocalFileSystemFunction::RespondFailedOnUIThread( 92 void RequestLocalFileSystemFunction::RespondFailedOnUIThread(
92 base::PlatformFileError error_code) { 93 base::PlatformFileError error_code) {
93 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 94 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
94 result_.reset(new DictionaryValue()); 95 result_.reset(new DictionaryValue());
95 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); 96 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get());
96 dict->SetInteger("error", static_cast<int>(error_code)); 97 dict->SetInteger("error", static_cast<int>(error_code));
97 SendResponse(true); 98 SendResponse(true);
98 } 99 }
99 100
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698