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

Side by Side Diff: chrome/browser/chromeos/extensions/file_manager/file_manager_util.cc

Issue 18344013: fileapi: Rename FileSystemMountProvider to FileSystemBackend (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 5 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 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h" 4 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_util.h"
5 5
6 #include "ash/shell.h" 6 #include "ash/shell.h"
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/public/browser/storage_partition.h" 48 #include "content/public/browser/storage_partition.h"
49 #include "content/public/browser/user_metrics.h" 49 #include "content/public/browser/user_metrics.h"
50 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
51 #include "content/public/common/pepper_plugin_info.h" 51 #include "content/public/common/pepper_plugin_info.h"
52 #include "grit/generated_resources.h" 52 #include "grit/generated_resources.h"
53 #include "net/base/escape.h" 53 #include "net/base/escape.h"
54 #include "net/base/mime_util.h" 54 #include "net/base/mime_util.h"
55 #include "net/base/net_util.h" 55 #include "net/base/net_util.h"
56 #include "ui/base/l10n/l10n_util.h" 56 #include "ui/base/l10n/l10n_util.h"
57 #include "ui/gfx/screen.h" 57 #include "ui/gfx/screen.h"
58 #include "webkit/browser/fileapi/file_system_backend.h"
58 #include "webkit/browser/fileapi/file_system_context.h" 59 #include "webkit/browser/fileapi/file_system_context.h"
59 #include "webkit/browser/fileapi/file_system_mount_point_provider.h"
60 #include "webkit/browser/fileapi/file_system_operation_runner.h" 60 #include "webkit/browser/fileapi/file_system_operation_runner.h"
61 #include "webkit/browser/fileapi/file_system_url.h" 61 #include "webkit/browser/fileapi/file_system_url.h"
62 #include "webkit/common/fileapi/file_system_util.h" 62 #include "webkit/common/fileapi/file_system_util.h"
63 #include "webkit/plugins/webplugininfo.h" 63 #include "webkit/plugins/webplugininfo.h"
64 64
65 using base::DictionaryValue; 65 using base::DictionaryValue;
66 using base::ListValue; 66 using base::ListValue;
67 using content::BrowserContext; 67 using content::BrowserContext;
68 using content::BrowserThread; 68 using content::BrowserThread;
69 using content::PluginService; 69 using content::PluginService;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 return; 249 return;
250 InstallCRX(browser, file); 250 InstallCRX(browser, file);
251 } 251 }
252 252
253 // Grants file system access to the file browser. 253 // Grants file system access to the file browser.
254 bool GrantFileSystemAccessToFileBrowser(Profile* profile) { 254 bool GrantFileSystemAccessToFileBrowser(Profile* profile) {
255 // File browser always runs in the site for its extension id, so that is the 255 // File browser always runs in the site for its extension id, so that is the
256 // site for which file access permissions should be granted. 256 // site for which file access permissions should be granted.
257 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()-> 257 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()->
258 GetSiteForExtensionId(kFileBrowserDomain); 258 GetSiteForExtensionId(kFileBrowserDomain);
259 fileapi::ExternalFileSystemMountPointProvider* external_provider = 259 fileapi::ExternalFileSystemBackend* backend =
260 BrowserContext::GetStoragePartitionForSite(profile, site)-> 260 BrowserContext::GetStoragePartitionForSite(profile, site)->
261 GetFileSystemContext()->external_provider(); 261 GetFileSystemContext()->external_backend();
262 if (!external_provider) 262 if (!backend)
263 return false; 263 return false;
264 external_provider->GrantFullAccessToExtension(GetFileBrowserUrl().host()); 264 backend->GrantFullAccessToExtension(GetFileBrowserUrl().host());
265 return true; 265 return true;
266 } 266 }
267 267
268 // Executes handler specifed with |extension_id| and |action_id| for |url|. 268 // Executes handler specifed with |extension_id| and |action_id| for |url|.
269 void ExecuteHandler(Profile* profile, 269 void ExecuteHandler(Profile* profile,
270 std::string extension_id, 270 std::string extension_id,
271 std::string action_id, 271 std::string action_id,
272 const GURL& url, 272 const GURL& url,
273 const std::string& task_type) { 273 const std::string& task_type) {
274 // If File Browser has not been open yet then it did not request access 274 // If File Browser has not been open yet then it did not request access
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 ExtensionService* service = 563 ExtensionService* service =
564 extensions::ExtensionSystem::Get(profile)->extension_service(); 564 extensions::ExtensionSystem::Get(profile)->extension_service();
565 // May be NULL during unit_tests. 565 // May be NULL during unit_tests.
566 if (!service) 566 if (!service)
567 return false; 567 return false;
568 568
569 // File browser APIs are meant to be used only from extension context, so the 569 // File browser APIs are meant to be used only from extension context, so the
570 // extension's site is the one in whose file system context the virtual path 570 // extension's site is the one in whose file system context the virtual path
571 // should be found. 571 // should be found.
572 GURL site = service->GetSiteForExtensionId(extension_id); 572 GURL site = service->GetSiteForExtensionId(extension_id);
573 fileapi::ExternalFileSystemMountPointProvider* provider = 573 fileapi::ExternalFileSystemBackend* backend =
574 BrowserContext::GetStoragePartitionForSite(profile, site)-> 574 BrowserContext::GetStoragePartitionForSite(profile, site)->
575 GetFileSystemContext()->external_provider(); 575 GetFileSystemContext()->external_backend();
576 if (!provider) 576 if (!backend)
577 return false; 577 return false;
578 578
579 // Find if this file path is managed by the external provider. 579 // Find if this file path is managed by the external backend.
580 if (!provider->GetVirtualPath(full_file_path, virtual_path)) 580 if (!backend->GetVirtualPath(full_file_path, virtual_path))
581 return false; 581 return false;
582 582
583 return true; 583 return true;
584 } 584 }
585 585
586 GURL GetFileBrowserUrlWithParams( 586 GURL GetFileBrowserUrlWithParams(
587 ui::SelectFileDialog::Type type, 587 ui::SelectFileDialog::Type type,
588 const string16& title, 588 const string16& title,
589 const base::FilePath& default_virtual_path, 589 const base::FilePath& default_virtual_path,
590 const ui::SelectFileDialog::FileTypeInfo* file_types, 590 const ui::SelectFileDialog::FileTypeInfo* file_types,
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 // If the file doesn't have an extension or its mime-type cannot be 855 // If the file doesn't have an extension or its mime-type cannot be
856 // determined, then indicate that it has the empty mime-type. This will 856 // determined, then indicate that it has the empty mime-type. This will
857 // only be matched if the Web Intents accepts "*" or "*/*". 857 // only be matched if the Web Intents accepts "*" or "*/*".
858 return ""; 858 return "";
859 } else { 859 } else {
860 return mime_type; 860 return mime_type;
861 } 861 }
862 } 862 }
863 863
864 } // namespace file_manager_util 864 } // namespace file_manager_util
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698