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

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

Issue 2495123003: Continue attempts to reinstall corrupt policy extensions across restarts (Closed)
Patch Set: cleanup 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
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>
lazyboy 2016/11/16 01:44:53 Do you need these includes? I don't see any new co
asargent_no_longer_on_chrome 2016/11/17 21:48:01 I'm just fixing lint errors since I'm modifying th
lazyboy 2016/11/17 21:59:09 Good to know, thanks.
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/stringprintf.h" 15 #include "base/strings/stringprintf.h"
13 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
14 #include "base/threading/thread_restrictions.h" 17 #include "base/threading/thread_restrictions.h"
15 #include "base/trace_event/trace_event.h" 18 #include "base/trace_event/trace_event.h"
16 #include "base/values.h" 19 #include "base/values.h"
17 #include "chrome/browser/browser_process.h" 20 #include "chrome/browser/browser_process.h"
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 extension = NULL; 201 extension = NULL;
199 } 202 }
200 203
201 // Check policy on every load in case an extension was blacklisted while 204 // Check policy on every load in case an extension was blacklisted while
202 // Chrome was not running. 205 // Chrome was not running.
203 const ManagementPolicy* policy = extensions::ExtensionSystem::Get( 206 const ManagementPolicy* policy = extensions::ExtensionSystem::Get(
204 extension_service_->profile())->management_policy(); 207 extension_service_->profile())->management_policy();
205 if (extension.get()) { 208 if (extension.get()) {
206 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; 209 Extension::DisableReason disable_reason = Extension::DISABLE_NONE;
207 bool force_disabled = false; 210 bool force_disabled = false;
208 if (!policy->UserMayLoad(extension.get(), NULL)) { 211 if (!policy->UserMayLoad(extension.get(), nullptr)) {
209 // The error message from UserMayInstall() often contains the extension ID 212 // The error message from UserMayInstall() often contains the extension ID
210 // and is therefore not well suited to this UI. 213 // and is therefore not well suited to this UI.
211 error = errors::kDisabledByPolicy; 214 error = errors::kDisabledByPolicy;
212 extension = NULL; 215 extension = NULL;
213 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) && 216 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) &&
214 policy->MustRemainDisabled( 217 policy->MustRemainDisabled(extension.get(), &disable_reason,
215 extension.get(), &disable_reason, NULL)) { 218 nullptr)) {
216 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reason); 219 extension_prefs_->SetExtensionDisabled(extension->id(), disable_reason);
217 force_disabled = true; 220 force_disabled = true;
221 } else if (extension_prefs_->IsExtensionDisabled(extension->id()) &&
222 policy->MustRemainEnabled(extension.get(), nullptr) &&
223 extension_prefs_->HasDisableReason(
224 extension->id(), Extension::DISABLE_CORRUPTED)) {
225 PendingExtensionManager* pending_manager =
lazyboy 2016/11/16 01:44:53 I'd add a note saying sth that explains this, as i
asargent_no_longer_on_chrome 2016/11/17 21:48:01 Good feedback - I've added a comment.
lazyboy 2016/11/17 21:59:09 Acknowledged.
226 extension_service_->pending_extension_manager();
227 pending_manager->ExpectPolicyReinstallForCorruption(extension->id());
218 } 228 }
219 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", 229 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled",
220 force_disabled); 230 force_disabled);
221 } 231 }
222 232
223 if (!extension.get()) { 233 if (!extension.get()) {
224 ExtensionErrorReporter::GetInstance()->ReportLoadError( 234 ExtensionErrorReporter::GetInstance()->ReportLoadError(
225 info.extension_path, 235 info.extension_path,
226 error, 236 error,
227 extension_service_->profile(), 237 extension_service_->profile(),
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after
606 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { 616 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) {
607 int flags = extension_prefs_->GetCreationFlags(info->extension_id); 617 int flags = extension_prefs_->GetCreationFlags(info->extension_id);
608 if (!Manifest::IsUnpackedLocation(info->extension_location)) 618 if (!Manifest::IsUnpackedLocation(info->extension_location))
609 flags |= Extension::REQUIRE_KEY; 619 flags |= Extension::REQUIRE_KEY;
610 if (extension_prefs_->AllowFileAccess(info->extension_id)) 620 if (extension_prefs_->AllowFileAccess(info->extension_id))
611 flags |= Extension::ALLOW_FILE_ACCESS; 621 flags |= Extension::ALLOW_FILE_ACCESS;
612 return flags; 622 return flags;
613 } 623 }
614 624
615 } // namespace extensions 625 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698