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/installed_loader.h" | 5 #include "chrome/browser/extensions/installed_loader.h" |
6 | 6 |
7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 info.extension_id != extension->id()) { | 159 info.extension_id != extension->id()) { |
160 error = errors::kCannotChangeExtensionID; | 160 error = errors::kCannotChangeExtensionID; |
161 extension = NULL; | 161 extension = NULL; |
162 content::RecordAction(UserMetricsAction("Extensions.IDChangedError")); | 162 content::RecordAction(UserMetricsAction("Extensions.IDChangedError")); |
163 } | 163 } |
164 | 164 |
165 // Check policy on every load in case an extension was blacklisted while | 165 // Check policy on every load in case an extension was blacklisted while |
166 // Chrome was not running. | 166 // Chrome was not running. |
167 const ManagementPolicy* policy = extensions::ExtensionSystem::Get( | 167 const ManagementPolicy* policy = extensions::ExtensionSystem::Get( |
168 extension_service_->profile())->management_policy(); | 168 extension_service_->profile())->management_policy(); |
169 if (extension.get() && !policy->UserMayLoad(extension.get(), NULL)) { | 169 if (extension.get()) { |
170 // The error message from UserMayInstall() often contains the extension ID | 170 Extension::DisableReason disable_reason = Extension::DISABLE_NONE; |
171 // and is therefore not well suited to this UI. | 171 if (!policy->UserMayLoad(extension.get(), NULL)) { |
172 error = errors::kDisabledByPolicy; | 172 // The error message from UserMayInstall() often contains the extension ID |
173 extension = NULL; | 173 // and is therefore not well suited to this UI. |
| 174 error = errors::kDisabledByPolicy; |
| 175 extension = NULL; |
| 176 } else if (!extension_prefs_->IsExtensionDisabled(extension->id()) && |
| 177 policy->MustRemainDisabled(extension, &disable_reason, NULL)) { |
| 178 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
| 179 extension_prefs_->AddDisableReason(extension->id(), disable_reason); |
| 180 } |
174 } | 181 } |
175 | 182 |
176 if (!extension.get()) { | 183 if (!extension.get()) { |
177 extension_service_->ReportExtensionLoadError( | 184 extension_service_->ReportExtensionLoadError( |
178 info.extension_path, error, false); | 185 info.extension_path, error, false); |
179 return; | 186 return; |
180 } | 187 } |
181 | 188 |
182 if (write_to_prefs) | 189 if (write_to_prefs) |
183 extension_prefs_->UpdateManifest(extension.get()); | 190 extension_prefs_->UpdateManifest(extension.get()); |
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 489 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
483 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 490 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
484 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 491 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
485 flags |= Extension::REQUIRE_KEY; | 492 flags |= Extension::REQUIRE_KEY; |
486 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 493 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
487 flags |= Extension::ALLOW_FILE_ACCESS; | 494 flags |= Extension::ALLOW_FILE_ACCESS; |
488 return flags; | 495 return flags; |
489 } | 496 } |
490 | 497 |
491 } // namespace extensions | 498 } // namespace extensions |
OLD | NEW |