Home | History | Annotate | Download | only in file_manager
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/chromeos/extensions/file_manager/fileapi_util.h"
      6 
      7 #include "chrome/browser/extensions/extension_service.h"
      8 #include "chrome/browser/extensions/extension_system.h"
      9 #include "chrome/browser/profiles/profile.h"
     10 #include "content/public/browser/browser_thread.h"
     11 #include "content/public/browser/render_view_host.h"
     12 #include "content/public/browser/site_instance.h"
     13 #include "content/public/browser/storage_partition.h"
     14 #include "url/gurl.h"
     15 #include "webkit/browser/fileapi/file_system_context.h"
     16 
     17 namespace file_manager {
     18 namespace fileapi_util {
     19 
     20 fileapi::FileSystemContext* GetFileSystemContextForExtensionId(
     21     Profile* profile,
     22     const std::string& extension_id) {
     23   GURL site = extensions::ExtensionSystem::Get(profile)->
     24       extension_service()->GetSiteForExtensionId(extension_id);
     25   return content::BrowserContext::GetStoragePartitionForSite(profile, site)->
     26       GetFileSystemContext();
     27 }
     28 
     29 fileapi::FileSystemContext* GetFileSystemContextForRenderViewHost(
     30     Profile* profile,
     31     content::RenderViewHost* render_view_host) {
     32   content::SiteInstance* site_instance = render_view_host->GetSiteInstance();
     33   return content::BrowserContext::GetStoragePartition(profile, site_instance)->
     34       GetFileSystemContext();
     35 }
     36 
     37 }  // namespace fileapi_util
     38 }  // namespace file_manager
     39