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

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

Issue 2495123003: Continue attempts to reinstall corrupt policy extensions across restarts (Closed)
Patch Set: merged latest from origin/master Created 4 years, 1 month 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 | « chrome/browser/extensions/content_verifier_browsertest.cc ('k') | no next file » | 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/installed_loader.h" 5 #include "chrome/browser/extensions/installed_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <memory>
9 #include <string>
10 #include <vector>
8 11
9 #include "base/files/file_path.h" 12 #include "base/files/file_path.h"
10 #include "base/metrics/histogram_macros.h" 13 #include "base/metrics/histogram_macros.h"
11 #include "base/metrics/sparse_histogram.h" 14 #include "base/metrics/sparse_histogram.h"
12 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
13 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
14 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
15 #include "base/values.h" 18 #include "base/values.h"
16 #include "chrome/browser/browser_process.h" 19 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/extensions/extension_error_reporter.h" 20 #include "chrome/browser/extensions/extension_error_reporter.h"
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 extension = NULL; 200 extension = NULL;
198 } 201 }
199 202
200 // Check policy on every load in case an extension was blacklisted while 203 // Check policy on every load in case an extension was blacklisted while
201 // Chrome was not running. 204 // Chrome was not running.
202 const ManagementPolicy* policy = extensions::ExtensionSystem::Get( 205 const ManagementPolicy* policy = extensions::ExtensionSystem::Get(
203 extension_service_->profile())->management_policy(); 206 extension_service_->profile())->management_policy();
204 if (extension.get()) { 207 if (extension.get()) {
205 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; 208 Extension::DisableReason disable_reason = Extension::DISABLE_NONE;
206 bool force_disabled = false; 209 bool force_disabled = false;
207 if (!policy->UserMayLoad(extension.get(), NULL)) { 210 if (!policy->UserMayLoad(extension.get(), nullptr)) {
208 // The error message from UserMayInstall() often contains the extension ID 211 // The error message from UserMayInstall() often contains the extension ID
209 // and is therefore not well suited to this UI. 212 // and is therefore not well suited to this UI.
210 error = errors::kDisabledByPolicy; 213 error = errors::kDisabledByPolicy;
211 extension = NULL; 214 extension = NULL;
212 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) && 215 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) &&
213 policy->MustRemainDisabled( 216 policy->MustRemainDisabled(extension.get(), &disable_reason,
214 extension.get(), &disable_reason, NULL)) { 217 nullptr)) {
215 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reason); 218 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reason);
216 force_disabled = true; 219 force_disabled = true;
220 } else if (extension_prefs_->IsExtensionDisabled(extension->id()) &&
221 policy->MustRemainEnabled(extension.get(), nullptr) &&
222 extension_prefs_->HasDisableReason(
223 extension->id(), Extension::DISABLE_CORRUPTED)) {
224 // This extension must have been disabled due to corruption on a previous
225 // run of chrome, and for some reason we weren't successful in
226 // auto-reinstalling it. So we want to notify the PendingExtensionManager
227 // that we'd still like to keep attempt to re-download and reinstall it
228 // whenever the ExtensionService checks for external updates.
229 PendingExtensionManager* pending_manager =
230 extension_service_->pending_extension_manager();
231 pending_manager->ExpectPolicyReinstallForCorruption(extension->id());
217 } 232 }
218 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", 233 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled",
219 force_disabled); 234 force_disabled);
220 } 235 }
221 236
222 if (!extension.get()) { 237 if (!extension.get()) {
223 ExtensionErrorReporter::GetInstance()->ReportLoadError( 238 ExtensionErrorReporter::GetInstance()->ReportLoadError(
224 info.extension_path, 239 info.extension_path,
225 error, 240 error,
226 extension_service_->profile(), 241 extension_service_->profile(),
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 620 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
606 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 621 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
607 if (!Manifest::IsUnpackedLocation(info->extension_location)) 622 if (!Manifest::IsUnpackedLocation(info->extension_location))
608 flags |= Extension::REQUIRE_KEY; 623 flags |= Extension::REQUIRE_KEY;
609 if (extension_prefs_->AllowFileAccess(info->extension_id)) 624 if (extension_prefs_->AllowFileAccess(info->extension_id))
610 flags |= Extension::ALLOW_FILE_ACCESS; 625 flags |= Extension::ALLOW_FILE_ACCESS;
611 return flags; 626 return flags;
612 } 627 }
613 628
614 } // namespace extensions 629 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_verifier_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698