Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(569)

Side by Side Diff: chrome/browser/extensions/api/developer_private/developer_private_api.cc

Issue 2801583003: developerPrivate.repair: Skip not-corrupted and policy extensions (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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,
Devlin 2017/04/06 00:54:06 Should we also check MustRemainInstalled()?
lazyboy 2017/04/06 01:33:53 I'm not entirely sure, I copied the logic from ver
Devlin 2017/04/06 15:12:31 Yeah, the differences differences between all of t
lazyboy 2017/04/06 18:06:05 OK, done MustRemainEnabled || MustRemainInstalled
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. Currently this would uninstall the extension but
Devlin 2017/04/06 00:54:06 Should we even allow this in the case of corruptio
lazyboy 2017/04/06 01:33:53 "Currently" is misleading here, I meant to put tha
Devlin 2017/04/06 15:12:31 Yep, I figured. :) But my main question still sta
lazyboy 2017/04/06 18:06:05 Ah, that is correct. I've disallowed policy extens
1474 // then we will fail to reinstall it for policy check.
1475 if ((disable_reason & Extension::DISABLE_CORRUPTED) == 0)
Devlin 2017/04/06 00:55:24 And actually, we should probably have this check e
lazyboy 2017/04/06 01:33:53 Putting it in WebstoreReinstaller might other case
1476 return RespondNow(Error(kCannotRepairNotCorruptedExtension));
1477 }
1478
1464 content::WebContents* web_contents = GetSenderWebContents(); 1479 content::WebContents* web_contents = GetSenderWebContents();
1465 if (!web_contents) 1480 if (!web_contents)
1466 return RespondNow(Error(kCouldNotFindWebContentsError)); 1481 return RespondNow(Error(kCouldNotFindWebContentsError));
1467 1482
1468 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller( 1483 scoped_refptr<WebstoreReinstaller> reinstaller(new WebstoreReinstaller(
1469 web_contents, 1484 web_contents,
1470 params->extension_id, 1485 params->extension_id,
1471 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete, 1486 base::Bind(&DeveloperPrivateRepairExtensionFunction::OnReinstallComplete,
1472 this))); 1487 this)));
1473 reinstaller->BeginReinstall(); 1488 reinstaller->BeginReinstall();
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 update.extension_id, update.command_name, *update.keybinding); 1572 update.extension_id, update.command_name, *update.keybinding);
1558 } 1573 }
1559 1574
1560 return RespondNow(NoArguments()); 1575 return RespondNow(NoArguments());
1561 } 1576 }
1562 1577
1563 1578
1564 } // namespace api 1579 } // namespace api
1565 1580
1566 } // namespace extensions 1581 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/developer_private/developer_private_api_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698