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

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

Issue 13023002: Change chrome.filesystem to handle the Chrome OS Drive file entries directly. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: COmment. Created 7 years, 9 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 "chrome/browser/extensions/extension_prefs.h" 7 #include "chrome/browser/extensions/extension_prefs.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/extensions/extension_system.h" 9 #include "chrome/browser/extensions/extension_system.h"
10 #include "content/public/browser/child_process_security_policy.h" 10 #include "content/public/browser/child_process_security_policy.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 const std::string& extension_id, 93 const std::string& extension_id,
94 int renderer_id, 94 int renderer_id,
95 const base::FilePath& path, 95 const base::FilePath& path,
96 bool writable) { 96 bool writable) {
97 GrantedFileEntry result; 97 GrantedFileEntry result;
98 fileapi::IsolatedContext* isolated_context = 98 fileapi::IsolatedContext* isolated_context =
99 fileapi::IsolatedContext::GetInstance(); 99 fileapi::IsolatedContext::GetInstance();
100 DCHECK(isolated_context); 100 DCHECK(isolated_context);
101 101
102 result.filesystem_id = isolated_context->RegisterFileSystemForPath( 102 result.filesystem_id = isolated_context->RegisterFileSystemForPath(
103 fileapi::kFileSystemTypeNativeLocal, path, &result.registered_name); 103 fileapi::kFileSystemTypeNativeForPlatformApp, path,
104 &result.registered_name);
104 105
105 content::ChildProcessSecurityPolicy* policy = 106 content::ChildProcessSecurityPolicy* policy =
106 content::ChildProcessSecurityPolicy::GetInstance(); 107 content::ChildProcessSecurityPolicy::GetInstance();
107 policy->GrantReadFileSystem(renderer_id, result.filesystem_id); 108 policy->GrantReadFileSystem(renderer_id, result.filesystem_id);
108 if (writable) 109 if (writable)
109 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id); 110 policy->GrantWriteFileSystem(renderer_id, result.filesystem_id);
110 111
111 result.id = result.filesystem_id + ":" + result.registered_name; 112 result.id = result.filesystem_id + ":" + result.registered_name;
112 113
113 // We only need file level access for reading FileEntries. Saving FileEntries 114 // We only need file level access for reading FileEntries. Saving FileEntries
114 // just needs the file system to have read/write access, which is granted 115 // just needs the file system to have read/write access, which is granted
115 // above if required. 116 // above if required.
116 if (!policy->CanReadFile(renderer_id, path)) 117 if (!policy->CanReadFile(renderer_id, path))
117 policy->GrantReadFile(renderer_id, path); 118 policy->GrantReadFile(renderer_id, path);
118 119
119 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile)-> 120 ExtensionPrefs* prefs = extensions::ExtensionSystem::Get(profile)->
120 extension_service()->extension_prefs(); 121 extension_service()->extension_prefs();
121 // Save this file entry in the prefs. 122 // Save this file entry in the prefs.
122 prefs->AddSavedFileEntry(extension_id, result.id, path, writable); 123 prefs->AddSavedFileEntry(extension_id, result.id, path, writable);
123 124
124 return result; 125 return result;
125 } 126 }
126 127
127 } // namespace app_file_handler_util 128 } // namespace app_file_handler_util
128 129
129 } // namespace extensions 130 } // namespace extensions
OLDNEW
« no previous file with comments | « apps/app_restore_service_browsertest.cc ('k') | chrome/browser/extensions/api/file_system/file_system_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698