Chromium Code Reviews| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 53 #include "content/public/browser/browser_thread.h" | 53 #include "content/public/browser/browser_thread.h" |
| 54 #include "content/public/browser/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
| 55 #include "content/public/browser/render_frame_host.h" | 55 #include "content/public/browser/render_frame_host.h" |
| 56 #include "content/public/browser/render_process_host.h" | 56 #include "content/public/browser/render_process_host.h" |
| 57 #include "content/public/browser/site_instance.h" | 57 #include "content/public/browser/site_instance.h" |
| 58 #include "content/public/browser/storage_partition.h" | 58 #include "content/public/browser/storage_partition.h" |
| 59 #include "content/public/browser/web_contents.h" | 59 #include "content/public/browser/web_contents.h" |
| 60 #include "extensions/browser/api/file_handlers/app_file_handler_util.h" | 60 #include "extensions/browser/api/file_handlers/app_file_handler_util.h" |
| 61 #include "extensions/browser/app_window/app_window.h" | 61 #include "extensions/browser/app_window/app_window.h" |
| 62 #include "extensions/browser/app_window/app_window_registry.h" | 62 #include "extensions/browser/app_window/app_window_registry.h" |
| 63 #include "extensions/browser/content_verifier.h" | |
| 63 #include "extensions/browser/error_map.h" | 64 #include "extensions/browser/error_map.h" |
| 64 #include "extensions/browser/extension_error.h" | 65 #include "extensions/browser/extension_error.h" |
| 65 #include "extensions/browser/extension_prefs.h" | 66 #include "extensions/browser/extension_prefs.h" |
| 66 #include "extensions/browser/extension_registry.h" | 67 #include "extensions/browser/extension_registry.h" |
| 67 #include "extensions/browser/extension_system.h" | 68 #include "extensions/browser/extension_system.h" |
| 68 #include "extensions/browser/file_highlighter.h" | 69 #include "extensions/browser/file_highlighter.h" |
| 69 #include "extensions/browser/management_policy.h" | 70 #include "extensions/browser/management_policy.h" |
| 70 #include "extensions/browser/notification_types.h" | 71 #include "extensions/browser/notification_types.h" |
| 71 #include "extensions/browser/warning_service.h" | 72 #include "extensions/browser/warning_service.h" |
| 72 #include "extensions/common/constants.h" | 73 #include "extensions/common/constants.h" |
| 73 #include "extensions/common/extension_set.h" | 74 #include "extensions/common/extension_set.h" |
| 74 #include "extensions/common/feature_switch.h" | 75 #include "extensions/common/feature_switch.h" |
| 75 #include "extensions/common/install_warning.h" | 76 #include "extensions/common/install_warning.h" |
| 76 #include "extensions/common/manifest.h" | 77 #include "extensions/common/manifest.h" |
| 77 #include "extensions/common/manifest_handlers/options_page_info.h" | 78 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 79 #include "extensions/common/manifest_url_handlers.h" | |
| 78 #include "extensions/common/permissions/permissions_data.h" | 80 #include "extensions/common/permissions/permissions_data.h" |
| 79 #include "extensions/grit/extensions_browser_resources.h" | 81 #include "extensions/grit/extensions_browser_resources.h" |
| 80 #include "storage/browser/fileapi/external_mount_points.h" | 82 #include "storage/browser/fileapi/external_mount_points.h" |
| 81 #include "storage/browser/fileapi/file_system_context.h" | 83 #include "storage/browser/fileapi/file_system_context.h" |
| 82 #include "storage/browser/fileapi/file_system_operation.h" | 84 #include "storage/browser/fileapi/file_system_operation.h" |
| 83 #include "storage/browser/fileapi/file_system_operation_runner.h" | 85 #include "storage/browser/fileapi/file_system_operation_runner.h" |
| 84 #include "storage/browser/fileapi/isolated_context.h" | 86 #include "storage/browser/fileapi/isolated_context.h" |
| 85 #include "ui/base/l10n/l10n_util.h" | 87 #include "ui/base/l10n/l10n_util.h" |
| 86 | 88 |
| 87 namespace extensions { | 89 namespace extensions { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 102 const char kNoSuchRendererError[] = "No such renderer."; | 104 const char kNoSuchRendererError[] = "No such renderer."; |
| 103 const char kInvalidPathError[] = "Invalid path."; | 105 const char kInvalidPathError[] = "Invalid path."; |
| 104 const char kManifestKeyIsRequiredError[] = | 106 const char kManifestKeyIsRequiredError[] = |
| 105 "The 'manifestKey' argument is required for manifest files."; | 107 "The 'manifestKey' argument is required for manifest files."; |
| 106 const char kCouldNotFindWebContentsError[] = | 108 const char kCouldNotFindWebContentsError[] = |
| 107 "Could not find a valid web contents."; | 109 "Could not find a valid web contents."; |
| 108 const char kCannotUpdateSupervisedProfileSettingsError[] = | 110 const char kCannotUpdateSupervisedProfileSettingsError[] = |
| 109 "Cannot change settings for a supervised profile."; | 111 "Cannot change settings for a supervised profile."; |
| 110 const char kNoOptionsPageForExtensionError[] = | 112 const char kNoOptionsPageForExtensionError[] = |
| 111 "Extension does not have an options page."; | 113 "Extension does not have an options page."; |
| 114 const char kCannotRepairHealthyExtension[] = | |
| 115 "Cannot repair a healthy extension."; | |
| 116 const char kCannotRepairPolicyExtension[] = | |
| 117 "Cannot repair a policy-installed extension."; | |
| 112 | 118 |
| 113 const char kUnpackedAppsFolder[] = "apps_target"; | 119 const char kUnpackedAppsFolder[] = "apps_target"; |
| 114 const char kManifestFile[] = "manifest.json"; | 120 const char kManifestFile[] = "manifest.json"; |
| 115 | 121 |
| 116 ExtensionService* GetExtensionService(content::BrowserContext* context) { | 122 ExtensionService* GetExtensionService(content::BrowserContext* context) { |
| 117 return ExtensionSystem::Get(context)->extension_service(); | 123 return ExtensionSystem::Get(context)->extension_service(); |
| 118 } | 124 } |
| 119 | 125 |
| 120 std::string ReadFileToString(const base::FilePath& path) { | 126 std::string ReadFileToString(const base::FilePath& path) { |
| 121 std::string data; | 127 std::string data; |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 144 // terminated. | 150 // terminated. |
| 145 void PerformVerificationCheck(content::BrowserContext* context) { | 151 void PerformVerificationCheck(content::BrowserContext* context) { |
| 146 std::unique_ptr<ExtensionSet> extensions = | 152 std::unique_ptr<ExtensionSet> extensions = |
| 147 ExtensionRegistry::Get(context)->GenerateInstalledExtensionsSet( | 153 ExtensionRegistry::Get(context)->GenerateInstalledExtensionsSet( |
| 148 ExtensionRegistry::ENABLED | ExtensionRegistry::DISABLED | | 154 ExtensionRegistry::ENABLED | ExtensionRegistry::DISABLED | |
| 149 ExtensionRegistry::TERMINATED); | 155 ExtensionRegistry::TERMINATED); |
| 150 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); | 156 ExtensionPrefs* prefs = ExtensionPrefs::Get(context); |
| 151 bool should_do_verification_check = false; | 157 bool should_do_verification_check = false; |
| 152 for (const scoped_refptr<const Extension>& extension : *extensions) { | 158 for (const scoped_refptr<const Extension>& extension : *extensions) { |
| 153 if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), context) && | 159 if (ui_util::ShouldDisplayInExtensionSettings(extension.get(), context) && |
| 154 ((prefs->GetDisableReasons(extension->id()) & | 160 prefs->HasDisableReason(extension->id(), |
|
lazyboy
2017/04/06 22:32:56
Note: unrelated to this CL
| |
| 155 Extension::DISABLE_NOT_VERIFIED) != 0)) { | 161 Extension::DISABLE_NOT_VERIFIED)) { |
| 156 should_do_verification_check = true; | 162 should_do_verification_check = true; |
| 157 break; | 163 break; |
| 158 } | 164 } |
| 159 } | 165 } |
| 160 | 166 |
| 161 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", | 167 UMA_HISTOGRAM_BOOLEAN("ExtensionSettings.ShouldDoVerificationCheck", |
| 162 should_do_verification_check); | 168 should_do_verification_check); |
| 163 if (should_do_verification_check) | 169 if (should_do_verification_check) |
| 164 InstallVerifier::Get(context)->VerifyAllExtensions(); | 170 InstallVerifier::Get(context)->VerifyAllExtensions(); |
| 165 } | 171 } |
| (...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 | 1460 |
| 1455 ExtensionFunction::ResponseAction | 1461 ExtensionFunction::ResponseAction |
| 1456 DeveloperPrivateRepairExtensionFunction::Run() { | 1462 DeveloperPrivateRepairExtensionFunction::Run() { |
| 1457 std::unique_ptr<developer::RepairExtension::Params> params( | 1463 std::unique_ptr<developer::RepairExtension::Params> params( |
| 1458 developer::RepairExtension::Params::Create(*args_)); | 1464 developer::RepairExtension::Params::Create(*args_)); |
| 1459 EXTENSION_FUNCTION_VALIDATE(params); | 1465 EXTENSION_FUNCTION_VALIDATE(params); |
| 1460 const Extension* extension = GetExtensionById(params->extension_id); | 1466 const Extension* extension = GetExtensionById(params->extension_id); |
| 1461 if (!extension) | 1467 if (!extension) |
| 1462 return RespondNow(Error(kNoSuchExtensionError)); | 1468 return RespondNow(Error(kNoSuchExtensionError)); |
| 1463 | 1469 |
| 1470 if (!ExtensionPrefs::Get(browser_context()) | |
| 1471 ->HasDisableReason(extension->id(), Extension::DISABLE_CORRUPTED)) { | |
| 1472 return RespondNow(Error(kCannotRepairHealthyExtension)); | |
| 1473 } | |
| 1474 | |
| 1475 ManagementPolicy* management_policy = | |
| 1476 ExtensionSystem::Get(browser_context())->management_policy(); | |
| 1477 // If content verifier would repair this extension independently, then don't | |
| 1478 // allow repair from here. This applies to policy extensions. | |
| 1479 // Also note that if we let |reinstaller| continue with the repair, this would | |
| 1480 // have uninstalled the extension but then we would have failed to reinstall | |
| 1481 // it for policy check (see PolicyCheck::Start()). | |
| 1482 if (ContentVerifier::ShouldRepairIfCorrupted(management_policy, extension)) | |
| 1483 return RespondNow(Error(kCannotRepairPolicyExtension)); | |
| 1484 | |
| 1464 content::WebContents* web_contents = GetSenderWebContents(); | 1485 content::WebContents* web_contents = GetSenderWebContents(); |
| 1465 if (!web_contents) | 1486 if (!web_contents) |
| 1466 return RespondNow(Error(kCouldNotFindWebContentsError)); | 1487 return RespondNow(Error(kCouldNotFindWebContentsError)); |
| 1467 | 1488 |
| 1468 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller( | 1489 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller( |
| 1469 web_contents, | 1490 web_contents, |
| 1470 params->extension_id, | 1491 params->extension_id, |
| 1471 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete, | 1492 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete, |
| 1472 this))); | 1493 this))); |
| 1473 reinstaller->BeginReinstall(); | 1494 reinstaller->BeginReinstall(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1557 update.extension_id, update.command_name, *update.keybinding); | 1578 update.extension_id, update.command_name, *update.keybinding); |
| 1558 } | 1579 } |
| 1559 | 1580 |
| 1560 return RespondNow(NoArguments()); | 1581 return RespondNow(NoArguments()); |
| 1561 } | 1582 } |
| 1562 | 1583 |
| 1563 | 1584 |
| 1564 } // namespace api | 1585 } // namespace api |
| 1565 | 1586 |
| 1566 } // namespace extensions | 1587 } // namespace extensions |
| OLD | NEW |