OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/extensions/extension_file_browser_private_api.h" | 5 #include "chrome/browser/extensions/extension_file_browser_private_api.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "chrome/browser/prefs/scoped_user_pref_update.h" | 26 #include "chrome/browser/prefs/scoped_user_pref_update.h" |
27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
29 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 29 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
30 #include "chrome/browser/ui/webui/extension_icon_source.h" | 30 #include "chrome/browser/ui/webui/extension_icon_source.h" |
31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
32 #include "chrome/common/extensions/extension.h" | 32 #include "chrome/common/extensions/extension.h" |
33 #include "chrome/common/extensions/file_browser_handler.h" | 33 #include "chrome/common/extensions/file_browser_handler.h" |
34 #include "chrome/common/pref_names.h" | 34 #include "chrome/common/pref_names.h" |
35 #include "content/browser/child_process_security_policy.h" | 35 #include "content/browser/child_process_security_policy.h" |
36 #include "content/browser/renderer_host/render_process_host.h" | |
37 #include "content/browser/renderer_host/render_view_host.h" | 36 #include "content/browser/renderer_host/render_view_host.h" |
38 #include "content/browser/tab_contents/tab_contents.h" | 37 #include "content/browser/tab_contents/tab_contents.h" |
39 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 39 #include "content/public/browser/render_process_host.h" |
40 #include "googleurl/src/gurl.h" | 40 #include "googleurl/src/gurl.h" |
41 #include "grit/generated_resources.h" | 41 #include "grit/generated_resources.h" |
42 #include "grit/platform_locale_settings.h" | 42 #include "grit/platform_locale_settings.h" |
43 #include "ui/base/l10n/l10n_util.h" | 43 #include "ui/base/l10n/l10n_util.h" |
44 #include "webkit/fileapi/file_system_context.h" | 44 #include "webkit/fileapi/file_system_context.h" |
45 #include "webkit/fileapi/file_system_file_util.h" | 45 #include "webkit/fileapi/file_system_file_util.h" |
46 #include "webkit/fileapi/file_system_mount_point_provider.h" | 46 #include "webkit/fileapi/file_system_mount_point_provider.h" |
47 #include "webkit/fileapi/file_system_operation.h" | 47 #include "webkit/fileapi/file_system_operation.h" |
48 #include "webkit/fileapi/file_system_operation_context.h" | 48 #include "webkit/fileapi/file_system_operation_context.h" |
49 #include "webkit/fileapi/file_system_path_manager.h" | 49 #include "webkit/fileapi/file_system_path_manager.h" |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 bool RequestLocalFileSystemFunction::RunImpl() { | 436 bool RequestLocalFileSystemFunction::RunImpl() { |
437 if (!dispatcher() || !render_view_host() || !render_view_host()->process()) | 437 if (!dispatcher() || !render_view_host() || !render_view_host()->process()) |
438 return false; | 438 return false; |
439 | 439 |
440 BrowserThread::PostTask( | 440 BrowserThread::PostTask( |
441 BrowserThread::FILE, FROM_HERE, | 441 BrowserThread::FILE, FROM_HERE, |
442 base::Bind( | 442 base::Bind( |
443 &RequestLocalFileSystemFunction::RequestOnFileThread, | 443 &RequestLocalFileSystemFunction::RequestOnFileThread, |
444 this, | 444 this, |
445 source_url_, | 445 source_url_, |
446 render_view_host()->process()->id())); | 446 render_view_host()->process()->GetID())); |
447 // Will finish asynchronously. | 447 // Will finish asynchronously. |
448 return true; | 448 return true; |
449 } | 449 } |
450 | 450 |
451 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( | 451 void RequestLocalFileSystemFunction::RespondSuccessOnUIThread( |
452 const std::string& name, const GURL& root_path) { | 452 const std::string& name, const GURL& root_path) { |
453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 453 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
454 result_.reset(new DictionaryValue()); | 454 result_.reset(new DictionaryValue()); |
455 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); | 455 DictionaryValue* dict = reinterpret_cast<DictionaryValue*>(result_.get()); |
456 dict->SetString("name", name); | 456 dict->SetString("name", name); |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 if (!CrackTaskIdentifier(task_id_, &target_extension_id_, &action_id)) | 715 if (!CrackTaskIdentifier(task_id_, &target_extension_id_, &action_id)) |
716 return; | 716 return; |
717 | 717 |
718 GURL extension_url = | 718 GURL extension_url = |
719 Extension::GetBaseURLFromExtensionId(target_extension_id_); | 719 Extension::GetBaseURLFromExtensionId(target_extension_id_); |
720 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); | 720 ExtensionProcessManager* manager = profile_->GetExtensionProcessManager(); |
721 | 721 |
722 SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); | 722 SiteInstance* site_instance = manager->GetSiteInstanceForURL(extension_url); |
723 if (!site_instance || !site_instance->HasProcess()) | 723 if (!site_instance || !site_instance->HasProcess()) |
724 return; | 724 return; |
725 RenderProcessHost* process = site_instance->GetProcess(); | 725 content::RenderProcessHost* process = site_instance->GetProcess(); |
726 | 726 |
727 target_process_id_ = process->id(); | 727 target_process_id_ = process->GetID(); |
728 } | 728 } |
729 | 729 |
730 // Checks legitimacy of file url and grants file RO access permissions from | 730 // Checks legitimacy of file url and grants file RO access permissions from |
731 // handler (target) extension and its renderer process. | 731 // handler (target) extension and its renderer process. |
732 bool SetupFileAccessPermissions(const GURL& origin_file_url, | 732 bool SetupFileAccessPermissions(const GURL& origin_file_url, |
733 GURL* target_file_url, FilePath* file_path, bool* is_directory) { | 733 GURL* target_file_url, FilePath* file_path, bool* is_directory) { |
734 if (!extension_.get()) | 734 if (!extension_.get()) |
735 return false; | 735 return false; |
736 | 736 |
737 if (target_process_id_ == 0) | 737 if (target_process_id_ == 0) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 | 875 |
876 void ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread( | 876 void ExecuteTasksFileBrowserFunction::RequestFileEntryOnFileThread( |
877 const GURL& source_url, const std::string& task_id, | 877 const GURL& source_url, const std::string& task_id, |
878 const std::vector<GURL>& file_urls) { | 878 const std::vector<GURL>& file_urls) { |
879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 879 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
880 fileapi::FileSystemOperation* operation = | 880 fileapi::FileSystemOperation* operation = |
881 new fileapi::FileSystemOperation( | 881 new fileapi::FileSystemOperation( |
882 new ExecuteTasksFileSystemCallbackDispatcher( | 882 new ExecuteTasksFileSystemCallbackDispatcher( |
883 this, | 883 this, |
884 profile(), | 884 profile(), |
885 render_view_host()->process()->id(), | 885 render_view_host()->process()->GetID(), |
886 source_url, | 886 source_url, |
887 GetExtension(), | 887 GetExtension(), |
888 task_id, | 888 task_id, |
889 file_urls), | 889 file_urls), |
890 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), | 890 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE), |
891 profile()->GetFileSystemContext()); | 891 profile()->GetFileSystemContext()); |
892 GURL origin_url = source_url.GetOrigin(); | 892 GURL origin_url = source_url.GetOrigin(); |
893 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeExternal, | 893 operation->OpenFileSystem(origin_url, fileapi::kFileSystemTypeExternal, |
894 false); // create | 894 false); // create |
895 } | 895 } |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1675 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); | 1675 l10n_util::GetStringUTF16(IDS_CERT_MANAGER_VIEW_CERT_BUTTON)); |
1676 dict->SetString("PLAY_MEDIA", | 1676 dict->SetString("PLAY_MEDIA", |
1677 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); | 1677 l10n_util::GetStringUTF16(IDS_CONTENT_CONTEXT_PLAY)); |
1678 #if defined(OS_CHROMEOS) | 1678 #if defined(OS_CHROMEOS) |
1679 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePhotoEditor)) | 1679 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnablePhotoEditor)) |
1680 dict->SetString("ENABLE_PHOTO_EDITOR", "true"); | 1680 dict->SetString("ENABLE_PHOTO_EDITOR", "true"); |
1681 #endif | 1681 #endif |
1682 | 1682 |
1683 return true; | 1683 return true; |
1684 } | 1684 } |
OLD | NEW |