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

Side by Side Diff: chrome/browser/devtools/devtools_file_helper.cc

Issue 492873002: Collapse fileapi, webkit_blob, webkit_database, quota, and webkit_common namespaces into single sto… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos build Created 6 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
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/devtools/devtools_file_helper.h" 5 #include "chrome/browser/devtools/devtools_file_helper.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 base::WriteFile(path, content.c_str(), content.length()); 124 base::WriteFile(path, content.c_str(), content.length());
125 } 125 }
126 126
127 void AppendToFile(const base::FilePath& path, const std::string& content) { 127 void AppendToFile(const base::FilePath& path, const std::string& content) {
128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); 128 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
129 DCHECK(!path.empty()); 129 DCHECK(!path.empty());
130 130
131 base::AppendToFile(path, content.c_str(), content.length()); 131 base::AppendToFile(path, content.c_str(), content.length());
132 } 132 }
133 133
134 fileapi::IsolatedContext* isolated_context() { 134 storage::IsolatedContext* isolated_context() {
135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 135 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
136 fileapi::IsolatedContext* isolated_context = 136 storage::IsolatedContext* isolated_context =
137 fileapi::IsolatedContext::GetInstance(); 137 storage::IsolatedContext::GetInstance();
138 DCHECK(isolated_context); 138 DCHECK(isolated_context);
139 return isolated_context; 139 return isolated_context;
140 } 140 }
141 141
142 std::string RegisterFileSystem(WebContents* web_contents, 142 std::string RegisterFileSystem(WebContents* web_contents,
143 const base::FilePath& path, 143 const base::FilePath& path,
144 std::string* registered_name) { 144 std::string* registered_name) {
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
146 CHECK(web_contents->GetURL().SchemeIs(content::kChromeDevToolsScheme)); 146 CHECK(web_contents->GetURL().SchemeIs(content::kChromeDevToolsScheme));
147 std::string file_system_id = isolated_context()->RegisterFileSystemForPath( 147 std::string file_system_id = isolated_context()->RegisterFileSystemForPath(
148 fileapi::kFileSystemTypeNativeLocal, std::string(), path, 148 storage::kFileSystemTypeNativeLocal,
149 std::string(),
150 path,
149 registered_name); 151 registered_name);
150 152
151 content::ChildProcessSecurityPolicy* policy = 153 content::ChildProcessSecurityPolicy* policy =
152 content::ChildProcessSecurityPolicy::GetInstance(); 154 content::ChildProcessSecurityPolicy::GetInstance();
153 RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); 155 RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
154 int renderer_id = render_view_host->GetProcess()->GetID(); 156 int renderer_id = render_view_host->GetProcess()->GetID();
155 policy->GrantReadFileSystem(renderer_id, file_system_id); 157 policy->GrantReadFileSystem(renderer_id, file_system_id);
156 policy->GrantWriteFileSystem(renderer_id, file_system_id); 158 policy->GrantWriteFileSystem(renderer_id, file_system_id);
157 policy->GrantCreateFileForFileSystem(renderer_id, file_system_id); 159 policy->GrantCreateFileForFileSystem(renderer_id, file_system_id);
158 policy->GrantDeleteFromFileSystem(renderer_id, file_system_id); 160 policy->GrantDeleteFromFileSystem(renderer_id, file_system_id);
159 161
160 // We only need file level access for reading FileEntries. Saving FileEntries 162 // We only need file level access for reading FileEntries. Saving FileEntries
161 // just needs the file system to have read/write access, which is granted 163 // just needs the file system to have read/write access, which is granted
162 // above if required. 164 // above if required.
163 if (!policy->CanReadFile(renderer_id, path)) 165 if (!policy->CanReadFile(renderer_id, path))
164 policy->GrantReadFile(renderer_id, path); 166 policy->GrantReadFile(renderer_id, path);
165 167
166 return file_system_id; 168 return file_system_id;
167 } 169 }
168 170
169 DevToolsFileHelper::FileSystem CreateFileSystemStruct( 171 DevToolsFileHelper::FileSystem CreateFileSystemStruct(
170 WebContents* web_contents, 172 WebContents* web_contents,
171 const std::string& file_system_id, 173 const std::string& file_system_id,
172 const std::string& registered_name, 174 const std::string& registered_name,
173 const std::string& file_system_path) { 175 const std::string& file_system_path) {
174 const GURL origin = web_contents->GetURL().GetOrigin(); 176 const GURL origin = web_contents->GetURL().GetOrigin();
175 std::string file_system_name = fileapi::GetIsolatedFileSystemName( 177 std::string file_system_name =
176 origin, 178 storage::GetIsolatedFileSystemName(origin, file_system_id);
177 file_system_id); 179 std::string root_url = storage::GetIsolatedFileSystemRootURIString(
178 std::string root_url = fileapi::GetIsolatedFileSystemRootURIString( 180 origin, file_system_id, registered_name);
179 origin,
180 file_system_id,
181 registered_name);
182 return DevToolsFileHelper::FileSystem(file_system_name, 181 return DevToolsFileHelper::FileSystem(file_system_name,
183 root_url, 182 root_url,
184 file_system_path); 183 file_system_path);
185 } 184 }
186 185
187 set<std::string> GetAddedFileSystemPaths(Profile* profile) { 186 set<std::string> GetAddedFileSystemPaths(Profile* profile) {
188 const base::DictionaryValue* file_systems_paths_value = 187 const base::DictionaryValue* file_systems_paths_value =
189 profile->GetPrefs()->GetDictionary(prefs::kDevToolsFileSystemPaths); 188 profile->GetPrefs()->GetDictionary(prefs::kDevToolsFileSystemPaths);
190 set<std::string> result; 189 set<std::string> result;
191 for (base::DictionaryValue::Iterator it(*file_systems_paths_value); 190 for (base::DictionaryValue::Iterator it(*file_systems_paths_value);
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 Bind(callback, FileSystem()), 312 Bind(callback, FileSystem()),
314 web_contents_); 313 web_contents_);
315 select_file_dialog->Show(ui::SelectFileDialog::SELECT_FOLDER, 314 select_file_dialog->Show(ui::SelectFileDialog::SELECT_FOLDER,
316 base::FilePath()); 315 base::FilePath());
317 } 316 }
318 317
319 void DevToolsFileHelper::UpgradeDraggedFileSystemPermissions( 318 void DevToolsFileHelper::UpgradeDraggedFileSystemPermissions(
320 const std::string& file_system_url, 319 const std::string& file_system_url,
321 const AddFileSystemCallback& callback, 320 const AddFileSystemCallback& callback,
322 const ShowInfoBarCallback& show_info_bar_callback) { 321 const ShowInfoBarCallback& show_info_bar_callback) {
323 fileapi::FileSystemURL root_url = 322 storage::FileSystemURL root_url =
324 isolated_context()->CrackURL(GURL(file_system_url)); 323 isolated_context()->CrackURL(GURL(file_system_url));
325 if (!root_url.is_valid() || !root_url.path().empty()) { 324 if (!root_url.is_valid() || !root_url.path().empty()) {
326 callback.Run(FileSystem()); 325 callback.Run(FileSystem());
327 return; 326 return;
328 } 327 }
329 328
330 std::vector<fileapi::MountPoints::MountPointInfo> mount_points; 329 std::vector<storage::MountPoints::MountPointInfo> mount_points;
331 isolated_context()->GetDraggedFileInfo(root_url.filesystem_id(), 330 isolated_context()->GetDraggedFileInfo(root_url.filesystem_id(),
332 &mount_points); 331 &mount_points);
333 332
334 std::vector<fileapi::MountPoints::MountPointInfo>::const_iterator it = 333 std::vector<storage::MountPoints::MountPointInfo>::const_iterator it =
335 mount_points.begin(); 334 mount_points.begin();
336 for (; it != mount_points.end(); ++it) 335 for (; it != mount_points.end(); ++it)
337 InnerAddFileSystem(callback, show_info_bar_callback, it->path); 336 InnerAddFileSystem(callback, show_info_bar_callback, it->path);
338 } 337 }
339 338
340 void DevToolsFileHelper::InnerAddFileSystem( 339 void DevToolsFileHelper::InnerAddFileSystem(
341 const AddFileSystemCallback& callback, 340 const AddFileSystemCallback& callback,
342 const ShowInfoBarCallback& show_info_bar_callback, 341 const ShowInfoBarCallback& show_info_bar_callback,
343 const base::FilePath& path) { 342 const base::FilePath& path) {
344 std::string file_system_path = path.AsUTF8Unsafe(); 343 std::string file_system_path = path.AsUTF8Unsafe();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 base::DictionaryValue* file_systems_paths_value = update.Get(); 419 base::DictionaryValue* file_systems_paths_value = update.Get();
421 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL); 420 file_systems_paths_value->RemoveWithoutPathExpansion(file_system_path, NULL);
422 } 421 }
423 422
424 bool DevToolsFileHelper::IsFileSystemAdded( 423 bool DevToolsFileHelper::IsFileSystemAdded(
425 const std::string& file_system_path) { 424 const std::string& file_system_path) {
426 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 425 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
427 set<std::string> file_system_paths = GetAddedFileSystemPaths(profile_); 426 set<std::string> file_system_paths = GetAddedFileSystemPaths(profile_);
428 return file_system_paths.find(file_system_path) != file_system_paths.end(); 427 return file_system_paths.find(file_system_path) != file_system_paths.end();
429 } 428 }
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/tab_specific_content_settings.cc ('k') | chrome/browser/diagnostics/sqlite_diagnostics.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698