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

Unified Diff: chrome/browser/extensions/extension_process_manager.cc

Issue 12253022: Manifest handler for all keys background-related. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_process_manager.cc
diff --git a/chrome/browser/extensions/extension_process_manager.cc b/chrome/browser/extensions/extension_process_manager.cc
index 1de90ca938dfa81b8ba5bd96b04acc834a35414a..098ffc25817bf9fd74cbdbb1062ba22d568687d8 100644
--- a/chrome/browser/extensions/extension_process_manager.cc
+++ b/chrome/browser/extensions/extension_process_manager.cc
@@ -25,8 +25,10 @@
#include "chrome/browser/view_type_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/extensions/background_info.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_messages.h"
+#include "chrome/common/extensions/manifest_handler.h"
#include "chrome/common/extensions/manifest_url_handler.h"
#include "chrome/common/url_constants.h"
#include "content/public/browser/browser_thread.h"
@@ -48,6 +50,8 @@ using content::Referrer;
using content::RenderViewHost;
using content::SiteInstance;
using content::WebContents;
+using extensions::BackgroundInfo;
+using extensions::BackgroundManifestHandler;
using extensions::Extension;
using extensions::ExtensionHost;
@@ -92,8 +96,9 @@ class IncognitoExtensionProcessManager : public ExtensionProcessManager {
static void CreateBackgroundHostForExtensionLoad(
ExtensionProcessManager* manager, const Extension* extension) {
- if (extension->has_persistent_background_page())
- manager->CreateBackgroundHost(extension, extension->GetBackgroundURL());
+ if (BackgroundInfo::HasPersistentBackgroundPage(extension))
+ manager->CreateBackgroundHost(extension,
+ BackgroundInfo::GetBackgroundURL(extension));
}
static void CreateBackgroundHostsForProfileStartup(
@@ -185,6 +190,14 @@ ExtensionProcessManager::ExtensionProcessManager(Profile* profile)
event_page_unloading_time_ = base::TimeDelta::FromSeconds(
unloading_time_sec);
}
+
+ std::vector<std::string> background_keys(BackgroundManifestHandler::keys());
Matt Perry 2013/02/15 20:15:02 This is cumbersome. How about making it a method o
Matt Perry 2013/02/15 20:15:02 Also, it feels a little out of place here, but I c
Yoyo Zhou 2013/02/16 00:54:04 Maybe we could call it ExtensionService? =) Serio
Yoyo Zhou 2013/02/16 00:54:04 I definitely considered this but I thought the own
+ linked_ptr<BackgroundManifestHandler> background_handler(
+ new BackgroundManifestHandler);
+ for (size_t i = 0; i < background_keys.size(); ++i) {
+ extensions::ManifestHandler::Register(background_keys[i],
+ background_handler);
+ }
}
ExtensionProcessManager::~ExtensionProcessManager() {
@@ -427,7 +440,7 @@ bool ExtensionProcessManager::IsBackgroundHostClosing(
}
int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
return background_page_data_[extension->id()].lazy_keepalive_count;
@@ -435,7 +448,7 @@ int ExtensionProcessManager::GetLazyKeepaliveCount(const Extension* extension) {
int ExtensionProcessManager::IncrementLazyKeepaliveCount(
const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
@@ -447,7 +460,7 @@ int ExtensionProcessManager::IncrementLazyKeepaliveCount(
int ExtensionProcessManager::DecrementLazyKeepaliveCount(
const Extension* extension) {
- if (!extension->has_lazy_background_page())
+ if (!BackgroundInfo::HasLazyBackgroundPage(extension))
return 0;
int& count = background_page_data_[extension->id()].lazy_keepalive_count;
@@ -720,7 +733,7 @@ void ExtensionProcessManager::OnExtensionHostCreated(ExtensionHost* host,
if (is_background) {
background_hosts_.insert(host);
- if (host->extension()->has_lazy_background_page()) {
+ if (BackgroundInfo::HasLazyBackgroundPage(host->extension())) {
linked_ptr<PerfTimer> since_unloaded(
background_page_data_[host->extension()->id()].
since_unloaded.release());

Powered by Google App Engine
This is Rietveld 408576698