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

Side by Side Diff: chrome/browser/extensions/chrome_content_verifier_delegate.cc

Issue 2801583003: developerPrivate.repair: Skip not-corrupted and policy extensions (Closed)
Patch Set: fix WebstoreReinsallerBrowserTest 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/chrome_content_verifier_delegate.h" 5 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/base_switches.h" 12 #include "base/base_switches.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/memory/ptr_util.h" 14 #include "base/memory/ptr_util.h"
15 #include "base/metrics/field_trial.h" 15 #include "base/metrics/field_trial.h"
16 #include "base/metrics/histogram_macros.h" 16 #include "base/metrics/histogram_macros.h"
17 #include "base/strings/string_piece.h" 17 #include "base/strings/string_piece.h"
18 #include "base/strings/string_util.h" 18 #include "base/strings/string_util.h"
19 #include "base/syslog_logging.h" 19 #include "base/syslog_logging.h"
20 #include "base/threading/thread_task_runner_handle.h" 20 #include "base/threading/thread_task_runner_handle.h"
21 #include "base/version.h" 21 #include "base/version.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "chrome/browser/extensions/extension_service.h" 23 #include "chrome/browser/extensions/extension_service.h"
24 #include "chrome/browser/extensions/policy_extension_reinstaller.h" 24 #include "chrome/browser/extensions/policy_extension_reinstaller.h"
25 #include "chrome/common/chrome_switches.h" 25 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/extensions/extension_constants.h" 26 #include "chrome/common/extensions/extension_constants.h"
27 #include "extensions/browser/content_verifier.h"
27 #include "extensions/browser/extension_prefs.h" 28 #include "extensions/browser/extension_prefs.h"
28 #include "extensions/browser/extension_registry.h" 29 #include "extensions/browser/extension_registry.h"
29 #include "extensions/browser/extension_system.h" 30 #include "extensions/browser/extension_system.h"
30 #include "extensions/browser/management_policy.h" 31 #include "extensions/browser/management_policy.h"
31 #include "extensions/common/constants.h" 32 #include "extensions/common/constants.h"
32 #include "extensions/common/extension.h" 33 #include "extensions/common/extension.h"
33 #include "extensions/common/extension_urls.h" 34 #include "extensions/common/extension_urls.h"
34 #include "extensions/common/extensions_client.h" 35 #include "extensions/common/extensions_client.h"
35 #include "extensions/common/manifest.h" 36 #include "extensions/common/manifest.h"
36 #include "extensions/common/manifest_url_handlers.h" 37 #include "extensions/common/manifest_url_handlers.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 ContentVerifyJob::FailureReason reason) { 178 ContentVerifyJob::FailureReason reason) {
178 ExtensionRegistry* registry = ExtensionRegistry::Get(context_); 179 ExtensionRegistry* registry = ExtensionRegistry::Get(context_);
179 const Extension* extension = 180 const Extension* extension =
180 registry->enabled_extensions().GetByID(extension_id); 181 registry->enabled_extensions().GetByID(extension_id);
181 if (!extension) 182 if (!extension)
182 return; 183 return;
183 ExtensionSystem* system = ExtensionSystem::Get(context_); 184 ExtensionSystem* system = ExtensionSystem::Get(context_);
184 ExtensionService* service = system->extension_service(); 185 ExtensionService* service = system->extension_service();
185 Mode mode = ShouldBeVerified(*extension); 186 Mode mode = ShouldBeVerified(*extension);
186 if (mode >= ContentVerifierDelegate::ENFORCE) { 187 if (mode >= ContentVerifierDelegate::ENFORCE) {
187 if (system->management_policy()->MustRemainEnabled(extension, NULL)) { 188 if (ContentVerifier::ShouldRepairIfCorrupted(system->management_policy(),
189 extension)) {
188 PendingExtensionManager* pending_manager = 190 PendingExtensionManager* pending_manager =
189 service->pending_extension_manager(); 191 service->pending_extension_manager();
190 if (pending_manager->IsPolicyReinstallForCorruptionExpected(extension_id)) 192 if (pending_manager->IsPolicyReinstallForCorruptionExpected(extension_id))
191 return; 193 return;
192 SYSLOG(WARNING) << "Corruption detected in policy extension " 194 SYSLOG(WARNING) << "Corruption detected in policy extension "
193 << extension_id << " installed at: " 195 << extension_id << " installed at: "
194 << extension->path().value(); 196 << extension->path().value();
195 pending_manager->ExpectPolicyReinstallForCorruption(extension_id); 197 pending_manager->ExpectPolicyReinstallForCorruption(extension_id);
196 service->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED); 198 service->DisableExtension(extension_id, Extension::DISABLE_CORRUPTED);
197 // Attempt to reinstall. 199 // Attempt to reinstall.
(...skipping 17 matching lines...) Expand all
215 } 217 }
216 218
217 void ChromeContentVerifierDelegate::Shutdown() { 219 void ChromeContentVerifierDelegate::Shutdown() {
218 // Shut down |policy_extension_reinstaller_| on its creation thread. |this| 220 // Shut down |policy_extension_reinstaller_| on its creation thread. |this|
219 // can be destroyed through InfoMap on IO thread, we do not want to destroy 221 // can be destroyed through InfoMap on IO thread, we do not want to destroy
220 // |policy_extension_reinstaller_| there. 222 // |policy_extension_reinstaller_| there.
221 policy_extension_reinstaller_.reset(); 223 policy_extension_reinstaller_.reset();
222 } 224 }
223 225
224 } // namespace extensions 226 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698