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

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

Issue 10869067: Deliver attach intent to packaged apps (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixes build error -- oops Created 8 years, 3 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
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"
11 #include "chrome/common/url_constants.h" 11 #include "chrome/common/url_constants.h"
12 #include "chrome/renderer/extensions/user_script_slave.h" 12 #include "chrome/renderer/extensions/user_script_slave.h"
13 #include "grit/renderer_resources.h" 13 #include "grit/renderer_resources.h"
14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h" 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebFileSyste m.h"
15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" 15 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" 16 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h"
17 #include "webkit/fileapi/file_system_types.h" 17 #include "webkit/fileapi/file_system_types.h"
18 #include "webkit/fileapi/file_system_util.h" 18 #include "webkit/fileapi/file_system_util.h"
19 19
20 namespace { 20 namespace {
21 21
22 static v8::Handle<v8::Value> GetIsolatedFileSystem( 22 static v8::Handle<v8::Value> GetIsolatedFileSystem(
23 const v8::Arguments& args) { 23 const v8::Arguments& args) {
24 DCHECK(args.Length() == 1); 24 DCHECK(args.Length() == 1 || args.Length() == 2);
25 DCHECK(args[0]->IsString()); 25 DCHECK(args[0]->IsString());
26 std::string file_system_id(*v8::String::Utf8Value(args[0])); 26 std::string file_system_id(*v8::String::Utf8Value(args[0]));
27 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext(); 27 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForCurrentContext();
28 DCHECK(webframe); 28 DCHECK(webframe);
29 29
30 GURL context_url = 30 GURL context_url =
31 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); 31 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe);
32 CHECK(context_url.SchemeIs(chrome::kExtensionScheme)); 32 CHECK(context_url.SchemeIs(chrome::kExtensionScheme));
33 33
34 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), 34 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(),
35 file_system_id)); 35 file_system_id));
36 36
37 std::string root(fileapi::GetFileSystemRootURI( 37 std::string root(fileapi::GetFileSystemRootURI(
38 context_url.GetOrigin(), 38 context_url.GetOrigin(),
39 fileapi::kFileSystemTypeIsolated).spec()); 39 fileapi::kFileSystemTypeIsolated).spec());
40 root.append(file_system_id); 40 root.append(file_system_id);
41 root.append("/"); 41 root.append("/");
42 42
43 // The optional second argument is the subfolder within the isolated file
44 // system at which to root the DOMFileSystem we're returning to the caller.
45 if (args.Length() == 2) {
46 DCHECK(args[1]->IsString());
47 name = *v8::String::Utf8Value(args[1]);
48 root.append(name);
49 root.append("/");
50 }
51
43 return webframe->createFileSystem( 52 return webframe->createFileSystem(
44 WebKit::WebFileSystem::TypeIsolated, 53 WebKit::WebFileSystem::TypeIsolated,
45 WebKit::WebString::fromUTF8(name.c_str()), 54 WebKit::WebString::fromUTF8(name),
46 WebKit::WebString::fromUTF8(root.c_str())); 55 WebKit::WebString::fromUTF8(root));
47 } 56 }
48 57
49 } // namespace 58 } // namespace
50 59
51 namespace extensions { 60 namespace extensions {
52 61
53 FileSystemNatives::FileSystemNatives() 62 FileSystemNatives::FileSystemNatives()
54 : ChromeV8Extension(NULL) { 63 : ChromeV8Extension(NULL) {
55 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem); 64 RouteStaticFunction("GetIsolatedFileSystem", &GetIsolatedFileSystem);
56 } 65 }
57 66
58 } // namespace extensions 67 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698