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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 68 #include "extensions/browser/file_highlighter.h" | 68 #include "extensions/browser/file_highlighter.h" |
| 69 #include "extensions/browser/management_policy.h" | 69 #include "extensions/browser/management_policy.h" |
| 70 #include "extensions/browser/notification_types.h" | 70 #include "extensions/browser/notification_types.h" |
| 71 #include "extensions/browser/warning_service.h" | 71 #include "extensions/browser/warning_service.h" |
| 72 #include "extensions/common/constants.h" | 72 #include "extensions/common/constants.h" |
| 73 #include "extensions/common/extension_set.h" | 73 #include "extensions/common/extension_set.h" |
| 74 #include "extensions/common/feature_switch.h" | 74 #include "extensions/common/feature_switch.h" |
| 75 #include "extensions/common/install_warning.h" | 75 #include "extensions/common/install_warning.h" |
| 76 #include "extensions/common/manifest.h" | 76 #include "extensions/common/manifest.h" |
| 77 #include "extensions/common/manifest_handlers/options_page_info.h" | 77 #include "extensions/common/manifest_handlers/options_page_info.h" |
| 78 #include "extensions/common/manifest_url_handlers.h" | |
| 78 #include "extensions/common/permissions/permissions_data.h" | 79 #include "extensions/common/permissions/permissions_data.h" |
| 79 #include "extensions/grit/extensions_browser_resources.h" | 80 #include "extensions/grit/extensions_browser_resources.h" |
| 80 #include "storage/browser/fileapi/external_mount_points.h" | 81 #include "storage/browser/fileapi/external_mount_points.h" |
| 81 #include "storage/browser/fileapi/file_system_context.h" | 82 #include "storage/browser/fileapi/file_system_context.h" |
| 82 #include "storage/browser/fileapi/file_system_operation.h" | 83 #include "storage/browser/fileapi/file_system_operation.h" |
| 83 #include "storage/browser/fileapi/file_system_operation_runner.h" | 84 #include "storage/browser/fileapi/file_system_operation_runner.h" |
| 84 #include "storage/browser/fileapi/isolated_context.h" | 85 #include "storage/browser/fileapi/isolated_context.h" |
| 85 #include "ui/base/l10n/l10n_util.h" | 86 #include "ui/base/l10n/l10n_util.h" |
| 86 | 87 |
| 87 namespace extensions { | 88 namespace extensions { |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 102 const char kNoSuchRendererError[] = "No such renderer."; | 103 const char kNoSuchRendererError[] = "No such renderer."; |
| 103 const char kInvalidPathError[] = "Invalid path."; | 104 const char kInvalidPathError[] = "Invalid path."; |
| 104 const char kManifestKeyIsRequiredError[] = | 105 const char kManifestKeyIsRequiredError[] = |
| 105 "The 'manifestKey' argument is required for manifest files."; | 106 "The 'manifestKey' argument is required for manifest files."; |
| 106 const char kCouldNotFindWebContentsError[] = | 107 const char kCouldNotFindWebContentsError[] = |
| 107 "Could not find a valid web contents."; | 108 "Could not find a valid web contents."; |
| 108 const char kCannotUpdateSupervisedProfileSettingsError[] = | 109 const char kCannotUpdateSupervisedProfileSettingsError[] = |
| 109 "Cannot change settings for a supervised profile."; | 110 "Cannot change settings for a supervised profile."; |
| 110 const char kNoOptionsPageForExtensionError[] = | 111 const char kNoOptionsPageForExtensionError[] = |
| 111 "Extension does not have an options page."; | 112 "Extension does not have an options page."; |
| 113 const char kCannotRepairNotCorruptedExtension[] = | |
| 114 "Cannot repair a not corrupted extension."; | |
| 112 | 115 |
| 113 const char kUnpackedAppsFolder[] = "apps_target"; | 116 const char kUnpackedAppsFolder[] = "apps_target"; |
| 114 const char kManifestFile[] = "manifest.json"; | 117 const char kManifestFile[] = "manifest.json"; |
| 115 | 118 |
| 116 ExtensionService* GetExtensionService(content::BrowserContext* context) { | 119 ExtensionService* GetExtensionService(content::BrowserContext* context) { |
| 117 return ExtensionSystem::Get(context)->extension_service(); | 120 return ExtensionSystem::Get(context)->extension_service(); |
| 118 } | 121 } |
| 119 | 122 |
| 120 std::string ReadFileToString(const base::FilePath& path) { | 123 std::string ReadFileToString(const base::FilePath& path) { |
| 121 std::string data; | 124 std::string data; |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1454 | 1457 |
| 1455 ExtensionFunction::ResponseAction | 1458 ExtensionFunction::ResponseAction |
| 1456 DeveloperPrivateRepairExtensionFunction::Run() { | 1459 DeveloperPrivateRepairExtensionFunction::Run() { |
| 1457 std::unique_ptr<developer::RepairExtension::Params> params( | 1460 std::unique_ptr<developer::RepairExtension::Params> params( |
| 1458 developer::RepairExtension::Params::Create(*args_)); | 1461 developer::RepairExtension::Params::Create(*args_)); |
| 1459 EXTENSION_FUNCTION_VALIDATE(params); | 1462 EXTENSION_FUNCTION_VALIDATE(params); |
| 1460 const Extension* extension = GetExtensionById(params->extension_id); | 1463 const Extension* extension = GetExtensionById(params->extension_id); |
| 1461 if (!extension) | 1464 if (!extension) |
| 1462 return RespondNow(Error(kNoSuchExtensionError)); | 1465 return RespondNow(Error(kNoSuchExtensionError)); |
| 1463 | 1466 |
| 1467 ExtensionSystem* extension_system = ExtensionSystem::Get(browser_context()); | |
| 1468 if (extension_system->management_policy()->MustRemainEnabled(extension, | |
| 1469 nullptr)) { | |
| 1470 int disable_reason = ExtensionPrefs::Get(browser_context()) | |
| 1471 ->GetDisableReasons(extension->id()); | |
| 1472 // Do not let a policy extension that is not corrupted to be | |
| 1473 // reinstalled/repaired. If we let |reinstaller| continue with the repair, | |
| 1474 // this would have uninstalled the extension but then we would have failed | |
| 1475 // to reinstall it for policy check. | |
| 1476 if ((disable_reason & Extension::DISABLE_CORRUPTED) == 0) | |
|
Devlin
2017/04/06 15:12:31
To elaborate on a previous comment, I don't think
lazyboy
2017/04/06 18:06:05
Done.
| |
| 1477 return RespondNow(Error(kCannotRepairNotCorruptedExtension)); | |
| 1478 } | |
| 1479 | |
| 1464 content::WebContents* web_contents = GetSenderWebContents(); | 1480 content::WebContents* web_contents = GetSenderWebContents(); |
| 1465 if (!web_contents) | 1481 if (!web_contents) |
| 1466 return RespondNow(Error(kCouldNotFindWebContentsError)); | 1482 return RespondNow(Error(kCouldNotFindWebContentsError)); |
| 1467 | 1483 |
| 1468 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller( | 1484 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller( |
| 1469 web_contents, | 1485 web_contents, |
| 1470 params->extension_id, | 1486 params->extension_id, |
| 1471 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete, | 1487 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete, |
| 1472 this))); | 1488 this))); |
| 1473 reinstaller->BeginReinstall(); | 1489 reinstaller->BeginReinstall(); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1557 update.extension_id, update.command_name, *update.keybinding); | 1573 update.extension_id, update.command_name, *update.keybinding); |
| 1558 } | 1574 } |
| 1559 | 1575 |
| 1560 return RespondNow(NoArguments()); | 1576 return RespondNow(NoArguments()); |
| 1561 } | 1577 } |
| 1562 | 1578 |
| 1563 | 1579 |
| 1564 } // namespace api | 1580 } // namespace api |
| 1565 | 1581 |
| 1566 } // namespace extensions | 1582 } // namespace extensions |
| OLD | NEW |