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