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 "base/bind.h" | 6 #include "base/bind.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.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 23 matching lines...) Expand all Loading... |
34 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
35 #include "chrome/browser/ui/extensions/application_launch.h" | 35 #include "chrome/browser/ui/extensions/application_launch.h" |
36 #include "chrome/browser/ui/simple_message_box.h" | 36 #include "chrome/browser/ui/simple_message_box.h" |
37 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 37 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
38 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 38 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
39 #include "chrome/common/chrome_paths.h" | 39 #include "chrome/common/chrome_paths.h" |
40 #include "chrome/common/extensions/file_browser_handler.h" | 40 #include "chrome/common/extensions/file_browser_handler.h" |
41 #include "chrome/common/url_constants.h" | 41 #include "chrome/common/url_constants.h" |
42 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
43 #include "content/public/browser/plugin_service.h" | 43 #include "content/public/browser/plugin_service.h" |
| 44 #include "content/public/browser/storage_partition.h" |
44 #include "content/public/browser/user_metrics.h" | 45 #include "content/public/browser/user_metrics.h" |
45 #include "content/public/browser/web_contents.h" | 46 #include "content/public/browser/web_contents.h" |
46 #include "grit/generated_resources.h" | 47 #include "grit/generated_resources.h" |
47 #include "net/base/escape.h" | 48 #include "net/base/escape.h" |
48 #include "net/base/net_util.h" | 49 #include "net/base/net_util.h" |
49 #include "ui/base/l10n/l10n_util.h" | 50 #include "ui/base/l10n/l10n_util.h" |
50 #include "ui/gfx/screen.h" | 51 #include "ui/gfx/screen.h" |
51 #include "webkit/fileapi/file_system_context.h" | 52 #include "webkit/fileapi/file_system_context.h" |
52 #include "webkit/fileapi/file_system_mount_point_provider.h" | 53 #include "webkit/fileapi/file_system_mount_point_provider.h" |
53 #include "webkit/fileapi/file_system_util.h" | 54 #include "webkit/fileapi/file_system_util.h" |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
297 | 298 |
298 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, | 299 GURL base_url = fileapi::GetFileSystemRootURI(origin_url, |
299 fileapi::kFileSystemTypeExternal); | 300 fileapi::kFileSystemTypeExternal); |
300 *url = GURL(base_url.spec() + virtual_path.value()); | 301 *url = GURL(base_url.spec() + virtual_path.value()); |
301 return true; | 302 return true; |
302 } | 303 } |
303 | 304 |
304 bool ConvertFileToRelativeFileSystemPath( | 305 bool ConvertFileToRelativeFileSystemPath( |
305 Profile* profile, const FilePath& full_file_path, FilePath* virtual_path) { | 306 Profile* profile, const FilePath& full_file_path, FilePath* virtual_path) { |
306 fileapi::ExternalFileSystemMountPointProvider* provider = | 307 fileapi::ExternalFileSystemMountPointProvider* provider = |
307 BrowserContext::GetFileSystemContext(profile)->external_provider(); | 308 BrowserContext::GetDefaultStoragePartition(profile)-> |
| 309 GetFileSystemContext()->external_provider(); |
308 if (!provider) | 310 if (!provider) |
309 return false; | 311 return false; |
310 | 312 |
311 // Find if this file path is managed by the external provider. | 313 // Find if this file path is managed by the external provider. |
312 if (!provider->GetVirtualPath(full_file_path, virtual_path)) | 314 if (!provider->GetVirtualPath(full_file_path, virtual_path)) |
313 return false; | 315 return false; |
314 | 316 |
315 return true; | 317 return true; |
316 } | 318 } |
317 | 319 |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } else { | 582 } else { |
581 return ExecuteBuiltinHandler(browser, path, action_id); | 583 return ExecuteBuiltinHandler(browser, path, action_id); |
582 } | 584 } |
583 } else { | 585 } else { |
584 // We are executing the task on behalf of File Browser extension. | 586 // We are executing the task on behalf of File Browser extension. |
585 const GURL source_url(kBaseFileBrowserUrl); | 587 const GURL source_url(kBaseFileBrowserUrl); |
586 | 588 |
587 // If File Browser has not been open yet then it did not request access | 589 // If File Browser has not been open yet then it did not request access |
588 // to the file system. Do it now. | 590 // to the file system. Do it now. |
589 fileapi::ExternalFileSystemMountPointProvider* external_provider = | 591 fileapi::ExternalFileSystemMountPointProvider* external_provider = |
590 BrowserContext::GetFileSystemContext(profile)->external_provider(); | 592 BrowserContext::GetDefaultStoragePartition( |
| 593 profile)->GetFileSystemContext()->external_provider(); |
591 if (!external_provider) | 594 if (!external_provider) |
592 return false; | 595 return false; |
593 external_provider->GrantFullAccessToExtension(source_url.host()); | 596 external_provider->GrantFullAccessToExtension(source_url.host()); |
594 | 597 |
595 std::vector<GURL> urls; | 598 std::vector<GURL> urls; |
596 urls.push_back(url); | 599 urls.push_back(url); |
597 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create( | 600 scoped_refptr<FileTaskExecutor> executor = FileTaskExecutor::Create( |
598 profile, source_url, extension_id, action_id); | 601 profile, source_url, extension_id, action_id); |
599 executor->Execute(urls); | 602 executor->Execute(urls); |
600 return true; | 603 return true; |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 OperationRegistry::ProgressStatus>::const_iterator iter = | 805 OperationRegistry::ProgressStatus>::const_iterator iter = |
803 list.begin(); | 806 list.begin(); |
804 iter != list.end(); ++iter) { | 807 iter != list.end(); ++iter) { |
805 result_list->Append( | 808 result_list->Append( |
806 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); | 809 ProgessStatusToDictionaryValue(profile, origin_url, *iter)); |
807 } | 810 } |
808 return result_list.release(); | 811 return result_list.release(); |
809 } | 812 } |
810 | 813 |
811 } // namespace file_manager_util | 814 } // namespace file_manager_util |
OLD | NEW |