OLD | NEW |
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 "extensions/common/constants.h" | 13 #include "extensions/common/constants.h" |
14 #include "grit/renderer_resources.h" | 14 #include "grit/renderer_resources.h" |
15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" | 15 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystem.h" |
| 16 #include "third_party/WebKit/Source/Platform/chromium/public/WebFileSystemType.h
" |
16 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" | 17 #include "third_party/WebKit/Source/Platform/chromium/public/WebString.h" |
17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
18 #include "webkit/fileapi/file_system_types.h" | 19 #include "webkit/fileapi/file_system_types.h" |
19 #include "webkit/fileapi/file_system_util.h" | 20 #include "webkit/fileapi/file_system_util.h" |
20 | 21 |
21 namespace extensions { | 22 namespace extensions { |
22 | 23 |
23 FileSystemNatives::FileSystemNatives(v8::Handle<v8::Context> context) | 24 FileSystemNatives::FileSystemNatives(v8::Handle<v8::Context> context) |
24 : ObjectBackedNativeHandler(context) { | 25 : ObjectBackedNativeHandler(context) { |
25 RouteFunction("GetFileEntry", | 26 RouteFunction("GetFileEntry", |
(...skipping 25 matching lines...) Expand all Loading... |
51 DCHECK(args[1]->IsString()); | 52 DCHECK(args[1]->IsString()); |
52 optional_root_name = *v8::String::Utf8Value(args[1]); | 53 optional_root_name = *v8::String::Utf8Value(args[1]); |
53 } | 54 } |
54 | 55 |
55 std::string root(fileapi::GetIsolatedFileSystemRootURIString( | 56 std::string root(fileapi::GetIsolatedFileSystemRootURIString( |
56 context_url.GetOrigin(), | 57 context_url.GetOrigin(), |
57 file_system_id, | 58 file_system_id, |
58 optional_root_name)); | 59 optional_root_name)); |
59 | 60 |
60 return webframe->createFileSystem( | 61 return webframe->createFileSystem( |
| 62 #ifdef WEBKIT_USE_NEW_WEBFILESYSTEMTYPE |
| 63 WebKit::WebFileSystemTypeIsolated, |
| 64 #else |
61 WebKit::WebFileSystem::TypeIsolated, | 65 WebKit::WebFileSystem::TypeIsolated, |
| 66 #endif |
62 WebKit::WebString::fromUTF8(name), | 67 WebKit::WebString::fromUTF8(name), |
63 WebKit::WebString::fromUTF8(root)); | 68 WebKit::WebString::fromUTF8(root)); |
64 } | 69 } |
65 | 70 |
66 v8::Handle<v8::Value> FileSystemNatives::GetFileEntry( | 71 v8::Handle<v8::Value> FileSystemNatives::GetFileEntry( |
67 const v8::Arguments& args) { | 72 const v8::Arguments& args) { |
68 DCHECK(args.Length() == 5); | 73 DCHECK(args.Length() == 5); |
69 DCHECK(args[0]->IsString()); | 74 DCHECK(args[0]->IsString()); |
70 std::string type_string = *v8::String::Utf8Value(args[0]->ToString()); | 75 std::string type_string = *v8::String::Utf8Value(args[0]->ToString()); |
| 76 #ifdef WEBKIT_USE_NEW_WEBFILESYSTEMTYPE |
| 77 WebKit::WebFileSystemType type; |
| 78 #else |
71 WebKit::WebFileSystem::Type type; | 79 WebKit::WebFileSystem::Type type; |
| 80 #endif |
72 bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type); | 81 bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type); |
73 DCHECK(is_valid_type); | 82 DCHECK(is_valid_type); |
74 if (is_valid_type == false) { | 83 if (is_valid_type == false) { |
75 return v8::Undefined(); | 84 return v8::Undefined(); |
76 } | 85 } |
77 | 86 |
78 DCHECK(args[1]->IsString()); | 87 DCHECK(args[1]->IsString()); |
79 DCHECK(args[2]->IsString()); | 88 DCHECK(args[2]->IsString()); |
80 DCHECK(args[3]->IsString()); | 89 DCHECK(args[3]->IsString()); |
81 std::string file_system_name(*v8::String::Utf8Value(args[1]->ToString())); | 90 std::string file_system_name(*v8::String::Utf8Value(args[1]->ToString())); |
82 std::string file_system_root_url(*v8::String::Utf8Value(args[2]->ToString())); | 91 std::string file_system_root_url(*v8::String::Utf8Value(args[2]->ToString())); |
83 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString())); | 92 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString())); |
84 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string); | 93 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string); |
85 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value())); | 94 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value())); |
86 | 95 |
87 DCHECK(args[4]->IsBoolean()); | 96 DCHECK(args[4]->IsBoolean()); |
88 bool is_directory = args[4]->BooleanValue(); | 97 bool is_directory = args[4]->BooleanValue(); |
89 | 98 |
90 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); | 99 WebKit::WebFrame* webframe = WebKit::WebFrame::frameForContext(v8_context()); |
91 DCHECK(webframe); | 100 DCHECK(webframe); |
92 return webframe->createFileEntry( | 101 return webframe->createFileEntry( |
93 type, | 102 type, |
94 WebKit::WebString::fromUTF8(file_system_name), | 103 WebKit::WebString::fromUTF8(file_system_name), |
95 WebKit::WebString::fromUTF8(file_system_root_url), | 104 WebKit::WebString::fromUTF8(file_system_root_url), |
96 WebKit::WebString::fromUTF8(file_path_string), | 105 WebKit::WebString::fromUTF8(file_path_string), |
97 is_directory); | 106 is_directory); |
98 } | 107 } |
99 | 108 |
100 } // namespace extensions | 109 } // namespace extensions |
OLD | NEW |