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 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
386 info->runtime_errors.push_back(make_linked_ptr(value.release())); | 386 info->runtime_errors.push_back(make_linked_ptr(value.release())); |
387 break; | 387 break; |
388 } | 388 } |
389 case ExtensionError::NUM_ERROR_TYPES: | 389 case ExtensionError::NUM_ERROR_TYPES: |
390 NOTREACHED(); | 390 NOTREACHED(); |
391 break; | 391 break; |
392 } | 392 } |
393 } | 393 } |
394 } | 394 } |
395 } else { | 395 } else { |
396 for (std::vector<extensions::InstallWarning>::const_iterator it = | 396 for (std::vector<InstallWarning>::const_iterator it = |
397 item.install_warnings().begin(); | 397 item.install_warnings().begin(); |
398 it != item.install_warnings().end(); | 398 it != item.install_warnings().end(); |
399 ++it) { | 399 ++it) { |
400 scoped_ptr<developer::InstallWarning> warning( | 400 scoped_ptr<developer::InstallWarning> warning( |
401 new developer::InstallWarning); | 401 new developer::InstallWarning); |
402 warning->message = it->message; | 402 warning->message = it->message; |
403 info->install_warnings.push_back(make_linked_ptr(warning.release())); | 403 info->install_warnings.push_back(make_linked_ptr(warning.release())); |
404 } | 404 } |
405 } | 405 } |
406 } | 406 } |
(...skipping 12 matching lines...) Expand all Loading... | |
419 info->options_url.reset( | 419 info->options_url.reset( |
420 new std::string(ManifestURL::GetOptionsPage(&item).spec())); | 420 new std::string(ManifestURL::GetOptionsPage(&item).spec())); |
421 } | 421 } |
422 | 422 |
423 if (!ManifestURL::GetUpdateURL(&item).is_empty()) { | 423 if (!ManifestURL::GetUpdateURL(&item).is_empty()) { |
424 info->update_url.reset( | 424 info->update_url.reset( |
425 new std::string(ManifestURL::GetUpdateURL(&item).spec())); | 425 new std::string(ManifestURL::GetUpdateURL(&item).spec())); |
426 } | 426 } |
427 | 427 |
428 if (item.is_app()) { | 428 if (item.is_app()) { |
429 info->app_launch_url.reset(new std::string( | 429 info->app_launch_url.reset( |
430 extensions::AppLaunchInfo::GetFullLaunchURL(&item).spec())); | 430 new std::string(AppLaunchInfo::GetFullLaunchURL(&item).spec())); |
431 } | 431 } |
432 | 432 |
433 info->may_disable = system->management_policy()-> | 433 info->may_disable = system->management_policy()-> |
434 UserMayModifySettings(&item, NULL); | 434 UserMayModifySettings(&item, NULL); |
435 info->is_app = item.is_app(); | 435 info->is_app = item.is_app(); |
436 info->views = GetInspectablePagesForExtension(&item, item_is_enabled); | 436 info->views = GetInspectablePagesForExtension(&item, item_is_enabled); |
437 | 437 |
438 return info.Pass(); | 438 return info.Pass(); |
439 } | 439 } |
440 | 440 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
539 view->generated_background_page = generated_background_page; | 539 view->generated_background_page = generated_background_page; |
540 return view; | 540 return view; |
541 } | 541 } |
542 | 542 |
543 ItemInspectViewList DeveloperPrivateGetItemsInfoFunction:: | 543 ItemInspectViewList DeveloperPrivateGetItemsInfoFunction:: |
544 GetInspectablePagesForExtension( | 544 GetInspectablePagesForExtension( |
545 const Extension* extension, | 545 const Extension* extension, |
546 bool extension_is_enabled) { | 546 bool extension_is_enabled) { |
547 ItemInspectViewList result; | 547 ItemInspectViewList result; |
548 // Get the extension process's active views. | 548 // Get the extension process's active views. |
549 extensions::ProcessManager* process_manager = | 549 ProcessManager* process_manager = |
550 ExtensionSystem::Get(GetProfile())->process_manager(); | 550 ExtensionSystem::Get(GetProfile())->process_manager(); |
551 GetInspectablePagesForExtensionProcess( | 551 GetInspectablePagesForExtensionProcess( |
552 extension, | 552 extension, |
553 process_manager->GetRenderViewHostsForExtension(extension->id()), | 553 process_manager->GetRenderViewHostsForExtension(extension->id()), |
554 &result); | 554 &result); |
555 | 555 |
556 // Get app window views. | 556 // Get app window views. |
557 GetAppWindowPagesForExtensionProfile(extension, &result); | 557 GetAppWindowPagesForExtensionProfile(extension, &result); |
558 | 558 |
559 // Include a link to start the lazy background page, if applicable. | 559 // Include a link to start the lazy background page, if applicable. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
596 } | 596 } |
597 | 597 |
598 bool DeveloperPrivateGetItemsInfoFunction::RunAsync() { | 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 ExtensionSet items; |
607 | 607 |
608 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); | 608 ExtensionRegistry* registry = ExtensionRegistry::Get(GetProfile()); |
609 | 609 |
610 items.InsertAll(registry->enabled_extensions()); | 610 items.InsertAll(registry->enabled_extensions()); |
611 | 611 |
612 if (include_disabled) { | 612 if (include_disabled) { |
613 items.InsertAll(registry->disabled_extensions()); | 613 items.InsertAll(registry->disabled_extensions()); |
614 } | 614 } |
615 | 615 |
616 if (include_terminated) { | 616 if (include_terminated) { |
617 items.InsertAll(registry->terminated_extensions()); | 617 items.InsertAll(registry->terminated_extensions()); |
618 } | 618 } |
619 | 619 |
620 ExtensionService* service = | 620 ExtensionService* service = |
621 ExtensionSystem::Get(GetProfile())->extension_service(); | 621 ExtensionSystem::Get(GetProfile())->extension_service(); |
622 std::map<std::string, ExtensionResource> id_to_icon; | 622 std::map<std::string, ExtensionResource> id_to_icon; |
623 ItemInfoList item_list; | 623 ItemInfoList item_list; |
624 | 624 |
625 for (extensions::ExtensionSet::const_iterator iter = items.begin(); | 625 for (ExtensionSet::const_iterator iter = items.begin(); iter != items.end(); |
626 iter != items.end(); ++iter) { | 626 ++iter) { |
627 const Extension& item = *iter->get(); | 627 const Extension& item = *iter->get(); |
628 | 628 |
629 ExtensionResource item_resource = | 629 ExtensionResource item_resource = |
630 IconsInfo::GetIconResource(&item, | 630 IconsInfo::GetIconResource(&item, |
631 extension_misc::EXTENSION_ICON_MEDIUM, | 631 extension_misc::EXTENSION_ICON_MEDIUM, |
632 ExtensionIconSet::MATCH_BIGGER); | 632 ExtensionIconSet::MATCH_BIGGER); |
633 id_to_icon[item.id()] = item_resource; | 633 id_to_icon[item.id()] = item_resource; |
634 | 634 |
635 // Don't show component extensions and invisible apps. | 635 // Don't show component extensions and invisible apps. |
636 if (item.ShouldNotBeVisible()) | 636 if (item.ShouldNotBeVisible()) |
(...skipping 17 matching lines...) Expand all Loading... | |
654 | 654 |
655 bool DeveloperPrivateAllowFileAccessFunction::RunSync() { | 655 bool DeveloperPrivateAllowFileAccessFunction::RunSync() { |
656 scoped_ptr<AllowFileAccess::Params> params( | 656 scoped_ptr<AllowFileAccess::Params> params( |
657 AllowFileAccess::Params::Create(*args_)); | 657 AllowFileAccess::Params::Create(*args_)); |
658 EXTENSION_FUNCTION_VALIDATE(params.get()); | 658 EXTENSION_FUNCTION_VALIDATE(params.get()); |
659 | 659 |
660 EXTENSION_FUNCTION_VALIDATE(user_gesture_); | 660 EXTENSION_FUNCTION_VALIDATE(user_gesture_); |
661 | 661 |
662 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); | 662 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); |
663 ManagementPolicy* management_policy = system->management_policy(); | 663 ManagementPolicy* management_policy = system->management_policy(); |
664 ExtensionService* service = GetProfile()->GetExtensionService(); | 664 const Extension* extension = |
665 const Extension* extension = service->GetInstalledExtension(params->item_id); | 665 ExtensionRegistry::Get(GetProfile()) |
666 ->GetExtensionById(params->item_id, ExtensionRegistry::EVERYTHING); | |
666 bool result = true; | 667 bool result = true; |
667 | 668 |
668 if (!extension) { | 669 if (!extension) { |
669 result = false; | 670 result = false; |
670 } else if (!management_policy->UserMayModifySettings(extension, NULL)) { | 671 } else if (!management_policy->UserMayModifySettings(extension, NULL)) { |
671 LOG(ERROR) << "Attempt to change allow file access of an extension that " | 672 LOG(ERROR) << "Attempt to change allow file access of an extension that " |
672 << "non-usermanagable was made. Extension id : " | 673 << "non-usermanagable was made. Extension id : " |
673 << extension->id(); | 674 << extension->id(); |
674 result = false; | 675 result = false; |
675 } else { | 676 } else { |
676 util::SetAllowFileAccess(extension->id(), GetProfile(), params->allow); | 677 util::SetAllowFileAccess(extension->id(), GetProfile(), params->allow); |
677 result = true; | 678 result = true; |
678 } | 679 } |
679 | 680 |
680 return result; | 681 return result; |
681 } | 682 } |
682 | 683 |
683 DeveloperPrivateAllowFileAccessFunction:: | 684 DeveloperPrivateAllowFileAccessFunction:: |
684 ~DeveloperPrivateAllowFileAccessFunction() {} | 685 ~DeveloperPrivateAllowFileAccessFunction() {} |
685 | 686 |
686 bool DeveloperPrivateAllowIncognitoFunction::RunSync() { | 687 bool DeveloperPrivateAllowIncognitoFunction::RunSync() { |
687 scoped_ptr<AllowIncognito::Params> params( | 688 scoped_ptr<AllowIncognito::Params> params( |
688 AllowIncognito::Params::Create(*args_)); | 689 AllowIncognito::Params::Create(*args_)); |
689 EXTENSION_FUNCTION_VALIDATE(params.get()); | 690 EXTENSION_FUNCTION_VALIDATE(params.get()); |
690 | 691 |
691 ExtensionService* service = GetProfile()->GetExtensionService(); | 692 const Extension* extension = |
692 const Extension* extension = service->GetInstalledExtension(params->item_id); | 693 ExtensionRegistry::Get(GetProfile()) |
694 ->GetExtensionById(params->item_id, ExtensionRegistry::EVERYTHING); | |
693 bool result = true; | 695 bool result = true; |
694 | 696 |
695 if (!extension) | 697 if (!extension) |
696 result = false; | 698 result = false; |
697 else | 699 else |
698 util::SetIsIncognitoEnabled(extension->id(), GetProfile(), params->allow); | 700 util::SetIsIncognitoEnabled(extension->id(), GetProfile(), params->allow); |
699 | 701 |
700 return result; | 702 return result; |
701 } | 703 } |
702 | 704 |
703 DeveloperPrivateAllowIncognitoFunction:: | 705 DeveloperPrivateAllowIncognitoFunction:: |
704 ~DeveloperPrivateAllowIncognitoFunction() {} | 706 ~DeveloperPrivateAllowIncognitoFunction() {} |
705 | 707 |
706 bool DeveloperPrivateReloadFunction::RunSync() { | 708 bool DeveloperPrivateReloadFunction::RunSync() { |
707 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); | 709 scoped_ptr<Reload::Params> params(Reload::Params::Create(*args_)); |
708 EXTENSION_FUNCTION_VALIDATE(params.get()); | 710 EXTENSION_FUNCTION_VALIDATE(params.get()); |
709 | 711 |
710 ExtensionService* service = GetProfile()->GetExtensionService(); | 712 ExtensionService* service = GetProfile()->GetExtensionService(); |
711 CHECK(!params->item_id.empty()); | 713 CHECK(!params->item_id.empty()); |
712 service->ReloadExtension(params->item_id); | 714 service->ReloadExtension(params->item_id); |
713 return true; | 715 return true; |
714 } | 716 } |
715 | 717 |
716 bool DeveloperPrivateShowPermissionsDialogFunction::RunSync() { | 718 bool DeveloperPrivateShowPermissionsDialogFunction::RunSync() { |
717 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_)); | 719 EXTENSION_FUNCTION_VALIDATE(args_->GetString(0, &extension_id_)); |
718 ExtensionService* service = GetProfile()->GetExtensionService(); | |
719 CHECK(!extension_id_.empty()); | 720 CHECK(!extension_id_.empty()); |
720 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile()); | 721 AppWindowRegistry* registry = AppWindowRegistry::Get(GetProfile()); |
721 DCHECK(registry); | 722 DCHECK(registry); |
722 AppWindow* app_window = | 723 AppWindow* app_window = |
723 registry->GetAppWindowForRenderViewHost(render_view_host()); | 724 registry->GetAppWindowForRenderViewHost(render_view_host()); |
724 prompt_.reset(new ExtensionInstallPrompt(app_window->web_contents())); | 725 prompt_.reset(new ExtensionInstallPrompt(app_window->web_contents())); |
725 const Extension* extension = service->GetInstalledExtension(extension_id_); | 726 const Extension* extension = |
727 ExtensionRegistry::Get(GetProfile()) | |
728 ->GetExtensionById(extension_id_, ExtensionRegistry::EVERYTHING); | |
726 | 729 |
727 if (!extension) | 730 if (!extension) |
728 return false; | 731 return false; |
729 | 732 |
730 // Released by InstallUIAbort or InstallUIProceed. | 733 // Released by InstallUIAbort or InstallUIProceed. |
731 AddRef(); | 734 AddRef(); |
732 std::vector<base::FilePath> retained_file_paths; | 735 std::vector<base::FilePath> retained_file_paths; |
733 if (extension->HasAPIPermission(extensions::APIPermission::kFileSystem)) { | 736 if (extension->HasAPIPermission(APIPermission::kFileSystem)) { |
734 std::vector<apps::SavedFileEntry> retained_file_entries = | 737 std::vector<apps::SavedFileEntry> retained_file_entries = |
735 apps::SavedFilesService::Get(GetProfile()) | 738 apps::SavedFilesService::Get(GetProfile()) |
736 ->GetAllFileEntries(extension_id_); | 739 ->GetAllFileEntries(extension_id_); |
737 for (size_t i = 0; i < retained_file_entries.size(); i++) { | 740 for (size_t i = 0; i < retained_file_entries.size(); i++) { |
738 retained_file_paths.push_back(retained_file_entries[i].path); | 741 retained_file_paths.push_back(retained_file_entries[i].path); |
739 } | 742 } |
740 } | 743 } |
741 prompt_->ReviewPermissions(this, extension, retained_file_paths); | 744 prompt_->ReviewPermissions(this, extension, retained_file_paths); |
742 return true; | 745 return true; |
743 } | 746 } |
(...skipping 27 matching lines...) Expand all Loading... | |
771 DeveloperPrivateEnableFunction::DeveloperPrivateEnableFunction() {} | 774 DeveloperPrivateEnableFunction::DeveloperPrivateEnableFunction() {} |
772 | 775 |
773 bool DeveloperPrivateEnableFunction::RunSync() { | 776 bool DeveloperPrivateEnableFunction::RunSync() { |
774 scoped_ptr<Enable::Params> params(Enable::Params::Create(*args_)); | 777 scoped_ptr<Enable::Params> params(Enable::Params::Create(*args_)); |
775 EXTENSION_FUNCTION_VALIDATE(params.get()); | 778 EXTENSION_FUNCTION_VALIDATE(params.get()); |
776 | 779 |
777 std::string extension_id = params->item_id; | 780 std::string extension_id = params->item_id; |
778 | 781 |
779 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); | 782 ExtensionSystem* system = ExtensionSystem::Get(GetProfile()); |
780 ManagementPolicy* policy = system->management_policy(); | 783 ManagementPolicy* policy = system->management_policy(); |
781 ExtensionService* service = GetProfile()->GetExtensionService(); | 784 ExtensionService* service = GetProfile()->GetExtensionService(); |
Devlin
2014/05/22 22:09:12
Since you're here, can you change this to system->
limasdf
2014/05/23 15:19:41
Done.
| |
782 | 785 |
783 const Extension* extension = service->GetInstalledExtension(extension_id); | 786 const Extension* extension = |
787 ExtensionRegistry::Get(GetProfile()) | |
788 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING); | |
784 if (!extension) { | 789 if (!extension) { |
785 LOG(ERROR) << "Did not find extension with id " << extension_id; | 790 LOG(ERROR) << "Did not find extension with id " << extension_id; |
786 return false; | 791 return false; |
787 } | 792 } |
788 bool enable = params->enable; | 793 bool enable = params->enable; |
789 if (!policy->UserMayModifySettings(extension, NULL) || | 794 if (!policy->UserMayModifySettings(extension, NULL) || |
790 (!enable && policy->MustRemainEnabled(extension, NULL)) || | 795 (!enable && policy->MustRemainEnabled(extension, NULL)) || |
791 (enable && policy->MustRemainDisabled(extension, NULL, NULL))) { | 796 (enable && policy->MustRemainDisabled(extension, NULL, NULL))) { |
792 LOG(ERROR) << "Attempt to change enable state denied by management policy. " | 797 LOG(ERROR) << "Attempt to change enable state denied by management policy. " |
793 << "Extension id: " << extension_id.c_str(); | 798 << "Extension id: " << extension_id.c_str(); |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1354 } | 1359 } |
1355 | 1360 |
1356 error_ui_util::HandleOpenDevTools(dict); | 1361 error_ui_util::HandleOpenDevTools(dict); |
1357 | 1362 |
1358 return true; | 1363 return true; |
1359 } | 1364 } |
1360 | 1365 |
1361 } // namespace api | 1366 } // namespace api |
1362 | 1367 |
1363 } // namespace extensions | 1368 } // namespace extensions |
OLD | NEW |