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 | 4 |
5 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 5 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
810 return; | 810 return; |
811 } | 811 } |
812 | 812 |
813 SetupHandlerHostFileAccessPermissions(handler_pid); | 813 SetupHandlerHostFileAccessPermissions(handler_pid); |
814 | 814 |
815 scoped_ptr<ListValue> event_args(new ListValue()); | 815 scoped_ptr<ListValue> event_args(new ListValue()); |
816 event_args->Append(Value::CreateStringValue(action_id_)); | 816 event_args->Append(Value::CreateStringValue(action_id_)); |
817 DictionaryValue* details = new DictionaryValue(); | 817 DictionaryValue* details = new DictionaryValue(); |
818 event_args->Append(details); | 818 event_args->Append(details); |
819 // Get file definitions. These will be replaced with Entry instances by | 819 // Get file definitions. These will be replaced with Entry instances by |
820 // chromeHidden.Event.dispatchJSON() method from even_binding.js. | 820 // chromeHidden.Event.dispatchEvent() method from event_binding.js. |
821 ListValue* files_urls = new ListValue(); | 821 ListValue* files_urls = new ListValue(); |
822 details->Set("entries", files_urls); | 822 details->Set("entries", files_urls); |
823 for (FileDefinitionList::const_iterator iter = file_list.begin(); | 823 for (FileDefinitionList::const_iterator iter = file_list.begin(); |
824 iter != file_list.end(); | 824 iter != file_list.end(); |
825 ++iter) { | 825 ++iter) { |
826 DictionaryValue* file_def = new DictionaryValue(); | 826 DictionaryValue* file_def = new DictionaryValue(); |
827 files_urls->Append(file_def); | 827 files_urls->Append(file_def); |
828 file_def->SetString("fileSystemName", file_system_name); | 828 file_def->SetString("fileSystemName", file_system_name); |
829 file_def->SetString("fileSystemRoot", file_system_root.spec()); | 829 file_def->SetString("fileSystemRoot", file_system_root.spec()); |
830 FilePath root(FILE_PATH_LITERAL("/")); | 830 FilePath root(FILE_PATH_LITERAL("/")); |
831 FilePath full_path = root.Append(iter->virtual_path); | 831 FilePath full_path = root.Append(iter->virtual_path); |
832 file_def->SetString("fileFullPath", full_path.value()); | 832 file_def->SetString("fileFullPath", full_path.value()); |
833 file_def->SetBoolean("fileIsDirectory", iter->is_directory); | 833 file_def->SetBoolean("fileIsDirectory", iter->is_directory); |
834 } | 834 } |
835 | 835 |
836 // Get tab id. | 836 // Get tab id. |
837 Browser* current_browser = GetBrowser(); | 837 Browser* current_browser = GetBrowser(); |
838 if (current_browser) { | 838 if (current_browser) { |
839 WebContents* contents = chrome::GetActiveWebContents(current_browser); | 839 WebContents* contents = chrome::GetActiveWebContents(current_browser); |
840 if (contents) | 840 if (contents) |
841 details->SetInteger("tab_id", ExtensionTabUtil::GetTabId(contents)); | 841 details->SetInteger("tab_id", ExtensionTabUtil::GetTabId(contents)); |
842 } | 842 } |
843 | 843 |
844 std::string json_args; | |
845 base::JSONWriter::Write(event_args.get(), &json_args); | |
846 event_router->DispatchEventToExtension( | 844 event_router->DispatchEventToExtension( |
847 extension_id_, std::string("fileBrowserHandler.onExecute"), | 845 extension_id_, std::string("fileBrowserHandler.onExecute"), |
848 json_args, profile(), GURL()); | 846 event_args.Pass(), profile(), GURL()); |
849 ExecuteDoneOnUIThread(true); | 847 ExecuteDoneOnUIThread(true); |
850 } | 848 } |
851 | 849 |
852 void ExtensionTaskExecutor::InitHandlerHostFileAccessPermissions( | 850 void ExtensionTaskExecutor::InitHandlerHostFileAccessPermissions( |
853 const FileDefinitionList& file_list, | 851 const FileDefinitionList& file_list, |
854 const Extension* handler_extension, | 852 const Extension* handler_extension, |
855 const std::string& action_id, | 853 const std::string& action_id, |
856 const base::Closure& callback) { | 854 const base::Closure& callback) { |
857 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 855 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
858 | 856 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 handler_pid, | 888 handler_pid, |
891 handler_host_permissions_[i].first, | 889 handler_host_permissions_[i].first, |
892 handler_host_permissions_[i].second); | 890 handler_host_permissions_[i].second); |
893 } | 891 } |
894 | 892 |
895 // We don't need this anymore. | 893 // We don't need this anymore. |
896 handler_host_permissions_.clear(); | 894 handler_host_permissions_.clear(); |
897 } | 895 } |
898 | 896 |
899 } // namespace file_handler_util | 897 } // namespace file_handler_util |
900 | |
OLD | NEW |