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

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

Issue 185393012: Change media galleries to external file system type to add toURL support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Mac/Win compile Created 6 years, 9 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 | 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/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 "chrome/common/extensions/extension_constants.h" 9 #include "chrome/common/extensions/extension_constants.h"
10 #include "third_party/WebKit/public/web/WebDOMFileSystem.h" 10 #include "third_party/WebKit/public/web/WebDOMFileSystem.h"
11 #include "third_party/WebKit/public/web/WebDocument.h" 11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebFrame.h" 12 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "v8/include/v8.h" 13 #include "v8/include/v8.h"
14 #include "webkit/common/fileapi/file_system_util.h" 14 #include "webkit/common/fileapi/file_system_util.h"
15 15
16 namespace extensions { 16 namespace extensions {
17 17
18 namespace { 18 namespace {
19 19
20 // FileSystemObject GetMediaFileSystem(string file_system_url): construct 20 // FileSystemObject GetMediaFileSystem(string file_system_url): construct
21 // a file system object from a file system url. 21 // a file system object from a file system url.
22 void GetMediaFileSystemObject(const v8::FunctionCallbackInfo<v8::Value>& args) { 22 void GetMediaFileSystemObject(const v8::FunctionCallbackInfo<v8::Value>& args) {
23 CHECK_EQ(1, args.Length()); 23 CHECK_EQ(1, args.Length());
24 CHECK(args[0]->IsString()); 24 CHECK(args[0]->IsString());
25 25
26 std::string fsid(*v8::String::Utf8Value(args[0])); 26 std::string fs_mount(*v8::String::Utf8Value(args[0]));
27 CHECK(!fsid.empty()); 27 if (fs_mount.empty()) {
28 NOTREACHED();
Lei Zhang 2014/03/20 00:46:26 Any reason to do this? In another CL, kalman was s
vandebo (ex-Chrome) 2014/03/20 18:08:53 Hmm, did this part of the change a long time ago a
29 return;
30 }
28 31
29 blink::WebFrame* webframe = blink::WebFrame::frameForCurrentContext(); 32 blink::WebFrame* webframe = blink::WebFrame::frameForCurrentContext();
30 const GURL origin = GURL(webframe->document().securityOrigin().toString()); 33 const GURL origin = GURL(webframe->document().securityOrigin().toString());
31 const std::string fs_name = fileapi::GetIsolatedFileSystemName(origin, fsid); 34 std::string fs_name =
35 fileapi::GetFileSystemName(origin, fileapi::kFileSystemTypeExternal);
36 fs_name.append("_");
37 fs_name.append(fs_mount);
32 const GURL root_url( 38 const GURL root_url(
33 fileapi::GetIsolatedFileSystemRootURIString( 39 fileapi::GetExternalFileSystemRootURIString(origin, fs_mount));
34 origin, fsid, extension_misc::kMediaFileSystemPathPart));
35 args.GetReturnValue().Set( 40 args.GetReturnValue().Set(
36 blink::WebDOMFileSystem::create( 41 blink::WebDOMFileSystem::create(webframe,
37 webframe, 42 blink::WebFileSystemTypeExternal,
38 blink::WebFileSystemTypeIsolated, 43 blink::WebString::fromUTF8(fs_name),
39 blink::WebString::fromUTF8(fs_name), 44 root_url).toV8Value());
40 root_url).toV8Value());
41 } 45 }
42 46
43 } // namespace 47 } // namespace
44 48
45 MediaGalleriesCustomBindings::MediaGalleriesCustomBindings( 49 MediaGalleriesCustomBindings::MediaGalleriesCustomBindings(
46 Dispatcher* dispatcher, ChromeV8Context* context) 50 Dispatcher* dispatcher, ChromeV8Context* context)
47 : ChromeV8Extension(dispatcher, context) { 51 : ChromeV8Extension(dispatcher, context) {
48 RouteFunction("GetMediaFileSystemObject", 52 RouteFunction("GetMediaFileSystemObject",
49 base::Bind(&GetMediaFileSystemObject)); 53 base::Bind(&GetMediaFileSystemObject));
50 } 54 }
51 55
52 } // namespace extensions 56 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698