diff options
Diffstat (limited to 'chrome/browser/background/background_contents_service.cc')
-rw-r--r-- | chrome/browser/background/background_contents_service.cc | 74 |
1 files changed, 40 insertions, 34 deletions
diff --git a/chrome/browser/background/background_contents_service.cc b/chrome/browser/background/background_contents_service.cc index e9e310d..1dbc47a 100644 --- a/chrome/browser/background/background_contents_service.cc +++ b/chrome/browser/background/background_contents_service.cc @@ -161,73 +161,77 @@ BackgroundContentsService::GetBackgroundContents() const void BackgroundContentsService::StartObserving(Profile* profile) { // On startup, load our background pages after extension-apps have loaded. registrar_.Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Track the lifecycle of all BackgroundContents in the system to allow us // to store an up-to-date list of the urls. Start tracking contents when they // have been opened via CreateBackgroundContents(), and stop tracking them // when they are closed by script. registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Stop tracking BackgroundContents when they have been deleted (happens // during shutdown or if the render process dies). registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Track when the BackgroundContents navigates to a new URL so we can update // our persisted information as appropriate. registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Listen for new extension installs so that we can load any associated // background page. registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Track when the extensions crash so that the user can be notified // about it, and the crashed contents can be restarted. registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); registrar_.Add(this, chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Listen for extensions to be unloaded so we can shutdown associated // BackgroundContents. registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); // Make sure the extension-crash balloons are removed when the extension is // uninstalled/reloaded. We cannot do this from UNLOADED since a crashed // extension is unloaded immediately after the crash, not when user reloads or // uninstalls the extension. registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNINSTALLED, - Source<Profile>(profile)); + content::Source<Profile>(profile)); } -void BackgroundContentsService::Observe(int type, - const NotificationSource& source, - const NotificationDetails& details) { +void BackgroundContentsService::Observe( + int type, + const content::NotificationSource& source, + const content::NotificationDetails& details) { switch (type) { case chrome::NOTIFICATION_EXTENSIONS_READY: - LoadBackgroundContentsFromManifests(Source<Profile>(source).ptr()); - LoadBackgroundContentsFromPrefs(Source<Profile>(source).ptr()); + LoadBackgroundContentsFromManifests( + content::Source<Profile>(source).ptr()); + LoadBackgroundContentsFromPrefs(content::Source<Profile>(source).ptr()); break; case chrome::NOTIFICATION_BACKGROUND_CONTENTS_DELETED: - BackgroundContentsShutdown(Details<BackgroundContents>(details).ptr()); + BackgroundContentsShutdown( + content::Details<BackgroundContents>(details).ptr()); break; case chrome::NOTIFICATION_BACKGROUND_CONTENTS_CLOSED: - DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); - UnregisterBackgroundContents(Details<BackgroundContents>(details).ptr()); + DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); + UnregisterBackgroundContents( + content::Details<BackgroundContents>(details).ptr()); break; case chrome::NOTIFICATION_BACKGROUND_CONTENTS_NAVIGATED: { - DCHECK(IsTracked(Details<BackgroundContents>(details).ptr())); + DCHECK(IsTracked(content::Details<BackgroundContents>(details).ptr())); // Do not register in the pref if the extension has a manifest-specified // background page. BackgroundContents* bgcontents = - Details<BackgroundContents>(details).ptr(); - Profile* profile = Source<Profile>(source).ptr(); + content::Details<BackgroundContents>(details).ptr(); + Profile* profile = content::Source<Profile>(source).ptr(); const string16& appid = GetParentApplicationId(bgcontents); ExtensionService* extension_service = profile->GetExtensionService(); // extension_service can be NULL when running tests. @@ -241,8 +245,9 @@ void BackgroundContentsService::Observe(int type, break; } case chrome::NOTIFICATION_EXTENSION_LOADED: { - const Extension* extension = Details<const Extension>(details).ptr(); - Profile* profile = Source<Profile>(source).ptr(); + const Extension* extension = + content::Details<const Extension>(details).ptr(); + Profile* profile = content::Source<Profile>(source).ptr(); if (extension->is_hosted_app() && extension->background_url().is_valid()) { // If there is a background page specified in the manifest for a hosted @@ -265,18 +270,19 @@ void BackgroundContentsService::Observe(int type, } case chrome::NOTIFICATION_EXTENSION_PROCESS_TERMINATED: case chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED: { - Profile* profile = Source<Profile>(source).ptr(); + Profile* profile = content::Source<Profile>(source).ptr(); const Extension* extension = NULL; if (type == chrome::NOTIFICATION_BACKGROUND_CONTENTS_TERMINATED) { BackgroundContents* bg = - Details<BackgroundContents>(details).ptr(); + content::Details<BackgroundContents>(details).ptr(); std::string extension_id = UTF16ToASCII( BackgroundContentsServiceFactory::GetForProfile(profile)-> GetParentApplicationId(bg)); extension = profile->GetExtensionService()->GetExtensionById(extension_id, false); } else { - ExtensionHost* extension_host = Details<ExtensionHost>(details).ptr(); + ExtensionHost* extension_host = + content::Details<ExtensionHost>(details).ptr(); extension = extension_host->extension(); } if (!extension) @@ -292,13 +298,13 @@ void BackgroundContentsService::Observe(int type, break; } case chrome::NOTIFICATION_EXTENSION_UNLOADED: - switch (Details<UnloadedExtensionInfo>(details)->reason) { + switch (content::Details<UnloadedExtensionInfo>(details)->reason) { // Intentionally fall through. case extension_misc::UNLOAD_REASON_DISABLE: case extension_misc::UNLOAD_REASON_UNINSTALL: ShutdownAssociatedBackgroundContents( - ASCIIToUTF16( - Details<UnloadedExtensionInfo>(details)->extension->id())); + ASCIIToUTF16(content::Details<UnloadedExtensionInfo>(details)-> + extension->id())); break; case extension_misc::UNLOAD_REASON_UPDATE: { // If there is a manifest specified background page, then shut it down @@ -306,7 +312,7 @@ void BackgroundContentsService::Observe(int type, // then it will be loaded from LOADED callback. Otherwise, leave // BackgroundContents in place. const Extension* extension = - Details<UnloadedExtensionInfo>(details)->extension; + content::Details<UnloadedExtensionInfo>(details)->extension; if (extension->background_url().is_valid()) ShutdownAssociatedBackgroundContents(ASCIIToUTF16(extension->id())); break; @@ -314,15 +320,15 @@ void BackgroundContentsService::Observe(int type, default: NOTREACHED(); ShutdownAssociatedBackgroundContents( - ASCIIToUTF16( - Details<UnloadedExtensionInfo>(details)->extension->id())); + ASCIIToUTF16(content::Details<UnloadedExtensionInfo>(details)-> + extension->id())); break; } break; case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { // Remove any "This extension has crashed" balloons. - ScheduleCloseBalloon(*Details<const std::string>(details).ptr()); + ScheduleCloseBalloon(*content::Details<const std::string>(details).ptr()); break; } @@ -471,8 +477,8 @@ BackgroundContents* BackgroundContentsService::CreateBackgroundContents( BackgroundContentsOpened(&details); NotificationService::current()->Notify( chrome::NOTIFICATION_BACKGROUND_CONTENTS_OPENED, - Source<Profile>(profile), - Details<BackgroundContentsOpenedDetails>(&details)); + content::Source<Profile>(profile), + content::Details<BackgroundContentsOpenedDetails>(&details)); return contents; } |