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/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 2081 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2092 extension_prefs_->extension_sorting()->EnsureValidOrdinals( | 2092 extension_prefs_->extension_sorting()->EnsureValidOrdinals( |
2093 extension->id(), syncer::StringOrdinal()); | 2093 extension->id(), syncer::StringOrdinal()); |
2094 } | 2094 } |
2095 | 2095 |
2096 extensions_.Insert(extension); | 2096 extensions_.Insert(extension); |
2097 SyncExtensionChangeIfNeeded(*extension); | 2097 SyncExtensionChangeIfNeeded(*extension); |
2098 NotifyExtensionLoaded(extension); | 2098 NotifyExtensionLoaded(extension); |
2099 DoPostLoadTasks(extension); | 2099 DoPostLoadTasks(extension); |
2100 } | 2100 } |
2101 | 2101 |
| 2102 void ExtensionService::AddComponentExtension(const Extension* extension) { |
| 2103 const std::string old_version_string( |
| 2104 extension_prefs_->GetVersionString(extension->id())); |
| 2105 const Version old_version(old_version_string); |
| 2106 |
| 2107 if (!old_version.IsValid() || !old_version.Equals(*extension->version())) { |
| 2108 VLOG(1) << "Component extension " << extension->name() << " (" |
| 2109 << extension->id() << ") installing/upgrading from '" |
| 2110 << old_version_string << "' to " << extension->version()->GetString(); |
| 2111 |
| 2112 AddNewOrUpdatedExtension(extension, |
| 2113 syncer::StringOrdinal(), |
| 2114 Extension::ENABLED_COMPONENT); |
| 2115 return; |
| 2116 } |
| 2117 |
| 2118 AddExtension(extension); |
| 2119 } |
| 2120 |
2102 void ExtensionService::InitializePermissions(const Extension* extension) { | 2121 void ExtensionService::InitializePermissions(const Extension* extension) { |
2103 // If the extension has used the optional permissions API, it will have a | 2122 // If the extension has used the optional permissions API, it will have a |
2104 // custom set of active permissions defined in the extension prefs. Here, | 2123 // custom set of active permissions defined in the extension prefs. Here, |
2105 // we update the extension's active permissions based on the prefs. | 2124 // we update the extension's active permissions based on the prefs. |
2106 scoped_refptr<PermissionSet> active_permissions = | 2125 scoped_refptr<PermissionSet> active_permissions = |
2107 extension_prefs()->GetActivePermissions(extension->id()); | 2126 extension_prefs()->GetActivePermissions(extension->id()); |
2108 | 2127 |
2109 if (active_permissions.get()) { | 2128 if (active_permissions.get()) { |
2110 // We restrict the active permissions to be within the bounds defined in the | 2129 // We restrict the active permissions to be within the bounds defined in the |
2111 // extension's manifest. | 2130 // extension's manifest. |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2360 | 2379 |
2361 // Transfer ownership of |extension|. | 2380 // Transfer ownership of |extension|. |
2362 pending_extension_updates_.Insert(extension); | 2381 pending_extension_updates_.Insert(extension); |
2363 | 2382 |
2364 // Notify extension of available update. | 2383 // Notify extension of available update. |
2365 extensions::RuntimeEventRouter::DispatchOnUpdateAvailableEvent( | 2384 extensions::RuntimeEventRouter::DispatchOnUpdateAvailableEvent( |
2366 profile_, id, extension->manifest()->value()); | 2385 profile_, id, extension->manifest()->value()); |
2367 return; | 2386 return; |
2368 } | 2387 } |
2369 | 2388 |
| 2389 // Transfer ownership of |extension|. |
| 2390 AddNewOrUpdatedExtension( |
| 2391 extension, |
| 2392 page_ordinal, |
| 2393 initial_enable ? Extension::ENABLED : Extension::DISABLED); |
| 2394 } |
| 2395 |
| 2396 void ExtensionService::AddNewOrUpdatedExtension( |
| 2397 const Extension* extension, |
| 2398 const syncer::StringOrdinal& page_ordinal, |
| 2399 Extension::State initial_state) { |
| 2400 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 2401 |
2370 extension_prefs_->OnExtensionInstalled( | 2402 extension_prefs_->OnExtensionInstalled( |
2371 extension, | 2403 extension, |
2372 initial_enable ? Extension::ENABLED : Extension::DISABLED, | 2404 initial_state, |
2373 page_ordinal); | 2405 page_ordinal); |
2374 | 2406 |
2375 // Unpacked extensions default to allowing file access, but if that has been | 2407 // Unpacked extensions default to allowing file access, but if that has been |
2376 // overridden, don't reset the value. | 2408 // overridden, don't reset the value. |
2377 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && | 2409 if (Extension::ShouldAlwaysAllowFileAccess(extension->location()) && |
2378 !extension_prefs_->HasAllowFileAccessSetting(id)) { | 2410 !extension_prefs_->HasAllowFileAccessSetting(extension->id())) { |
2379 extension_prefs_->SetAllowFileAccess(id, true); | 2411 extension_prefs_->SetAllowFileAccess(extension->id(), true); |
2380 } | 2412 } |
2381 | 2413 |
2382 FinishInstallation(extension); | 2414 FinishInstallation(extension); |
2383 } | 2415 } |
2384 | 2416 |
2385 void ExtensionService::MaybeFinishDelayedInstallation( | 2417 void ExtensionService::MaybeFinishDelayedInstallation( |
2386 const std::string& extension_id) { | 2418 const std::string& extension_id) { |
2387 // Check if the extension already got updated. | 2419 // Check if the extension already got updated. |
2388 if (!pending_extension_updates_.Contains(extension_id)) | 2420 if (!pending_extension_updates_.Contains(extension_id)) |
2389 return; | 2421 return; |
(...skipping 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2980 extension_id, kOnUpdateAvailableEvent); | 3012 extension_id, kOnUpdateAvailableEvent); |
2981 } else { | 3013 } else { |
2982 // Delay installation if the extension is not idle. | 3014 // Delay installation if the extension is not idle. |
2983 return !IsExtensionIdle(extension_id); | 3015 return !IsExtensionIdle(extension_id); |
2984 } | 3016 } |
2985 } | 3017 } |
2986 | 3018 |
2987 void ExtensionService::OnBlacklistUpdated() { | 3019 void ExtensionService::OnBlacklistUpdated() { |
2988 CheckManagementPolicy(); | 3020 CheckManagementPolicy(); |
2989 } | 3021 } |
OLD | NEW |