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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
192 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 192 CHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
193 | 193 |
194 frontend_ = frontend; | 194 frontend_ = frontend; |
195 | 195 |
196 // Explicit UI loads are always noisy. | 196 // Explicit UI loads are always noisy. |
197 alert_on_error_ = true; | 197 alert_on_error_ = true; |
198 | 198 |
199 FilePath extension_path = path_in; | 199 FilePath extension_path = path_in; |
200 file_util::AbsolutePath(&extension_path); | 200 file_util::AbsolutePath(&extension_path); |
201 | 201 |
202 int flags = Extension::NO_FLAGS; | 202 int flags = Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) ? |
| 203 Extension::ALLOW_FILE_ACCESS : Extension::NO_FLAGS; |
203 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD)) | 204 if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD)) |
204 flags |= Extension::STRICT_ERROR_CHECKS; | 205 flags |= Extension::STRICT_ERROR_CHECKS; |
205 std::string error; | 206 std::string error; |
206 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( | 207 scoped_refptr<const Extension> extension(extension_file_util::LoadExtension( |
207 extension_path, | 208 extension_path, |
208 Extension::LOAD, | 209 Extension::LOAD, |
209 flags, | 210 flags, |
210 &error)); | 211 &error)); |
211 | 212 |
212 if (!extension) { | 213 if (!extension) { |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 // UI thread because reloads should be very rare, and the complexity | 792 // UI thread because reloads should be very rare, and the complexity |
792 // added by delaying the time when the extensions service knows about | 793 // added by delaying the time when the extensions service knows about |
793 // all extensions is significant. See crbug.com/37548 for details. | 794 // all extensions is significant. See crbug.com/37548 for details. |
794 // |allow_io| disables tests that file operations run on the file | 795 // |allow_io| disables tests that file operations run on the file |
795 // thread. | 796 // thread. |
796 base::ThreadRestrictions::ScopedAllowIO allow_io; | 797 base::ThreadRestrictions::ScopedAllowIO allow_io; |
797 | 798 |
798 int flags = Extension::NO_FLAGS; | 799 int flags = Extension::NO_FLAGS; |
799 if (Extension::ShouldDoStrictErrorChecking(info->extension_location)) | 800 if (Extension::ShouldDoStrictErrorChecking(info->extension_location)) |
800 flags |= Extension::STRICT_ERROR_CHECKS; | 801 flags |= Extension::STRICT_ERROR_CHECKS; |
| 802 if (extension_prefs_->AllowFileAccess(info->extension_id)) |
| 803 flags |= Extension::ALLOW_FILE_ACCESS; |
801 std::string error; | 804 std::string error; |
802 scoped_refptr<const Extension> extension( | 805 scoped_refptr<const Extension> extension( |
803 extension_file_util::LoadExtension( | 806 extension_file_util::LoadExtension( |
804 info->extension_path, | 807 info->extension_path, |
805 info->extension_location, | 808 info->extension_location, |
806 flags, | 809 flags, |
807 &error)); | 810 &error)); |
808 | 811 |
809 if (extension.get()) { | 812 if (extension.get()) { |
810 extensions_info->at(i)->extension_manifest.reset( | 813 extensions_info->at(i)->extension_manifest.reset( |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 std::string error; | 918 std::string error; |
916 scoped_refptr<const Extension> extension(NULL); | 919 scoped_refptr<const Extension> extension(NULL); |
917 if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) { | 920 if (!extension_prefs_->IsExtensionAllowedByPolicy(info.extension_id)) { |
918 error = errors::kDisabledByPolicy; | 921 error = errors::kDisabledByPolicy; |
919 } else if (info.extension_manifest.get()) { | 922 } else if (info.extension_manifest.get()) { |
920 int flags = Extension::NO_FLAGS; | 923 int flags = Extension::NO_FLAGS; |
921 if (info.extension_location != Extension::LOAD) | 924 if (info.extension_location != Extension::LOAD) |
922 flags |= Extension::REQUIRE_KEY; | 925 flags |= Extension::REQUIRE_KEY; |
923 if (Extension::ShouldDoStrictErrorChecking(info.extension_location)) | 926 if (Extension::ShouldDoStrictErrorChecking(info.extension_location)) |
924 flags |= Extension::STRICT_ERROR_CHECKS; | 927 flags |= Extension::STRICT_ERROR_CHECKS; |
| 928 if (extension_prefs_->AllowFileAccess(info.extension_id)) |
| 929 flags |= Extension::ALLOW_FILE_ACCESS; |
925 extension = Extension::Create( | 930 extension = Extension::Create( |
926 info.extension_path, | 931 info.extension_path, |
927 info.extension_location, | 932 info.extension_location, |
928 *info.extension_manifest, | 933 *info.extension_manifest, |
929 flags, | 934 flags, |
930 &error); | 935 &error); |
931 } else { | 936 } else { |
932 error = errors::kManifestUnreadable; | 937 error = errors::kManifestUnreadable; |
933 } | 938 } |
934 | 939 |
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1487 initial_enable_incognito = | 1492 initial_enable_incognito = |
1488 extension_prefs_->IsIncognitoEnabled(extension->id()); | 1493 extension_prefs_->IsIncognitoEnabled(extension->id()); |
1489 } | 1494 } |
1490 | 1495 |
1491 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", | 1496 UMA_HISTOGRAM_ENUMERATION("Extensions.InstallType", |
1492 extension->GetType(), 100); | 1497 extension->GetType(), 100); |
1493 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension); | 1498 ShownSectionsHandler::OnExtensionInstalled(profile_->GetPrefs(), extension); |
1494 extension_prefs_->OnExtensionInstalled( | 1499 extension_prefs_->OnExtensionInstalled( |
1495 extension, initial_state, initial_enable_incognito); | 1500 extension, initial_state, initial_enable_incognito); |
1496 | 1501 |
1497 // Unpacked extensions start off with file access since they are a developer | 1502 if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD)) |
1498 // feature. | |
1499 if (extension->location() == Extension::LOAD) | |
1500 extension_prefs_->SetAllowFileAccess(extension->id(), true); | 1503 extension_prefs_->SetAllowFileAccess(extension->id(), true); |
1501 | 1504 |
1502 // If the extension is a theme, tell the profile (and therefore ThemeProvider) | 1505 // If the extension is a theme, tell the profile (and therefore ThemeProvider) |
1503 // to apply it. | 1506 // to apply it. |
1504 if (extension->is_theme()) { | 1507 if (extension->is_theme()) { |
1505 NotificationService::current()->Notify( | 1508 NotificationService::current()->Notify( |
1506 NotificationType::THEME_INSTALLED, | 1509 NotificationType::THEME_INSTALLED, |
1507 Source<Profile>(profile_), | 1510 Source<Profile>(profile_), |
1508 Details<const Extension>(extension)); | 1511 Details<const Extension>(extension)); |
1509 } else { | 1512 } else { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 } | 1767 } |
1765 | 1768 |
1766 void ExtensionService::SetBeingUpgraded(const Extension* extension, | 1769 void ExtensionService::SetBeingUpgraded(const Extension* extension, |
1767 bool value) { | 1770 bool value) { |
1768 extension_runtime_data_[extension->id()].being_upgraded = value; | 1771 extension_runtime_data_[extension->id()].being_upgraded = value; |
1769 } | 1772 } |
1770 | 1773 |
1771 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { | 1774 PropertyBag* ExtensionService::GetPropertyBag(const Extension* extension) { |
1772 return &extension_runtime_data_[extension->id()].property_bag; | 1775 return &extension_runtime_data_[extension->id()].property_bag; |
1773 } | 1776 } |
OLD | NEW |