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/extensions/api/developer_private/developer_private_api. h" | 5 #include "chrome/browser/extensions/api/developer_private/developer_private_api. h" |
6 | 6 |
7 #include "apps/app_load_service.h" | 7 #include "apps/app_load_service.h" |
8 #include "apps/saved_files_service.h" | 8 #include "apps/saved_files_service.h" |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 | 89 |
90 namespace { | 90 namespace { |
91 | 91 |
92 const char kNoSuchExtensionError[] = "No such extension."; | 92 const char kNoSuchExtensionError[] = "No such extension."; |
93 const char kSupervisedUserError[] = | 93 const char kSupervisedUserError[] = |
94 "Supervised users cannot modify extension settings."; | 94 "Supervised users cannot modify extension settings."; |
95 const char kCannotModifyPolicyExtensionError[] = | 95 const char kCannotModifyPolicyExtensionError[] = |
96 "Cannot modify the extension by policy."; | 96 "Cannot modify the extension by policy."; |
97 const char kRequiresUserGestureError[] = | 97 const char kRequiresUserGestureError[] = |
98 "This action requires a user gesture."; | 98 "This action requires a user gesture."; |
99 const char kCouldNotShowSelectFileDialogError[] = | |
100 "Could not show a file chooser."; | |
101 const char kFileSelectionCanceled[] = | |
102 "File selection was canceled."; | |
99 | 103 |
100 const char kUnpackedAppsFolder[] = "apps_target"; | 104 const char kUnpackedAppsFolder[] = "apps_target"; |
101 | 105 |
102 ExtensionService* GetExtensionService(content::BrowserContext* context) { | 106 ExtensionService* GetExtensionService(content::BrowserContext* context) { |
103 return ExtensionSystem::Get(context)->extension_service(); | 107 return ExtensionSystem::Get(context)->extension_service(); |
104 } | 108 } |
105 | 109 |
106 ExtensionUpdater* GetExtensionUpdater(Profile* profile) { | 110 ExtensionUpdater* GetExtensionUpdater(Profile* profile) { |
107 return GetExtensionService(profile)->updater(); | 111 return GetExtensionService(profile)->updater(); |
108 } | 112 } |
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
741 return RespondNow(NoArguments()); | 745 return RespondNow(NoArguments()); |
742 } | 746 } |
743 | 747 |
744 DeveloperPrivateAllowIncognitoFunction:: | 748 DeveloperPrivateAllowIncognitoFunction:: |
745 ~DeveloperPrivateAllowIncognitoFunction() {} | 749 ~DeveloperPrivateAllowIncognitoFunction() {} |
746 | 750 |
747 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { | 751 ExtensionFunction::ResponseAction DeveloperPrivateReloadFunction::Run() { |
748 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); | 752 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); |
749 EXTENSION_FUNCTION_VALIDATE(params.get()); | 753 EXTENSION_FUNCTION_VALIDATE(params.get()); |
750 | 754 |
751 const Extension* extension = GetExtensionById(params->item_id); | 755 const Extension* extension = GetExtensionById(params->extension_id); |
752 if (!extension) | 756 if (!extension) |
753 return RespondNow(Error(kNoSuchExtensionError)); | 757 return RespondNow(Error(kNoSuchExtensionError)); |
754 | 758 |
755 bool fail_quietly = | 759 bool fail_quietly = params->options && params->options->fail_quietly; |
not at google - send to devlin
2015/02/27 17:58:10
Urk, fail_quietly should be optional.
dictionar
Devlin
2015/02/27 21:37:02
Well, two things:
- The fact it shows up here is a
| |
756 params->options.get() && | |
757 params->options->fail_quietly.get() && | |
758 *params->options->fail_quietly; | |
759 | 760 |
760 ExtensionService* service = GetExtensionService(browser_context()); | 761 ExtensionService* service = GetExtensionService(browser_context()); |
761 if (fail_quietly) | 762 if (fail_quietly) |
762 service->ReloadExtensionWithQuietFailure(params->extension_id); | 763 service->ReloadExtensionWithQuietFailure(params->extension_id); |
763 else | 764 else |
764 service->ReloadExtension(params->extension_id); | 765 service->ReloadExtension(params->extension_id); |
765 | 766 |
766 // TODO(devlin): We shouldn't return until the extension has finished trying | 767 // TODO(devlin): We shouldn't return until the extension has finished trying |
767 // to reload (and then we could also return the error). | 768 // to reload (and then we could also return the error). |
768 return RespondNow(NoArguments()); | 769 return RespondNow(NoArguments()); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
863 return false; | 864 return false; |
864 } | 865 } |
865 | 866 |
866 DevToolsWindow::OpenDevToolsWindow( | 867 DevToolsWindow::OpenDevToolsWindow( |
867 content::WebContents::FromRenderViewHost(host)); | 868 content::WebContents::FromRenderViewHost(host)); |
868 return true; | 869 return true; |
869 } | 870 } |
870 | 871 |
871 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {} | 872 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {} |
872 | 873 |
873 bool DeveloperPrivateLoadUnpackedFunction::RunAsync() { | 874 ExtensionFunction::ResponseAction DeveloperPrivateLoadUnpackedFunction::Run() { |
874 base::string16 select_title = | 875 if (!ShowPicker( |
875 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); | 876 ui::SelectFileDialog::SELECT_FOLDER, |
877 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY), | |
878 ui::SelectFileDialog::FileTypeInfo(), | |
879 0)) { | |
not at google - send to devlin
2015/02/27 17:58:10
Comment what 0 is.
Devlin
2015/02/27 21:37:02
Done.
| |
880 return RespondNow(Error(kCouldNotShowSelectFileDialogError)); | |
881 } | |
876 | 882 |
877 // Balanced in FileSelected / FileSelectionCanceled. | 883 AddRef(); // Balanced in FileSelected / FileSelectionCanceled. |
878 AddRef(); | 884 return RespondLater(); |
879 bool result = ShowPicker( | |
880 ui::SelectFileDialog::SELECT_FOLDER, | |
881 DeveloperPrivateAPI::Get(GetProfile())->GetLastUnpackedDirectory(), | |
882 select_title, | |
883 ui::SelectFileDialog::FileTypeInfo(), | |
884 0); | |
885 return result; | |
886 } | 885 } |
887 | 886 |
888 void DeveloperPrivateLoadUnpackedFunction::FileSelected( | 887 void DeveloperPrivateLoadUnpackedFunction::FileSelected( |
889 const base::FilePath& path) { | 888 const base::FilePath& path) { |
890 ExtensionService* service = GetExtensionService(GetProfile()); | 889 UnpackedInstaller::Create(GetExtensionService(browser_context()))->Load(path); |
891 UnpackedInstaller::Create(service)->Load(path); | 890 DeveloperPrivateAPI::Get(browser_context())->SetLastUnpackedDirectory(path); |
892 DeveloperPrivateAPI::Get(GetProfile())->SetLastUnpackedDirectory(path); | 891 // TODO(devlin): Shouldn't we wait until the extension is loaded? |
893 SendResponse(true); | 892 Respond(NoArguments()); |
894 Release(); | 893 Release(); // Balanced in Run(). |
895 } | 894 } |
896 | 895 |
897 void DeveloperPrivateLoadUnpackedFunction::FileSelectionCanceled() { | 896 void DeveloperPrivateLoadUnpackedFunction::FileSelectionCanceled() { |
898 SendResponse(false); | 897 // This isn't really an error, but we should keep it like this for |
899 Release(); | 898 // backward compatability. |
899 Respond(Error(kFileSelectionCanceled)); | |
900 Release(); // Balanced in Run(). | |
900 } | 901 } |
901 | 902 |
902 bool DeveloperPrivateChooseEntryFunction::ShowPicker( | 903 bool DeveloperPrivateChooseEntryFunction::ShowPicker( |
903 ui::SelectFileDialog::Type picker_type, | 904 ui::SelectFileDialog::Type picker_type, |
904 const base::FilePath& last_directory, | |
905 const base::string16& select_title, | 905 const base::string16& select_title, |
906 const ui::SelectFileDialog::FileTypeInfo& info, | 906 const ui::SelectFileDialog::FileTypeInfo& info, |
907 int file_type_index) { | 907 int file_type_index) { |
908 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile()); | 908 content::WebContents* web_contents = GetSenderWebContents(); |
not at google - send to devlin
2015/02/27 17:58:10
Thank you.
| |
909 DCHECK(registry); | 909 if (!web_contents) |
910 AppWindow* app_window = | |
911 registry->GetAppWindowForRenderViewHost(render_view_host()); | |
912 if (!app_window) { | |
913 return false; | 910 return false; |
914 } | |
915 | 911 |
916 // The entry picker will hold a reference to this function instance, | 912 // The entry picker will hold a reference to this function instance, |
917 // and subsequent sending of the function response) until the user has | 913 // and subsequent sending of the function response) until the user has |
918 // selected a file or cancelled the picker. At that point, the picker will | 914 // selected a file or cancelled the picker. At that point, the picker will |
919 // delete itself. | 915 // delete itself. |
920 new EntryPicker(this, | 916 new EntryPicker(this, |
921 app_window->web_contents(), | 917 web_contents, |
922 picker_type, | 918 picker_type, |
923 last_directory, | 919 DeveloperPrivateAPI::Get(browser_context())-> |
920 GetLastUnpackedDirectory(), | |
924 select_title, | 921 select_title, |
925 info, | 922 info, |
926 file_type_index); | 923 file_type_index); |
927 return true; | 924 return true; |
928 } | 925 } |
929 | 926 |
930 bool DeveloperPrivateChooseEntryFunction::RunAsync() { | |
931 return false; | |
932 } | |
933 | |
934 DeveloperPrivateChooseEntryFunction::~DeveloperPrivateChooseEntryFunction() {} | 927 DeveloperPrivateChooseEntryFunction::~DeveloperPrivateChooseEntryFunction() {} |
935 | 928 |
936 void DeveloperPrivatePackDirectoryFunction::OnPackSuccess( | 929 void DeveloperPrivatePackDirectoryFunction::OnPackSuccess( |
937 const base::FilePath& crx_file, | 930 const base::FilePath& crx_file, |
938 const base::FilePath& pem_file) { | 931 const base::FilePath& pem_file) { |
939 developer::PackDirectoryResponse response; | 932 developer::PackDirectoryResponse response; |
940 response.message = base::UTF16ToUTF8( | 933 response.message = base::UTF16ToUTF8( |
941 PackExtensionJob::StandardSuccessMessage(crx_file, pem_file)); | 934 PackExtensionJob::StandardSuccessMessage(crx_file, pem_file)); |
942 response.status = developer::PACK_STATUS_SUCCESS; | 935 response.status = developer::PACK_STATUS_SUCCESS; |
943 results_ = developer::PackDirectory::Results::Create(response); | 936 Respond(OneArgument(response.ToValue().release())); |
not at google - send to devlin
2015/02/27 17:58:11
Should be:
Respond(ArgumentList(
developer::P
Devlin
2015/02/27 21:37:02
Does it make a difference? developer::PackDirecto
| |
944 SendResponse(true); | 937 Release(); // Balanced in Run(). |
945 Release(); | |
946 } | 938 } |
947 | 939 |
948 void DeveloperPrivatePackDirectoryFunction::OnPackFailure( | 940 void DeveloperPrivatePackDirectoryFunction::OnPackFailure( |
949 const std::string& error, | 941 const std::string& error, |
950 ExtensionCreator::ErrorType error_type) { | 942 ExtensionCreator::ErrorType error_type) { |
951 developer::PackDirectoryResponse response; | 943 developer::PackDirectoryResponse response; |
952 response.message = error; | 944 response.message = error; |
953 if (error_type == ExtensionCreator::kCRXExists) { | 945 if (error_type == ExtensionCreator::kCRXExists) { |
954 response.item_path = item_path_str_; | 946 response.item_path = item_path_str_; |
955 response.pem_path = key_path_str_; | 947 response.pem_path = key_path_str_; |
956 response.override_flags = ExtensionCreator::kOverwriteCRX; | 948 response.override_flags = ExtensionCreator::kOverwriteCRX; |
957 response.status = developer::PACK_STATUS_WARNING; | 949 response.status = developer::PACK_STATUS_WARNING; |
958 } else { | 950 } else { |
959 response.status = developer::PACK_STATUS_ERROR; | 951 response.status = developer::PACK_STATUS_ERROR; |
960 } | 952 } |
961 results_ = developer::PackDirectory::Results::Create(response); | 953 Respond(OneArgument(response.ToValue().release())); |
962 SendResponse(true); | 954 Release(); // Balanced in Run(). |
963 Release(); | |
964 } | 955 } |
965 | 956 |
966 bool DeveloperPrivatePackDirectoryFunction::RunAsync() { | 957 ExtensionFunction::ResponseAction DeveloperPrivatePackDirectoryFunction::Run() { |
967 scoped_ptr<PackDirectory::Params> params( | 958 scoped_ptr<PackDirectory::Params> params( |
968 PackDirectory::Params::Create(*args_)); | 959 PackDirectory::Params::Create(*args_)); |
969 EXTENSION_FUNCTION_VALIDATE(params.get()); | 960 EXTENSION_FUNCTION_VALIDATE(params); |
970 | 961 |
971 int flags = params->flags ? *params->flags : 0; | 962 int flags = params->flags ? *params->flags : 0; |
972 item_path_str_ = params->path; | 963 item_path_str_ = params->path; |
973 if (params->private_key_path) | 964 if (params->private_key_path) |
974 key_path_str_ = *params->private_key_path; | 965 key_path_str_ = *params->private_key_path; |
975 | 966 |
976 base::FilePath root_directory = | 967 base::FilePath root_directory(item_path_str_); |
977 base::FilePath::FromUTF8Unsafe(item_path_str_); | 968 base::FilePath key_file(key_path_str_); |
978 | |
979 base::FilePath key_file = base::FilePath::FromUTF8Unsafe(key_path_str_); | |
980 | 969 |
981 developer::PackDirectoryResponse response; | 970 developer::PackDirectoryResponse response; |
982 if (root_directory.empty()) { | 971 if (root_directory.empty()) { |
983 if (item_path_str_.empty()) | 972 if (item_path_str_.empty()) |
984 response.message = l10n_util::GetStringUTF8( | 973 response.message = l10n_util::GetStringUTF8( |
985 IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_REQUIRED); | 974 IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_REQUIRED); |
986 else | 975 else |
987 response.message = l10n_util::GetStringUTF8( | 976 response.message = l10n_util::GetStringUTF8( |
988 IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_INVALID); | 977 IDS_EXTENSION_PACK_DIALOG_ERROR_ROOT_INVALID); |
989 | 978 |
990 response.status = developer::PACK_STATUS_ERROR; | 979 response.status = developer::PACK_STATUS_ERROR; |
991 results_ = developer::PackDirectory::Results::Create(response); | 980 return RespondNow(OneArgument(response.ToValue().release())); |
992 SendResponse(true); | |
993 return true; | |
994 } | 981 } |
995 | 982 |
996 if (!key_path_str_.empty() && key_file.empty()) { | 983 if (!key_path_str_.empty() && key_file.empty()) { |
997 response.message = l10n_util::GetStringUTF8( | 984 response.message = l10n_util::GetStringUTF8( |
998 IDS_EXTENSION_PACK_DIALOG_ERROR_KEY_INVALID); | 985 IDS_EXTENSION_PACK_DIALOG_ERROR_KEY_INVALID); |
999 response.status = developer::PACK_STATUS_ERROR; | 986 response.status = developer::PACK_STATUS_ERROR; |
1000 results_ = developer::PackDirectory::Results::Create(response); | 987 return RespondNow(OneArgument(response.ToValue().release())); |
1001 SendResponse(true); | |
1002 return true; | |
1003 } | 988 } |
1004 | 989 |
1005 // Balanced in OnPackSuccess / OnPackFailure. | 990 AddRef(); // Balanced in OnPackSuccess / OnPackFailure. |
1006 AddRef(); | |
1007 | 991 |
992 // TODO(devlin): Why is PackExtensionJob ref-counted? | |
1008 pack_job_ = new PackExtensionJob(this, root_directory, key_file, flags); | 993 pack_job_ = new PackExtensionJob(this, root_directory, key_file, flags); |
1009 pack_job_->Start(); | 994 pack_job_->Start(); |
1010 return true; | 995 return RespondLater(); |
1011 } | 996 } |
1012 | 997 |
1013 DeveloperPrivatePackDirectoryFunction::DeveloperPrivatePackDirectoryFunction() | 998 DeveloperPrivatePackDirectoryFunction::DeveloperPrivatePackDirectoryFunction() { |
1014 {} | 999 } |
1015 | 1000 |
1016 DeveloperPrivatePackDirectoryFunction::~DeveloperPrivatePackDirectoryFunction() | 1001 DeveloperPrivatePackDirectoryFunction:: |
1017 {} | 1002 ~DeveloperPrivatePackDirectoryFunction() {} |
1018 | 1003 |
1019 DeveloperPrivateLoadUnpackedFunction::~DeveloperPrivateLoadUnpackedFunction() {} | 1004 DeveloperPrivateLoadUnpackedFunction::~DeveloperPrivateLoadUnpackedFunction() {} |
1020 | 1005 |
1021 bool DeveloperPrivateLoadDirectoryFunction::RunAsync() { | 1006 bool DeveloperPrivateLoadDirectoryFunction::RunAsync() { |
1022 // TODO(grv) : add unittests. | 1007 // TODO(grv) : add unittests. |
1023 std::string directory_url_str; | 1008 std::string directory_url_str; |
1024 std::string filesystem_name; | 1009 std::string filesystem_name; |
1025 std::string filesystem_path; | 1010 std::string filesystem_path; |
1026 | 1011 |
1027 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); | 1012 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1242 this)); | 1227 this)); |
1243 } | 1228 } |
1244 } | 1229 } |
1245 | 1230 |
1246 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() | 1231 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() |
1247 : pending_copy_operations_count_(0), success_(true) {} | 1232 : pending_copy_operations_count_(0), success_(true) {} |
1248 | 1233 |
1249 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() | 1234 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() |
1250 {} | 1235 {} |
1251 | 1236 |
1252 bool DeveloperPrivateChoosePathFunction::RunAsync() { | 1237 ExtensionFunction::ResponseAction DeveloperPrivateChoosePathFunction::Run() { |
not at google - send to devlin
2015/02/27 17:58:10
Hm I get that load unpacked is safer to be impleme
Devlin
2015/02/27 21:37:02
I know; I thought of that too :( Maybe one day we
| |
1253 scoped_ptr<developer::ChoosePath::Params> params( | 1238 scoped_ptr<developer::ChoosePath::Params> params( |
1254 developer::ChoosePath::Params::Create(*args_)); | 1239 developer::ChoosePath::Params::Create(*args_)); |
1255 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 1240 EXTENSION_FUNCTION_VALIDATE(params); |
1256 | 1241 |
1257 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; | 1242 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; |
1258 ui::SelectFileDialog::FileTypeInfo info; | 1243 ui::SelectFileDialog::FileTypeInfo info; |
1259 if (params->select_type == developer::SELECT_TYPE_FILE) { | 1244 |
1245 if (params->select_type == developer::SELECT_TYPE_FILE) | |
1260 type = ui::SelectFileDialog::SELECT_OPEN_FILE; | 1246 type = ui::SelectFileDialog::SELECT_OPEN_FILE; |
1261 } | |
1262 base::string16 select_title; | 1247 base::string16 select_title; |
1263 | 1248 |
1264 int file_type_index = 0; | 1249 int file_type_index = 0; |
1265 if (params->file_type == developer::FILE_TYPE_LOAD) { | 1250 if (params->file_type == developer::FILE_TYPE_LOAD) { |
1266 select_title = l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); | 1251 select_title = l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); |
1267 } else if (params->file_type == developer::FILE_TYPE_PEM) { | 1252 } else if (params->file_type == developer::FILE_TYPE_PEM) { |
1268 select_title = l10n_util::GetStringUTF16( | 1253 select_title = l10n_util::GetStringUTF16( |
1269 IDS_EXTENSION_PACK_DIALOG_SELECT_KEY); | 1254 IDS_EXTENSION_PACK_DIALOG_SELECT_KEY); |
1270 info.extensions.push_back(std::vector<base::FilePath::StringType>()); | 1255 info.extensions.push_back(std::vector<base::FilePath::StringType>( |
1271 info.extensions.front().push_back(FILE_PATH_LITERAL("pem")); | 1256 1, FILE_PATH_LITERAL("pem"))); |
1272 info.extension_description_overrides.push_back( | 1257 info.extension_description_overrides.push_back( |
1273 l10n_util::GetStringUTF16( | 1258 l10n_util::GetStringUTF16( |
1274 IDS_EXTENSION_PACK_DIALOG_KEY_FILE_TYPE_DESCRIPTION)); | 1259 IDS_EXTENSION_PACK_DIALOG_KEY_FILE_TYPE_DESCRIPTION)); |
1275 info.include_all_files = true; | 1260 info.include_all_files = true; |
1276 file_type_index = 1; | 1261 file_type_index = 1; |
1277 } else { | 1262 } else { |
1278 NOTREACHED(); | 1263 NOTREACHED(); |
1279 } | 1264 } |
1280 | 1265 |
1281 // Balanced by FileSelected / FileSelectionCanceled. | 1266 if (!ShowPicker( |
1282 AddRef(); | 1267 type, |
not at google - send to devlin
2015/02/27 17:58:10
So this was a leak?
Devlin
2015/02/27 21:37:02
Yes. Scary, huh?
| |
1283 bool result = ShowPicker( | 1268 select_title, |
1284 type, | 1269 info, |
1285 DeveloperPrivateAPI::Get(GetProfile())->GetLastUnpackedDirectory(), | 1270 file_type_index)) { |
1286 select_title, | 1271 return RespondNow(Error(kCouldNotShowSelectFileDialogError)); |
1287 info, | 1272 } |
1288 file_type_index); | 1273 |
1289 return result; | 1274 AddRef(); // Balanced by FileSelected / FileSelectionCanceled. |
1275 return RespondLater(); | |
1290 } | 1276 } |
1291 | 1277 |
1292 void DeveloperPrivateChoosePathFunction::FileSelected( | 1278 void DeveloperPrivateChoosePathFunction::FileSelected( |
1293 const base::FilePath& path) { | 1279 const base::FilePath& path) { |
1294 SetResult(new base::StringValue(base::UTF16ToUTF8(path.LossyDisplayName()))); | 1280 Respond(OneArgument(new base::StringValue(path.LossyDisplayName()))); |
1295 SendResponse(true); | |
1296 Release(); | 1281 Release(); |
1297 } | 1282 } |
1298 | 1283 |
1299 void DeveloperPrivateChoosePathFunction::FileSelectionCanceled() { | 1284 void DeveloperPrivateChoosePathFunction::FileSelectionCanceled() { |
1300 SendResponse(false); | 1285 // This isn't really an error, but we should keep it like this for |
1286 // backward compatability. | |
1287 Respond(Error(kFileSelectionCanceled)); | |
1301 Release(); | 1288 Release(); |
1302 } | 1289 } |
1303 | 1290 |
1304 DeveloperPrivateChoosePathFunction::~DeveloperPrivateChoosePathFunction() {} | 1291 DeveloperPrivateChoosePathFunction::~DeveloperPrivateChoosePathFunction() {} |
1305 | 1292 |
1306 bool DeveloperPrivateIsProfileManagedFunction::RunSync() { | 1293 bool DeveloperPrivateIsProfileManagedFunction::RunSync() { |
1307 SetResult(new base::FundamentalValue(GetProfile()->IsSupervised())); | 1294 SetResult(new base::FundamentalValue(GetProfile()->IsSupervised())); |
1308 return true; | 1295 return true; |
1309 } | 1296 } |
1310 | 1297 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1356 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0u, &dict)); | 1343 EXTENSION_FUNCTION_VALIDATE(args_->GetDictionary(0u, &dict)); |
1357 | 1344 |
1358 error_ui_util::HandleOpenDevTools(dict); | 1345 error_ui_util::HandleOpenDevTools(dict); |
1359 | 1346 |
1360 return true; | 1347 return true; |
1361 } | 1348 } |
1362 | 1349 |
1363 } // namespace api | 1350 } // namespace api |
1364 | 1351 |
1365 } // namespace extensions | 1352 } // namespace extensions |
OLD | NEW |