| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" |
| 10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/extensions/extension_prefs.h" | 12 #include "chrome/browser/extensions/extension_prefs.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
| 15 #include "chrome/common/extensions/extension.h" | 15 #include "chrome/common/extensions/extension.h" |
| 16 #include "chrome/common/extensions/extension_file_util.h" | 16 #include "chrome/common/extensions/extension_file_util.h" |
| 17 #include "chrome/common/extensions/extension_l10n_util.h" | 17 #include "chrome/common/extensions/extension_l10n_util.h" |
| 18 #include "chrome/common/extensions/manifest.h" | 18 #include "chrome/common/extensions/manifest.h" |
| 19 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
| 20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
| 21 #include "content/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 22 | 22 |
| 23 using content::BrowserThread; | 23 using content::BrowserThread; |
| 24 using content::UserMetricsAction; |
| 24 | 25 |
| 25 namespace errors = extension_manifest_errors; | 26 namespace errors = extension_manifest_errors; |
| 26 | 27 |
| 27 namespace { | 28 namespace { |
| 28 | 29 |
| 29 // The following enumeration is used in histograms matching | 30 // The following enumeration is used in histograms matching |
| 30 // Extensions.ManifestReload* . Values may be added, as long as existing | 31 // Extensions.ManifestReload* . Values may be added, as long as existing |
| 31 // values are not changed. | 32 // values are not changed. |
| 32 enum ManifestReloadReason { | 33 enum ManifestReloadReason { |
| 33 NOT_NEEDED = 0, // Reload not needed. | 34 NOT_NEEDED = 0, // Reload not needed. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 error = errors::kManifestUnreadable; | 82 error = errors::kManifestUnreadable; |
| 82 } | 83 } |
| 83 | 84 |
| 84 // Once installed, non-unpacked extensions cannot change their IDs (e.g., by | 85 // Once installed, non-unpacked extensions cannot change their IDs (e.g., by |
| 85 // updating the 'key' field in their manifest). | 86 // updating the 'key' field in their manifest). |
| 86 if (extension && | 87 if (extension && |
| 87 extension->location() != Extension::LOAD && | 88 extension->location() != Extension::LOAD && |
| 88 info.extension_id != extension->id()) { | 89 info.extension_id != extension->id()) { |
| 89 error = errors::kCannotChangeExtensionID; | 90 error = errors::kCannotChangeExtensionID; |
| 90 extension = NULL; | 91 extension = NULL; |
| 91 UserMetrics::RecordAction(UserMetricsAction("Extensions.IDChangedError")); | 92 content::RecordAction(UserMetricsAction("Extensions.IDChangedError")); |
| 92 } | 93 } |
| 93 | 94 |
| 94 if (!extension) { | 95 if (!extension) { |
| 95 extension_service_-> | 96 extension_service_-> |
| 96 ReportExtensionLoadError(info.extension_path, error, false); | 97 ReportExtensionLoadError(info.extension_path, error, false); |
| 97 return; | 98 return; |
| 98 } | 99 } |
| 99 | 100 |
| 100 if (write_to_prefs) | 101 if (write_to_prefs) |
| 101 extension_prefs_->UpdateManifest(extension); | 102 extension_prefs_->UpdateManifest(extension); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 if (extension_prefs_->AllowFileAccess(info->extension_id)) | 277 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 277 flags |= Extension::ALLOW_FILE_ACCESS; | 278 flags |= Extension::ALLOW_FILE_ACCESS; |
| 278 if (extension_prefs_->IsFromWebStore(info->extension_id)) | 279 if (extension_prefs_->IsFromWebStore(info->extension_id)) |
| 279 flags |= Extension::FROM_WEBSTORE; | 280 flags |= Extension::FROM_WEBSTORE; |
| 280 if (extension_prefs_->IsFromBookmark(info->extension_id)) | 281 if (extension_prefs_->IsFromBookmark(info->extension_id)) |
| 281 flags |= Extension::FROM_BOOKMARK; | 282 flags |= Extension::FROM_BOOKMARK; |
| 282 return flags; | 283 return flags; |
| 283 } | 284 } |
| 284 | 285 |
| 285 } // namespace extensions | 286 } // namespace extensions |
| OLD | NEW |