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/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
9 #include "apps/app_window.h" | 9 #include "apps/app_window.h" |
10 #include "apps/app_window_registry.h" | 10 #include "apps/app_window_registry.h" |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 -1, | 588 -1, |
589 -1, | 589 -1, |
590 false, | 590 false, |
591 BackgroundInfo::HasGeneratedBackgroundPage(extension))); | 591 BackgroundInfo::HasGeneratedBackgroundPage(extension))); |
592 } | 592 } |
593 } | 593 } |
594 | 594 |
595 return result; | 595 return result; |
596 } | 596 } |
597 | 597 |
598 bool DeveloperPrivateGetItemsInfoFunction::RunImpl() { | 598 bool DeveloperPrivateGetItemsInfoFunction::RunAsync() { |
599 scoped_ptr<developer::GetItemsInfo::Params> params( | 599 scoped_ptr<developer::GetItemsInfo::Params> params( |
600 developer::GetItemsInfo::Params::Create(*args_)); | 600 developer::GetItemsInfo::Params::Create(*args_)); |
601 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 601 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
602 | 602 |
603 bool include_disabled = params->include_disabled; | 603 bool include_disabled = params->include_disabled; |
604 bool include_terminated = params->include_terminated; | 604 bool include_terminated = params->include_terminated; |
605 | 605 |
606 extensions::ExtensionSet items; | 606 extensions::ExtensionSet items; |
607 | 607 |
608 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); | 608 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
882 // This can happen if the host has gone away since the page was displayed. | 882 // This can happen if the host has gone away since the page was displayed. |
883 return false; | 883 return false; |
884 } | 884 } |
885 | 885 |
886 DevToolsWindow::OpenDevToolsWindow(host); | 886 DevToolsWindow::OpenDevToolsWindow(host); |
887 return true; | 887 return true; |
888 } | 888 } |
889 | 889 |
890 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {} | 890 DeveloperPrivateInspectFunction::~DeveloperPrivateInspectFunction() {} |
891 | 891 |
892 bool DeveloperPrivateLoadUnpackedFunction::RunImpl() { | 892 bool DeveloperPrivateLoadUnpackedFunction::RunAsync() { |
893 base::string16 select_title = | 893 base::string16 select_title = |
894 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); | 894 l10n_util::GetStringUTF16(IDS_EXTENSION_LOAD_FROM_DIRECTORY); |
895 | 895 |
896 // Balanced in FileSelected / FileSelectionCanceled. | 896 // Balanced in FileSelected / FileSelectionCanceled. |
897 AddRef(); | 897 AddRef(); |
898 bool result = ShowPicker( | 898 bool result = ShowPicker( |
899 ui::SelectFileDialog::SELECT_FOLDER, | 899 ui::SelectFileDialog::SELECT_FOLDER, |
900 DeveloperPrivateAPI::Get(GetProfile())->GetLastUnpackedDirectory(), | 900 DeveloperPrivateAPI::Get(GetProfile())->GetLastUnpackedDirectory(), |
901 select_title, | 901 select_title, |
902 ui::SelectFileDialog::FileTypeInfo(), | 902 ui::SelectFileDialog::FileTypeInfo(), |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
939 new EntryPicker(this, | 939 new EntryPicker(this, |
940 app_window->web_contents(), | 940 app_window->web_contents(), |
941 picker_type, | 941 picker_type, |
942 last_directory, | 942 last_directory, |
943 select_title, | 943 select_title, |
944 info, | 944 info, |
945 file_type_index); | 945 file_type_index); |
946 return true; | 946 return true; |
947 } | 947 } |
948 | 948 |
949 bool DeveloperPrivateChooseEntryFunction::RunImpl() { return false; } | 949 bool DeveloperPrivateChooseEntryFunction::RunAsync() { |
| 950 return false; |
| 951 } |
950 | 952 |
951 DeveloperPrivateChooseEntryFunction::~DeveloperPrivateChooseEntryFunction() {} | 953 DeveloperPrivateChooseEntryFunction::~DeveloperPrivateChooseEntryFunction() {} |
952 | 954 |
953 void DeveloperPrivatePackDirectoryFunction::OnPackSuccess( | 955 void DeveloperPrivatePackDirectoryFunction::OnPackSuccess( |
954 const base::FilePath& crx_file, | 956 const base::FilePath& crx_file, |
955 const base::FilePath& pem_file) { | 957 const base::FilePath& pem_file) { |
956 developer::PackDirectoryResponse response; | 958 developer::PackDirectoryResponse response; |
957 response.message = base::UTF16ToUTF8( | 959 response.message = base::UTF16ToUTF8( |
958 PackExtensionJob::StandardSuccessMessage(crx_file, pem_file)); | 960 PackExtensionJob::StandardSuccessMessage(crx_file, pem_file)); |
959 response.status = developer::PACK_STATUS_SUCCESS; | 961 response.status = developer::PACK_STATUS_SUCCESS; |
(...skipping 13 matching lines...) Expand all Loading... |
973 response.override_flags = ExtensionCreator::kOverwriteCRX; | 975 response.override_flags = ExtensionCreator::kOverwriteCRX; |
974 response.status = developer::PACK_STATUS_WARNING; | 976 response.status = developer::PACK_STATUS_WARNING; |
975 } else { | 977 } else { |
976 response.status = developer::PACK_STATUS_ERROR; | 978 response.status = developer::PACK_STATUS_ERROR; |
977 } | 979 } |
978 results_ = developer::PackDirectory::Results::Create(response); | 980 results_ = developer::PackDirectory::Results::Create(response); |
979 SendResponse(true); | 981 SendResponse(true); |
980 Release(); | 982 Release(); |
981 } | 983 } |
982 | 984 |
983 bool DeveloperPrivatePackDirectoryFunction::RunImpl() { | 985 bool DeveloperPrivatePackDirectoryFunction::RunAsync() { |
984 scoped_ptr<PackDirectory::Params> params( | 986 scoped_ptr<PackDirectory::Params> params( |
985 PackDirectory::Params::Create(*args_)); | 987 PackDirectory::Params::Create(*args_)); |
986 EXTENSION_FUNCTION_VALIDATE(params.get()); | 988 EXTENSION_FUNCTION_VALIDATE(params.get()); |
987 | 989 |
988 int flags = params->flags; | 990 int flags = params->flags; |
989 item_path_str_ = params->path; | 991 item_path_str_ = params->path; |
990 key_path_str_ = params->private_key_path; | 992 key_path_str_ = params->private_key_path; |
991 | 993 |
992 base::FilePath root_directory = | 994 base::FilePath root_directory = |
993 base::FilePath::FromUTF8Unsafe(item_path_str_); | 995 base::FilePath::FromUTF8Unsafe(item_path_str_); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 } | 1029 } |
1028 | 1030 |
1029 DeveloperPrivatePackDirectoryFunction::DeveloperPrivatePackDirectoryFunction() | 1031 DeveloperPrivatePackDirectoryFunction::DeveloperPrivatePackDirectoryFunction() |
1030 {} | 1032 {} |
1031 | 1033 |
1032 DeveloperPrivatePackDirectoryFunction::~DeveloperPrivatePackDirectoryFunction() | 1034 DeveloperPrivatePackDirectoryFunction::~DeveloperPrivatePackDirectoryFunction() |
1033 {} | 1035 {} |
1034 | 1036 |
1035 DeveloperPrivateLoadUnpackedFunction::~DeveloperPrivateLoadUnpackedFunction() {} | 1037 DeveloperPrivateLoadUnpackedFunction::~DeveloperPrivateLoadUnpackedFunction() {} |
1036 | 1038 |
1037 bool DeveloperPrivateLoadDirectoryFunction::RunImpl() { | 1039 bool DeveloperPrivateLoadDirectoryFunction::RunAsync() { |
1038 // TODO(grv) : add unittests. | 1040 // TODO(grv) : add unittests. |
1039 std::string directory_url_str; | 1041 std::string directory_url_str; |
1040 std::string filesystem_name; | 1042 std::string filesystem_name; |
1041 std::string filesystem_path; | 1043 std::string filesystem_path; |
1042 | 1044 |
1043 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); | 1045 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &filesystem_name)); |
1044 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); | 1046 EXTENSION_FUNCTION_VALIDATE(args_->GetString(1, &filesystem_path)); |
1045 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &directory_url_str)); | 1047 EXTENSION_FUNCTION_VALIDATE(args_->GetString(2, &directory_url_str)); |
1046 | 1048 |
1047 // Directory url is non empty only for syncfilesystem. | 1049 // Directory url is non empty only for syncfilesystem. |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 this)); | 1236 this)); |
1235 } | 1237 } |
1236 } | 1238 } |
1237 | 1239 |
1238 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() | 1240 DeveloperPrivateLoadDirectoryFunction::DeveloperPrivateLoadDirectoryFunction() |
1239 : pending_copy_operations_count_(0), success_(true) {} | 1241 : pending_copy_operations_count_(0), success_(true) {} |
1240 | 1242 |
1241 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() | 1243 DeveloperPrivateLoadDirectoryFunction::~DeveloperPrivateLoadDirectoryFunction() |
1242 {} | 1244 {} |
1243 | 1245 |
1244 bool DeveloperPrivateChoosePathFunction::RunImpl() { | 1246 bool DeveloperPrivateChoosePathFunction::RunAsync() { |
1245 scoped_ptr<developer::ChoosePath::Params> params( | 1247 scoped_ptr<developer::ChoosePath::Params> params( |
1246 developer::ChoosePath::Params::Create(*args_)); | 1248 developer::ChoosePath::Params::Create(*args_)); |
1247 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 1249 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
1248 | 1250 |
1249 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; | 1251 ui::SelectFileDialog::Type type = ui::SelectFileDialog::SELECT_FOLDER; |
1250 ui::SelectFileDialog::FileTypeInfo info; | 1252 ui::SelectFileDialog::FileTypeInfo info; |
1251 if (params->select_type == developer::SELECT_TYPE_FILE) { | 1253 if (params->select_type == developer::SELECT_TYPE_FILE) { |
1252 type = ui::SelectFileDialog::SELECT_OPEN_FILE; | 1254 type = ui::SelectFileDialog::SELECT_OPEN_FILE; |
1253 } | 1255 } |
1254 base::string16 select_title; | 1256 base::string16 select_title; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1303 DeveloperPrivateIsProfileManagedFunction:: | 1305 DeveloperPrivateIsProfileManagedFunction:: |
1304 ~DeveloperPrivateIsProfileManagedFunction() { | 1306 ~DeveloperPrivateIsProfileManagedFunction() { |
1305 } | 1307 } |
1306 | 1308 |
1307 DeveloperPrivateRequestFileSourceFunction:: | 1309 DeveloperPrivateRequestFileSourceFunction:: |
1308 DeveloperPrivateRequestFileSourceFunction() {} | 1310 DeveloperPrivateRequestFileSourceFunction() {} |
1309 | 1311 |
1310 DeveloperPrivateRequestFileSourceFunction:: | 1312 DeveloperPrivateRequestFileSourceFunction:: |
1311 ~DeveloperPrivateRequestFileSourceFunction() {} | 1313 ~DeveloperPrivateRequestFileSourceFunction() {} |
1312 | 1314 |
1313 bool DeveloperPrivateRequestFileSourceFunction::RunImpl() { | 1315 bool DeveloperPrivateRequestFileSourceFunction::RunAsync() { |
1314 scoped_ptr<developer::RequestFileSource::Params> params( | 1316 scoped_ptr<developer::RequestFileSource::Params> params( |
1315 developer::RequestFileSource::Params::Create(*args_)); | 1317 developer::RequestFileSource::Params::Create(*args_)); |
1316 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 1318 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
1317 | 1319 |
1318 base::DictionaryValue* dict = NULL; | 1320 base::DictionaryValue* dict = NULL; |
1319 if (!params->dict->GetAsDictionary(&dict)) { | 1321 if (!params->dict->GetAsDictionary(&dict)) { |
1320 NOTREACHED(); | 1322 NOTREACHED(); |
1321 return false; | 1323 return false; |
1322 } | 1324 } |
1323 | 1325 |
1324 AddRef(); // Balanced in LaunchCallback(). | 1326 AddRef(); // Balanced in LaunchCallback(). |
1325 error_ui_util::HandleRequestFileSource( | 1327 error_ui_util::HandleRequestFileSource( |
1326 dict, | 1328 dict, |
1327 GetProfile(), | 1329 GetProfile(), |
1328 base::Bind(&DeveloperPrivateRequestFileSourceFunction::LaunchCallback, | 1330 base::Bind(&DeveloperPrivateRequestFileSourceFunction::LaunchCallback, |
1329 base::Unretained(this))); | 1331 base::Unretained(this))); |
1330 return true; | 1332 return true; |
1331 } | 1333 } |
1332 | 1334 |
1333 void DeveloperPrivateRequestFileSourceFunction::LaunchCallback( | 1335 void DeveloperPrivateRequestFileSourceFunction::LaunchCallback( |
1334 const base::DictionaryValue& results) { | 1336 const base::DictionaryValue& results) { |
1335 SetResult(results.DeepCopy()); | 1337 SetResult(results.DeepCopy()); |
1336 SendResponse(true); | 1338 SendResponse(true); |
1337 Release(); // Balanced in RunImpl(). | 1339 Release(); // Balanced in RunAsync(). |
1338 } | 1340 } |
1339 | 1341 |
1340 DeveloperPrivateOpenDevToolsFunction::DeveloperPrivateOpenDevToolsFunction() {} | 1342 DeveloperPrivateOpenDevToolsFunction::DeveloperPrivateOpenDevToolsFunction() {} |
1341 DeveloperPrivateOpenDevToolsFunction::~DeveloperPrivateOpenDevToolsFunction() {} | 1343 DeveloperPrivateOpenDevToolsFunction::~DeveloperPrivateOpenDevToolsFunction() {} |
1342 | 1344 |
1343 bool DeveloperPrivateOpenDevToolsFunction::RunImpl() { | 1345 bool DeveloperPrivateOpenDevToolsFunction::RunAsync() { |
1344 scoped_ptr<developer::OpenDevTools::Params> params( | 1346 scoped_ptr<developer::OpenDevTools::Params> params( |
1345 developer::OpenDevTools::Params::Create(*args_)); | 1347 developer::OpenDevTools::Params::Create(*args_)); |
1346 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); | 1348 EXTENSION_FUNCTION_VALIDATE(params.get() != NULL); |
1347 | 1349 |
1348 base::DictionaryValue* dict = NULL; | 1350 base::DictionaryValue* dict = NULL; |
1349 if (!params->dict->GetAsDictionary(&dict)) { | 1351 if (!params->dict->GetAsDictionary(&dict)) { |
1350 NOTREACHED(); | 1352 NOTREACHED(); |
1351 return false; | 1353 return false; |
1352 } | 1354 } |
1353 | 1355 |
1354 error_ui_util::HandleOpenDevTools(dict); | 1356 error_ui_util::HandleOpenDevTools(dict); |
1355 | 1357 |
1356 return true; | 1358 return true; |
1357 } | 1359 } |
1358 | 1360 |
1359 } // namespace api | 1361 } // namespace api |
1360 | 1362 |
1361 } // namespace extensions | 1363 } // namespace extensions |
OLD | NEW |