| 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 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 4 #include "chrome/browser/chromeos/extensions/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/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 #include "content/public/browser/user_metrics.h" | 47 #include "content/public/browser/user_metrics.h" |
| 48 #include "content/public/browser/web_contents.h" | 48 #include "content/public/browser/web_contents.h" |
| 49 #include "content/public/common/pepper_plugin_info.h" | 49 #include "content/public/common/pepper_plugin_info.h" |
| 50 #include "grit/generated_resources.h" | 50 #include "grit/generated_resources.h" |
| 51 #include "net/base/escape.h" | 51 #include "net/base/escape.h" |
| 52 #include "net/base/net_util.h" | 52 #include "net/base/net_util.h" |
| 53 #include "ui/base/l10n/l10n_util.h" | 53 #include "ui/base/l10n/l10n_util.h" |
| 54 #include "ui/gfx/screen.h" | 54 #include "ui/gfx/screen.h" |
| 55 #include "webkit/fileapi/file_system_context.h" | 55 #include "webkit/fileapi/file_system_context.h" |
| 56 #include "webkit/fileapi/file_system_mount_point_provider.h" | 56 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 57 #include "webkit/fileapi/file_system_url.h" |
| 57 #include "webkit/fileapi/file_system_util.h" | 58 #include "webkit/fileapi/file_system_util.h" |
| 58 #include "webkit/plugins/webplugininfo.h" | 59 #include "webkit/plugins/webplugininfo.h" |
| 59 | 60 |
| 60 using base::DictionaryValue; | 61 using base::DictionaryValue; |
| 61 using base::ListValue; | 62 using base::ListValue; |
| 62 using content::BrowserContext; | 63 using content::BrowserContext; |
| 63 using content::BrowserThread; | 64 using content::BrowserThread; |
| 64 using content::PluginService; | 65 using content::PluginService; |
| 65 using content::UserMetricsAction; | 66 using content::UserMetricsAction; |
| 66 using extensions::Extension; | 67 using extensions::Extension; |
| 67 using file_handler_util::FileTaskExecutor; | 68 using file_handler_util::FileTaskExecutor; |
| 69 using fileapi::FileSystemURL; |
| 68 | 70 |
| 69 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" | 71 #define FILEBROWSER_EXTENSON_ID "hhaomjibdihmijegdhdafkllkbggdgoj" |
| 70 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; | 72 const char kFileBrowserDomain[] = FILEBROWSER_EXTENSON_ID; |
| 71 | 73 |
| 72 const char kFileBrowserGalleryTaskId[] = "gallery"; | 74 const char kFileBrowserGalleryTaskId[] = "gallery"; |
| 73 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; | 75 const char kFileBrowserMountArchiveTaskId[] = "mount-archive"; |
| 74 const char kFileBrowserWatchTaskId[] = "watch"; | 76 const char kFileBrowserWatchTaskId[] = "watch"; |
| 75 const char kFileBrowserPlayTaskId[] = "play"; | 77 const char kFileBrowserPlayTaskId[] = "play"; |
| 76 | 78 |
| 77 const char kVideoPlayerAppName[] = "videoplayer"; | 79 const char kVideoPlayerAppName[] = "videoplayer"; |
| (...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 const GURL& url) { | 476 const GURL& url) { |
| 475 // We are executing the task on behalf of File Browser extension. | 477 // We are executing the task on behalf of File Browser extension. |
| 476 const GURL source_url(kBaseFileBrowserUrl); | 478 const GURL source_url(kBaseFileBrowserUrl); |
| 477 | 479 |
| 478 // If File Browser has not been open yet then it did not request access | 480 // If File Browser has not been open yet then it did not request access |
| 479 // to the file system. Do it now. | 481 // to the file system. Do it now. |
| 480 // File browser always runs in the site for its extension id, so that is the | 482 // File browser always runs in the site for its extension id, so that is the |
| 481 // site for which file access permissions should be granted. | 483 // site for which file access permissions should be granted. |
| 482 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()-> | 484 GURL site = extensions::ExtensionSystem::Get(profile)->extension_service()-> |
| 483 GetSiteForExtensionId(kFileBrowserDomain); | 485 GetSiteForExtensionId(kFileBrowserDomain); |
| 484 fileapi::ExternalFileSystemMountPointProvider* external_provider = | 486 fileapi::FileSystemContext* file_system_context = |
| 485 BrowserContext::GetStoragePartitionForSite(profile, site)-> | 487 BrowserContext::GetStoragePartitionForSite(profile, site)-> |
| 486 GetFileSystemContext()->external_provider(); | 488 GetFileSystemContext(); |
| 487 if (!external_provider) | 489 |
| 490 if (!file_system_context->external_provider()) |
| 488 return; | 491 return; |
| 489 external_provider->GrantFullAccessToExtension(source_url.host()); | 492 file_system_context->external_provider()->GrantFullAccessToExtension( |
| 493 source_url.host()); |
| 490 | 494 |
| 491 std::vector<GURL> urls; | 495 std::vector<FileSystemURL> urls; |
| 492 urls.push_back(url); | 496 urls.push_back(file_system_context->CrackURL(url)); |
| 493 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create(profile, | 497 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create(profile, |
| 494 source_url, kFileBrowserDomain, 0 /* no tab id */, extension_id, | 498 source_url, kFileBrowserDomain, 0 /* no tab id */, extension_id, |
| 495 file_handler_util::kTaskFile, action_id); | 499 file_handler_util::kTaskFile, action_id); |
| 496 executor->Execute(urls); | 500 executor->Execute(urls); |
| 497 } | 501 } |
| 498 | 502 |
| 499 void OpenFileBrowser(const FilePath& path, | 503 void OpenFileBrowser(const FilePath& path, |
| 500 TAB_REUSE_MODE mode, | 504 TAB_REUSE_MODE mode, |
| 501 const std::string& action_id) { | 505 const std::string& action_id) { |
| 502 content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); | 506 content::RecordAction(UserMetricsAction("ShowFileBrowserFullTab")); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 869 for (google_apis::OperationProgressStatusList::const_iterator iter = | 873 for (google_apis::OperationProgressStatusList::const_iterator iter = |
| 870 list.begin(); | 874 list.begin(); |
| 871 iter != list.end(); ++iter) { | 875 iter != list.end(); ++iter) { |
| 872 result_list->Append( | 876 result_list->Append( |
| 873 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); | 877 ProgessStatusToDictionaryValue(profile, extension_id, *iter)); |
| 874 } | 878 } |
| 875 return result_list.release(); | 879 return result_list.release(); |
| 876 } | 880 } |
| 877 | 881 |
| 878 } // namespace file_manager_util | 882 } // namespace file_manager_util |
| OLD | NEW |