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

Unified Diff: chrome/renderer/extensions/file_system_natives.cc

Issue 235943018: Move extensions bindings code out of //chrome (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/extensions/file_system_natives.h ('k') | chrome/renderer/extensions/i18n_custom_bindings.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/extensions/file_system_natives.cc
diff --git a/chrome/renderer/extensions/file_system_natives.cc b/chrome/renderer/extensions/file_system_natives.cc
deleted file mode 100644
index 8c83c8e7075aeb7024a7adb362f11f02b94b636a..0000000000000000000000000000000000000000
--- a/chrome/renderer/extensions/file_system_natives.cc
+++ /dev/null
@@ -1,160 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/renderer/extensions/file_system_natives.h"
-
-#include <string>
-
-#include "base/basictypes.h"
-#include "base/logging.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/renderer/extensions/chrome_v8_context.h"
-#include "chrome/renderer/extensions/user_script_slave.h"
-#include "extensions/common/constants.h"
-#include "extensions/renderer/script_context.h"
-#include "grit/renderer_resources.h"
-#include "third_party/WebKit/public/platform/WebString.h"
-#include "third_party/WebKit/public/web/WebDOMError.h"
-#include "third_party/WebKit/public/web/WebDOMFileSystem.h"
-#include "third_party/WebKit/public/web/WebLocalFrame.h"
-#include "webkit/common/fileapi/file_system_types.h"
-#include "webkit/common/fileapi/file_system_util.h"
-
-namespace extensions {
-
-FileSystemNatives::FileSystemNatives(ChromeV8Context* context)
- : ObjectBackedNativeHandler(context) {
- RouteFunction("GetFileEntry",
- base::Bind(&FileSystemNatives::GetFileEntry, base::Unretained(this)));
- RouteFunction("GetIsolatedFileSystem",
- base::Bind(&FileSystemNatives::GetIsolatedFileSystem,
- base::Unretained(this)));
- RouteFunction("CrackIsolatedFileSystemName",
- base::Bind(&FileSystemNatives::CrackIsolatedFileSystemName,
- base::Unretained(this)));
- RouteFunction("GetDOMError",
- base::Bind(&FileSystemNatives::GetDOMError,
- base::Unretained(this)));
-}
-
-void FileSystemNatives::GetIsolatedFileSystem(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- DCHECK(args.Length() == 1 || args.Length() == 2);
- DCHECK(args[0]->IsString());
- std::string file_system_id(*v8::String::Utf8Value(args[0]));
- blink::WebLocalFrame* webframe =
- blink::WebLocalFrame::frameForContext(context()->v8_context());
- DCHECK(webframe);
-
- GURL context_url =
- extensions::ScriptContext::GetDataSourceURLForFrame(webframe);
- CHECK(context_url.SchemeIs(extensions::kExtensionScheme));
-
- std::string name(fileapi::GetIsolatedFileSystemName(context_url.GetOrigin(),
- file_system_id));
-
- // The optional second argument is the subfolder within the isolated file
- // system at which to root the DOMFileSystem we're returning to the caller.
- std::string optional_root_name;
- if (args.Length() == 2) {
- DCHECK(args[1]->IsString());
- optional_root_name = *v8::String::Utf8Value(args[1]);
- }
-
- GURL root_url(fileapi::GetIsolatedFileSystemRootURIString(
- context_url.GetOrigin(),
- file_system_id,
- optional_root_name));
-
- args.GetReturnValue().Set(
- blink::WebDOMFileSystem::create(
- webframe,
- blink::WebFileSystemTypeIsolated,
- blink::WebString::fromUTF8(name),
- root_url).toV8Value());
-}
-
-void FileSystemNatives::GetFileEntry(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- DCHECK(args.Length() == 5);
- DCHECK(args[0]->IsString());
- std::string type_string = *v8::String::Utf8Value(args[0]->ToString());
- blink::WebFileSystemType type;
- bool is_valid_type = fileapi::GetFileSystemPublicType(type_string, &type);
- DCHECK(is_valid_type);
- if (is_valid_type == false) {
- return;
- }
-
- DCHECK(args[1]->IsString());
- DCHECK(args[2]->IsString());
- DCHECK(args[3]->IsString());
- std::string file_system_name(*v8::String::Utf8Value(args[1]->ToString()));
- GURL file_system_root_url(*v8::String::Utf8Value(args[2]->ToString()));
- std::string file_path_string(*v8::String::Utf8Value(args[3]->ToString()));
- base::FilePath file_path = base::FilePath::FromUTF8Unsafe(file_path_string);
- DCHECK(fileapi::VirtualPath::IsAbsolute(file_path.value()));
-
- DCHECK(args[4]->IsBoolean());
- blink::WebDOMFileSystem::EntryType entry_type = args[4]->BooleanValue()
- ? blink::WebDOMFileSystem::EntryTypeDirectory
- : blink::WebDOMFileSystem::EntryTypeFile;
-
- blink::WebLocalFrame* webframe =
- blink::WebLocalFrame::frameForContext(context()->v8_context());
- DCHECK(webframe);
- args.GetReturnValue().Set(
- blink::WebDOMFileSystem::create(
- webframe, type,
- blink::WebString::fromUTF8(file_system_name),
- file_system_root_url).createV8Entry(
- blink::WebString::fromUTF8(file_path_string),
- entry_type));
-}
-
-void FileSystemNatives::CrackIsolatedFileSystemName(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- DCHECK_EQ(args.Length(), 1);
- DCHECK(args[0]->IsString());
- std::string filesystem_name = *v8::String::Utf8Value(args[0]->ToString());
- std::string filesystem_id;
- if (!fileapi::CrackIsolatedFileSystemName(filesystem_name, &filesystem_id))
- return;
-
- args.GetReturnValue().Set(v8::String::NewFromUtf8(args.GetIsolate(),
- filesystem_id.c_str(),
- v8::String::kNormalString,
- filesystem_id.size()));
-}
-
-void FileSystemNatives::GetDOMError(
- const v8::FunctionCallbackInfo<v8::Value>& args) {
- if (args.Length() != 2) {
- NOTREACHED();
- return;
- }
- if (!args[0]->IsString()) {
- NOTREACHED();
- return;
- }
- if (!args[1]->IsString()) {
- NOTREACHED();
- return;
- }
-
- std::string name(*v8::String::Utf8Value(args[0]));
- if (name.empty()) {
- NOTREACHED();
- return;
- }
- std::string message(*v8::String::Utf8Value(args[1]));
- // message is optional hence empty is fine.
-
- blink::WebDOMError dom_error = blink::WebDOMError::create(
- blink::WebString::fromUTF8(name),
- blink::WebString::fromUTF8(message));
- args.GetReturnValue().Set(dom_error.toV8Value());
-}
-
-} // namespace extensions
« no previous file with comments | « chrome/renderer/extensions/file_system_natives.h ('k') | chrome/renderer/extensions/i18n_custom_bindings.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698