| 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/media_galleries_custom_bindings.h" | 5 #include "chrome/renderer/extensions/media_galleries_custom_bindings.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "content/public/child/url_conversion.h" |
| 9 #include "extensions/renderer/script_context.h" | 10 #include "extensions/renderer/script_context.h" |
| 10 #include "storage/common/fileapi/file_system_util.h" | 11 #include "storage/common/fileapi/file_system_util.h" |
| 11 #include "third_party/WebKit/public/web/WebDOMFileSystem.h" | 12 #include "third_party/WebKit/public/web/WebDOMFileSystem.h" |
| 12 #include "third_party/WebKit/public/web/WebDocument.h" | 13 #include "third_party/WebKit/public/web/WebDocument.h" |
| 13 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 14 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 14 #include "v8/include/v8.h" | 15 #include "v8/include/v8.h" |
| 15 | 16 |
| 16 namespace extensions { | 17 namespace extensions { |
| 17 | 18 |
| 18 MediaGalleriesCustomBindings::MediaGalleriesCustomBindings( | 19 MediaGalleriesCustomBindings::MediaGalleriesCustomBindings( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 29 void MediaGalleriesCustomBindings::GetMediaFileSystemObject( | 30 void MediaGalleriesCustomBindings::GetMediaFileSystemObject( |
| 30 const v8::FunctionCallbackInfo<v8::Value>& args) { | 31 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 31 CHECK_EQ(1, args.Length()); | 32 CHECK_EQ(1, args.Length()); |
| 32 CHECK(args[0]->IsString()); | 33 CHECK(args[0]->IsString()); |
| 33 | 34 |
| 34 std::string fs_mount(*v8::String::Utf8Value(args[0])); | 35 std::string fs_mount(*v8::String::Utf8Value(args[0])); |
| 35 CHECK(!fs_mount.empty()); | 36 CHECK(!fs_mount.empty()); |
| 36 | 37 |
| 37 blink::WebLocalFrame* webframe = | 38 blink::WebLocalFrame* webframe = |
| 38 blink::WebLocalFrame::frameForCurrentContext(); | 39 blink::WebLocalFrame::frameForCurrentContext(); |
| 39 const GURL origin = GURL(webframe->document().securityOrigin().toString()); | 40 const GURL origin = content::WebStringToGURL( |
| 41 webframe->document().securityOrigin().toString()); |
| 40 std::string fs_name = | 42 std::string fs_name = |
| 41 storage::GetFileSystemName(origin, storage::kFileSystemTypeExternal); | 43 storage::GetFileSystemName(origin, storage::kFileSystemTypeExternal); |
| 42 fs_name.append("_"); | 44 fs_name.append("_"); |
| 43 fs_name.append(fs_mount); | 45 fs_name.append(fs_mount); |
| 44 const GURL root_url( | 46 const GURL root_url( |
| 45 storage::GetExternalFileSystemRootURIString(origin, fs_mount)); | 47 storage::GetExternalFileSystemRootURIString(origin, fs_mount)); |
| 46 args.GetReturnValue().Set( | 48 args.GetReturnValue().Set( |
| 47 blink::WebDOMFileSystem::create(webframe, | 49 blink::WebDOMFileSystem::create(webframe, |
| 48 blink::WebFileSystemTypeExternal, | 50 blink::WebFileSystemTypeExternal, |
| 49 blink::WebString::fromUTF8(fs_name), | 51 blink::WebString::fromUTF8(fs_name), |
| 50 root_url) | 52 root_url) |
| 51 .toV8Value(context()->v8_context()->Global(), args.GetIsolate())); | 53 .toV8Value(context()->v8_context()->Global(), args.GetIsolate())); |
| 52 } | 54 } |
| 53 | 55 |
| 54 } // namespace extensions | 56 } // namespace extensions |
| OLD | NEW |