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

Side by Side Diff: chrome/renderer/extensions/file_system_natives.cc

Issue 11833002: Cleanup: Add fileapi::GetIsolatedFileSystemRootURIString (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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/renderer/extensions/file_system_natives.h" 5 #include "chrome/renderer/extensions/file_system_natives.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 17 matching lines...) Expand all
28 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); 28 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
29 DCHECK(webframe); 29 DCHECK(webframe);
30 30
31 GURL context_url = 31 GURL context_url =
32 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); 32 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe);
33 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); 33 CHECK(context_url.SchemeIs(extensions::kExtensionScheme));
34 34
35 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), 35 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(),
36 file_system_id)); 36 file_system_id));
37 37
38 std::string root(fileapi::GetFileSystemRootURI(
39 context_url.GetOrigin(),
40 fileapi::kFileSystemTypeIsolated).spec());
41 root.append(file_system_id);
42 root.append("/");
43
44 // The optional second argument is the subfolder within the isolated file 38 // The optional second argument is the subfolder within the isolated file
45 // system at which to root the DOMFileSystem we're returning to the caller. 39 // system at which to root the DOMFileSystem we're returning to the caller.
40 std::string optional_root_name;
46 if (args.Length() == 2) { 41 if (args.Length() == 2) {
47 DCHECK(args[1]->IsString()); 42 DCHECK(args[1]->IsString());
48 name = *v8::String::Utf8Value(args[1]); 43 optional_root_name = *v8::String::Utf8Value(args[1]);
49 root.append(name);
50 root.append("/");
51 } 44 }
52 45
46 std::string root(fileapi::GetIsolatedFileSystemRootURIString(
47 context_url.GetOrigin(),
48 file_system_id,
49 optional_root_name));
50
53 return webframe->createFileSystem( 51 return webframe->createFileSystem(
54 WebKit::WebFileSystem::TypeIsolated, 52 WebKit::WebFileSystem::TypeIsolated,
55 WebKit::WebString::fromUTF8(name), 53 WebKit::WebString::fromUTF8(name),
56 WebKit::WebString::fromUTF8(root)); 54 WebKit::WebString::fromUTF8(root));
57 } 55 }
58 56
59 } // namespace 57 } // namespace
60 58
61 namespace extensions { 59 namespace extensions {
62 60
63 FileSystemNatives::FileSystemNatives() 61 FileSystemNatives::FileSystemNatives()
64 : ChromeV8Extension(NULL) { 62 : ChromeV8Extension(NULL) {
65 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); 63 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem);
66 } 64 }
67 65
68 } // namespace extensions 66 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/extensions/media_galleries_custom_bindings.cc » ('j') | webkit/fileapi/file_system_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698