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

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

Issue 63273002: Rename WebKit namespace to blink (part 4) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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 21 matching lines...) Expand all
32 RouteFunction("CrackIsolatedFileSystemName", 32 RouteFunction("CrackIsolatedFileSystemName",
33 base::Bind(&FileSystemNatives::CrackIsolatedFileSystemName, 33 base::Bind(&FileSystemNatives::CrackIsolatedFileSystemName,
34 base::Unretained(this))); 34 base::Unretained(this)));
35 } 35 }
36 36
37 void FileSystemNatives::GetIsolatedFileSystem( 37 void FileSystemNatives::GetIsolatedFileSystem(
38 const v8::FunctionCallbackInfo<v8::Value>& args) { 38 const v8::FunctionCallbackInfo<v8::Value>& args) {
39 DCHECK(args.Length() == 1 || args.Length() == 2); 39 DCHECK(args.Length() == 1 || args.Length() == 2);
40 DCHECK(args[0]->IsString()); 40 DCHECK(args[0]->IsString());
41 std::string file_system_id(*v8::String::Utf8Value(args[0])); 41 std::string file_system_id(*v8::String::Utf8Value(args[0]));
42 WebKit::WebFrame* webframe = 42 blink::WebFrame* webframe =
43 WebKit::WebFrame::frameForContext(context()->v8_context()); 43 blink::WebFrame::frameForContext(context()->v8_context());
44 DCHECK(webframe); 44 DCHECK(webframe);
45 45
46 GURL context_url = 46 GURL context_url =
47 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe); 47 extensions::UserScriptSlave::GetDataSourceURLForFrame(webframe);
48 CHECK(context_url.SchemeIs(extensions::kExtensionScheme)); 48 CHECK(context_url.SchemeIs(extensions::kExtensionScheme));
49 49
50 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(), 50 std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(),
51 file_system_id)); 51 file_system_id));
52 52
53 // The optional second argument is the subfolder within the isolated file 53 // The optional second argument is the subfolder within the isolated file
54 // system at which to root the DOMFileSystem we're returning to the caller. 54 // system at which to root the DOMFileSystem we're returning to the caller.
55 std::string optional_root_name; 55 std::string optional_root_name;
56 if (args.Length() == 2) { 56 if (args.Length() == 2) {
57 DCHECK(args[1]->IsString()); 57 DCHECK(args[1]->IsString());
58 optional_root_name = *v8::String::Utf8Value(args[1]); 58 optional_root_name = *v8::String::Utf8Value(args[1]);
59 } 59 }
60 60
61 std::string root(fileapi::GetIsolatedFileSystemRootURIString( 61 std::string root(fileapi::GetIsolatedFileSystemRootURIString(
62 context_url.GetOrigin(), 62 context_url.GetOrigin(),
63 file_system_id, 63 file_system_id,
64 optional_root_name)); 64 optional_root_name));
65 65
66 args.GetReturnValue().Set(webframe->createFileSystem( 66 args.GetReturnValue().Set(webframe->createFileSystem(
67 WebKit::WebFileSystemTypeIsolated, 67 blink::WebFileSystemTypeIsolated,
68 WebKit::WebString::fromUTF8(name), 68 blink::WebString::fromUTF8(name),
69 WebKit::WebString::fromUTF8(root))); 69 blink::WebString::fromUTF8(root)));
70 } 70 }
71 71
72 void FileSystemNatives::GetFileEntry( 72 void FileSystemNatives::GetFileEntry(
73 const v8::FunctionCallbackInfo<v8::Value>& args) { 73 const v8::FunctionCallbackInfo<v8::Value>& args) {
74 DCHECK(args.Length() == 5); 74 DCHECK(args.Length() == 5);
75 DCHECK(args[0]->IsString()); 75 DCHECK(args[0]->IsString());
76 std::string type_string = *v8::String::Utf8Value(args[0]->ToString()); 76 std::string type_string = *v8::String::Utf8Value(args[0]->ToString());
77 WebKit::WebFileSystemType type; 77 blink::WebFileSystemType type;
78 bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type); 78 bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type);
79 DCHECK(is_valid_type); 79 DCHECK(is_valid_type);
80 if (is_valid_type == false) { 80 if (is_valid_type == false) {
81 return; 81 return;
82 } 82 }
83 83
84 DCHECK(args[1]->IsString()); 84 DCHECK(args[1]->IsString());
85 DCHECK(args[2]->IsString()); 85 DCHECK(args[2]->IsString());
86 DCHECK(args[3]->IsString()); 86 DCHECK(args[3]->IsString());
87 std::string file_system_name(*v8::String::Utf8Value(args[1]->ToString())); 87 std::string file_system_name(*v8::String::Utf8Value(args[1]->ToString()));
88 std::string file_system_root_url(*v8::String::Utf8Value(args[2]->ToString())); 88 std::string file_system_root_url(*v8::String::Utf8Value(args[2]->ToString()));
89 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString())); 89 std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString()));
90 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string); 90 base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string);
91 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value())); 91 DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value()));
92 92
93 DCHECK(args[4]->IsBoolean()); 93 DCHECK(args[4]->IsBoolean());
94 bool is_directory = args[4]->BooleanValue(); 94 bool is_directory = args[4]->BooleanValue();
95 95
96 WebKit::WebFrame* webframe = 96 blink::WebFrame* webframe =
97 WebKit::WebFrame::frameForContext(context()->v8_context()); 97 blink::WebFrame::frameForContext(context()->v8_context());
98 DCHECK(webframe); 98 DCHECK(webframe);
99 args.GetReturnValue().Set(webframe->createFileEntry( 99 args.GetReturnValue().Set(webframe->createFileEntry(
100 type, 100 type,
101 WebKit::WebString::fromUTF8(file_system_name), 101 blink::WebString::fromUTF8(file_system_name),
102 WebKit::WebString::fromUTF8(file_system_root_url), 102 blink::WebString::fromUTF8(file_system_root_url),
103 WebKit::WebString::fromUTF8(file_path_string), 103 blink::WebString::fromUTF8(file_path_string),
104 is_directory)); 104 is_directory));
105 } 105 }
106 106
107 void FileSystemNatives::CrackIsolatedFileSystemName( 107 void FileSystemNatives::CrackIsolatedFileSystemName(
108 const v8::FunctionCallbackInfo<v8::Value>& args) { 108 const v8::FunctionCallbackInfo<v8::Value>& args) {
109 DCHECK_EQ(args.Length(), 1); 109 DCHECK_EQ(args.Length(), 1);
110 DCHECK(args[0]->IsString()); 110 DCHECK(args[0]->IsString());
111 std::string filesystem_name = *v8::String::Utf8Value(args[0]->ToString()); 111 std::string filesystem_name = *v8::String::Utf8Value(args[0]->ToString());
112 std::string filesystem_id; 112 std::string filesystem_id;
113 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id)) 113 if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id))
114 return; 114 return;
115 115
116 args.GetReturnValue().Set( 116 args.GetReturnValue().Set(
117 v8::String::New(filesystem_id.c_str(), filesystem_id.size())); 117 v8::String::New(filesystem_id.c_str(), filesystem_id.size()));
118 } 118 }
119 119
120 } // namespace extensions 120 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698