| 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" |
| 11 #include "base/threading/thread_restrictions.h" | 11 #include "base/threading/thread_restrictions.h" |
| 12 #include "base/values.h" | 12 #include "base/values.h" |
| 13 #include "chrome/browser/browser_process.h" | 13 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/extensions/api/runtime/runtime_api.h" | 14 #include "chrome/browser/extensions/api/runtime/runtime_api.h" |
| 15 #include "chrome/browser/extensions/extension_action_manager.h" | 15 #include "chrome/browser/extensions/extension_action_manager.h" |
| 16 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 16 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
| 17 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
| 18 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" | 20 #include "chrome/common/extensions/api/managed_mode_private/managed_mode_handler
.h" |
| 20 #include "chrome/common/extensions/manifest_url_handler.h" | 21 #include "chrome/common/extensions/manifest_url_handler.h" |
| 21 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
| 22 #include "content/public/browser/notification_service.h" | 23 #include "content/public/browser/notification_service.h" |
| 23 #include "content/public/browser/user_metrics.h" | 24 #include "content/public/browser/user_metrics.h" |
| 24 #include "extensions/browser/extension_prefs.h" | 25 #include "extensions/browser/extension_prefs.h" |
| 25 #include "extensions/browser/extension_registry.h" | 26 #include "extensions/browser/extension_registry.h" |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 164 policy->MustRemainDisabled(extension, &disable_reason, NULL)) { | 165 policy->MustRemainDisabled(extension, &disable_reason, NULL)) { |
| 165 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); | 166 extension_prefs_->SetExtensionState(extension->id(), Extension::DISABLED); |
| 166 extension_prefs_->AddDisableReason(extension->id(), disable_reason); | 167 extension_prefs_->AddDisableReason(extension->id(), disable_reason); |
| 167 force_disabled = true; | 168 force_disabled = true; |
| 168 } | 169 } |
| 169 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", | 170 UMA_HISTOGRAM_BOOLEAN("ExtensionInstalledLoader.ForceDisabled", |
| 170 force_disabled); | 171 force_disabled); |
| 171 } | 172 } |
| 172 | 173 |
| 173 if (!extension.get()) { | 174 if (!extension.get()) { |
| 174 extension_service_->ReportExtensionLoadError(info.extension_path, error); | 175 ExtensionErrorReporter::GetInstance()->ReportLoadError( |
| 176 info.extension_path, |
| 177 error, |
| 178 extension_service_->profile(), |
| 179 false); // Be quiet. |
| 175 return; | 180 return; |
| 176 } | 181 } |
| 177 | 182 |
| 178 if (write_to_prefs) | 183 if (write_to_prefs) |
| 179 extension_prefs_->UpdateManifest(extension.get()); | 184 extension_prefs_->UpdateManifest(extension.get()); |
| 180 | 185 |
| 181 extension_service_->AddExtension(extension.get()); | 186 extension_service_->AddExtension(extension.get()); |
| 182 } | 187 } |
| 183 | 188 |
| 184 void InstalledLoader::LoadAllExtensions() { | 189 void InstalledLoader::LoadAllExtensions() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 215 base::ThreadRestrictions::ScopedAllowIO allow_io; | 220 base::ThreadRestrictions::ScopedAllowIO allow_io; |
| 216 | 221 |
| 217 std::string error; | 222 std::string error; |
| 218 scoped_refptr<const Extension> extension( | 223 scoped_refptr<const Extension> extension( |
| 219 file_util::LoadExtension(info->extension_path, | 224 file_util::LoadExtension(info->extension_path, |
| 220 info->extension_location, | 225 info->extension_location, |
| 221 GetCreationFlags(info), | 226 GetCreationFlags(info), |
| 222 &error)); | 227 &error)); |
| 223 | 228 |
| 224 if (!extension.get()) { | 229 if (!extension.get()) { |
| 225 extension_service_->ReportExtensionLoadError( | 230 ExtensionErrorReporter::GetInstance()->ReportLoadError( |
| 226 info->extension_path, error); | 231 info->extension_path, |
| 232 error, |
| 233 extension_service_->profile(), |
| 234 false); // Be quiet. |
| 227 continue; | 235 continue; |
| 228 } | 236 } |
| 229 | 237 |
| 230 extensions_info->at(i)->extension_manifest.reset( | 238 extensions_info->at(i)->extension_manifest.reset( |
| 231 static_cast<base::DictionaryValue*>( | 239 static_cast<base::DictionaryValue*>( |
| 232 extension->manifest()->value()->DeepCopy())); | 240 extension->manifest()->value()->DeepCopy())); |
| 233 should_write_prefs = true; | 241 should_write_prefs = true; |
| 234 } | 242 } |
| 235 } | 243 } |
| 236 | 244 |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 476 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { | 484 int InstalledLoader::GetCreationFlags(const ExtensionInfo* info) { |
| 477 int flags = extension_prefs_->GetCreationFlags(info->extension_id); | 485 int flags = extension_prefs_->GetCreationFlags(info->extension_id); |
| 478 if (!Manifest::IsUnpackedLocation(info->extension_location)) | 486 if (!Manifest::IsUnpackedLocation(info->extension_location)) |
| 479 flags |= Extension::REQUIRE_KEY; | 487 flags |= Extension::REQUIRE_KEY; |
| 480 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 488 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 481 flags |= Extension::ALLOW_FILE_ACCESS; | 489 flags |= Extension::ALLOW_FILE_ACCESS; |
| 482 return flags; | 490 return flags; |
| 483 } | 491 } |
| 484 | 492 |
| 485 } // namespace extensions | 493 } // namespace extensions |
| OLD | NEW |