Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 11348301: Force-load a lazy background page whenever an extension is enabled. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 const char* kNaClPluginMimeType = "application/x-nacl"; 182 const char* kNaClPluginMimeType = "application/x-nacl";
183 183
184 static bool IsSyncableExtension(const Extension& extension) { 184 static bool IsSyncableExtension(const Extension& extension) {
185 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION; 185 return extension.GetSyncType() == Extension::SYNC_TYPE_EXTENSION;
186 } 186 }
187 187
188 static bool IsSyncableApp(const Extension& extension) { 188 static bool IsSyncableApp(const Extension& extension) {
189 return extension.GetSyncType() == Extension::SYNC_TYPE_APP; 189 return extension.GetSyncType() == Extension::SYNC_TYPE_APP;
190 } 190 }
191 191
192 static void DoNothing(extensions::ExtensionHost* host) {
193 }
194
192 } // namespace 195 } // namespace
193 196
194 ExtensionService::ExtensionRuntimeData::ExtensionRuntimeData() 197 ExtensionService::ExtensionRuntimeData::ExtensionRuntimeData()
195 : background_page_ready(false), 198 : background_page_ready(false),
196 being_upgraded(false), 199 being_upgraded(false),
197 has_used_webrequest(false) { 200 has_used_webrequest(false) {
198 } 201 }
199 202
200 ExtensionService::ExtensionRuntimeData::~ExtensionRuntimeData() { 203 ExtensionService::ExtensionRuntimeData::~ExtensionRuntimeData() {
201 } 204 }
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after
928 AcknowledgeExternalExtension(extension->id()); 931 AcknowledgeExternalExtension(extension->id());
929 } 932 }
930 933
931 if (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT) 934 if (disable_reasons & Extension::DISABLE_SIDELOAD_WIPEOUT)
932 UMA_HISTOGRAM_BOOLEAN("DisabledExtension.ExtensionWipedStatus", false); 935 UMA_HISTOGRAM_BOOLEAN("DisabledExtension.ExtensionWipedStatus", false);
933 936
934 // Move it over to the enabled list. 937 // Move it over to the enabled list.
935 extensions_.Insert(make_scoped_refptr(extension)); 938 extensions_.Insert(make_scoped_refptr(extension));
936 disabled_extensions_.Remove(extension->id()); 939 disabled_extensions_.Remove(extension->id());
937 940
941 // If the extension has a lazy background page, make sure it gets loaded to
Matt Perry 2012/11/29 20:24:46 ExtensionService is not the best place for this co
Marijn Kruisselbrink 2012/11/29 21:07:19 Ah yes, of course. Done.
942 // discover which events the extension wants to listen to.
943 if (extension->has_lazy_background_page()) {
944 extensions::LazyBackgroundTaskQueue* queue =
945 system_->lazy_background_task_queue();
946 queue->AddPendingTask(profile_, extension->id(), base::Bind(&DoNothing));
947 }
948
938 NotifyExtensionLoaded(extension); 949 NotifyExtensionLoaded(extension);
939 950
940 // Notify listeners that the extension was enabled. 951 // Notify listeners that the extension was enabled.
941 content::NotificationService::current()->Notify( 952 content::NotificationService::current()->Notify(
942 chrome::NOTIFICATION_EXTENSION_ENABLED, 953 chrome::NOTIFICATION_EXTENSION_ENABLED,
943 content::Source<Profile>(profile_), 954 content::Source<Profile>(profile_),
944 content::Details<const Extension>(extension)); 955 content::Details<const Extension>(extension));
945 956
946 SyncExtensionChangeIfNeeded(*extension); 957 SyncExtensionChangeIfNeeded(*extension);
947 } 958 }
(...skipping 2035 matching lines...) Expand 10 before | Expand all | Expand 10 after
2983 extension_id, kOnUpdateAvailableEvent); 2994 extension_id, kOnUpdateAvailableEvent);
2984 } else { 2995 } else {
2985 // Delay installation if the extension is not idle. 2996 // Delay installation if the extension is not idle.
2986 return !IsExtensionIdle(extension_id); 2997 return !IsExtensionIdle(extension_id);
2987 } 2998 }
2988 } 2999 }
2989 3000
2990 void ExtensionService::OnBlacklistUpdated() { 3001 void ExtensionService::OnBlacklistUpdated() {
2991 CheckManagementPolicy(); 3002 CheckManagementPolicy();
2992 } 3003 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698