Chromium Code Reviews| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 173 static const int kOmniboxIconPaddingLeft = 0; | 173 static const int kOmniboxIconPaddingLeft = 0; |
| 174 static const int kOmniboxIconPaddingRight = 0; | 174 static const int kOmniboxIconPaddingRight = 0; |
| 175 #endif | 175 #endif |
| 176 | 176 |
| 177 // Prompt the user this many times before considering an extension acknowledged. | 177 // Prompt the user this many times before considering an extension acknowledged. |
| 178 static const int kMaxExtensionAcknowledgePromptCount = 3; | 178 static const int kMaxExtensionAcknowledgePromptCount = 3; |
| 179 | 179 |
| 180 // Wait this many seconds after an extensions becomes idle before updating it. | 180 // Wait this many seconds after an extensions becomes idle before updating it. |
| 181 static const int kUpdateIdleDelay = 5; | 181 static const int kUpdateIdleDelay = 5; |
| 182 | 182 |
| 183 // Wait this many seconds before trying to garbage collect extensions again. | |
| 184 static const int kGarbageCollectRetryDelay = 30; | |
|
James Cook
2012/11/28 18:15:29
optional nit: Constants in anonymous namespace don
| |
| 185 | |
| 183 const char* kNaClPluginMimeType = "application/x-nacl"; | 186 const char* kNaClPluginMimeType = "application/x-nacl"; |
| 184 | 187 |
| 185 static bool IsSyncableExtension(const Extension& extension) { | 188 static bool IsSyncableExtension(const Extension& extension) { |
| 186 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION; | 189 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION; |
| 187 } | 190 } |
| 188 | 191 |
| 189 static bool IsSyncableApp(const Extension& extension) { | 192 static bool IsSyncableApp(const Extension& extension) { |
| 190 return extension.GetSyncType() == Extension::SYNC_TYPE_APP; | 193 return extension.GetSyncType() == Extension::SYNC_TYPE_APP; |
| 191 } | 194 } |
| 192 | 195 |
| (...skipping 1794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1987 void ExtensionService::ReloadExtensions() { | 1990 void ExtensionService::ReloadExtensions() { |
| 1988 UnloadAllExtensions(); | 1991 UnloadAllExtensions(); |
| 1989 component_loader_->LoadAll(); | 1992 component_loader_->LoadAll(); |
| 1990 extensions::InstalledLoader(this).LoadAllExtensions(); | 1993 extensions::InstalledLoader(this).LoadAllExtensions(); |
| 1991 } | 1994 } |
| 1992 | 1995 |
| 1993 void ExtensionService::GarbageCollectExtensions() { | 1996 void ExtensionService::GarbageCollectExtensions() { |
| 1994 if (extension_prefs_->pref_service()->ReadOnly()) | 1997 if (extension_prefs_->pref_service()->ReadOnly()) |
| 1995 return; | 1998 return; |
| 1996 | 1999 |
| 2000 if (pending_extension_manager()->HasPendingExtensions()) { | |
| 2001 // Don't garbage collect while there are pending installations, which may | |
| 2002 // be using the temporary installation directory. Try to garbage collect | |
| 2003 // again later. | |
| 2004 MessageLoop::current()->PostDelayedTask( | |
| 2005 FROM_HERE, | |
| 2006 base::Bind(&ExtensionService::GarbageCollectExtensions, AsWeakPtr()), | |
| 2007 base::TimeDelta::FromSeconds(kGarbageCollectRetryDelay)); | |
| 2008 return; | |
| 2009 } | |
| 2010 | |
| 1997 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( | 2011 scoped_ptr<extensions::ExtensionPrefs::ExtensionsInfo> info( |
| 1998 extension_prefs_->GetInstalledExtensionsInfo()); | 2012 extension_prefs_->GetInstalledExtensionsInfo()); |
| 1999 | 2013 |
| 2000 std::multimap<std::string, FilePath> extension_paths; | 2014 std::multimap<std::string, FilePath> extension_paths; |
| 2001 for (size_t i = 0; i < info->size(); ++i) | 2015 for (size_t i = 0; i < info->size(); ++i) |
| 2002 extension_paths.insert(std::make_pair(info->at(i)->extension_id, | 2016 extension_paths.insert(std::make_pair(info->at(i)->extension_id, |
| 2003 info->at(i)->extension_path)); | 2017 info->at(i)->extension_path)); |
| 2004 | 2018 |
| 2005 info = extension_prefs_->GetAllIdleInstallInfo(); | 2019 info = extension_prefs_->GetAllIdleInstallInfo(); |
| 2006 for (size_t i = 0; i < info->size(); ++i) | 2020 for (size_t i = 0; i < info->size(); ++i) |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2985 extension_id, kOnUpdateAvailableEvent); | 2999 extension_id, kOnUpdateAvailableEvent); |
| 2986 } else { | 3000 } else { |
| 2987 // Delay installation if the extension is not idle. | 3001 // Delay installation if the extension is not idle. |
| 2988 return !IsExtensionIdle(extension_id); | 3002 return !IsExtensionIdle(extension_id); |
| 2989 } | 3003 } |
| 2990 } | 3004 } |
| 2991 | 3005 |
| 2992 void ExtensionService::OnBlacklistUpdated() { | 3006 void ExtensionService::OnBlacklistUpdated() { |
| 2993 CheckManagementPolicy(); | 3007 CheckManagementPolicy(); |
| 2994 } | 3008 } |
| OLD | NEW |