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

Unified Diff: apps/app_load_service.cc

Issue 441553002: Remove deprecated extension notification from AppLoadService (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 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
« no previous file with comments | « apps/app_load_service.h ('k') | apps/app_load_service_factory.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/app_load_service.cc
diff --git a/apps/app_load_service.cc b/apps/app_load_service.cc
index 95608514cdc56ea89e50355c166b916502cbc04b..a2fb0e4eb8decd382904b07e09ff091a7784bbfb 100644
--- a/apps/app_load_service.cc
+++ b/apps/app_load_service.cc
@@ -19,6 +19,7 @@
#include "extensions/browser/extension_system.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/extension.h"
+#include "extensions/browser/extension_registry.h"
using extensions::Extension;
using extensions::ExtensionPrefs;
@@ -32,13 +33,11 @@ AppLoadService::PostReloadAction::PostReloadAction()
}
AppLoadService::AppLoadService(Profile* profile)
- : profile_(profile) {
+ : profile_(profile), extension_registry_observer_(this) {
registrar_.Add(this,
extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
content::NotificationService::AllSources());
- registrar_.Add(this,
- extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
- content::NotificationService::AllSources());
+ extension_registry_observer_.Add(extensions::ExtensionRegistry::Get(profile));
}
AppLoadService::~AppLoadService() {}
tapted 2014/08/04 07:05:37 This class is simple enough to just put extension
limasdf 2014/08/04 07:30:35 Done.
@@ -84,64 +83,59 @@ AppLoadService* AppLoadService::Get(Profile* profile) {
void AppLoadService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- switch (type) {
- case extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING: {
- extensions::ExtensionHost* host =
- content::Details<extensions::ExtensionHost>(details).ptr();
- const Extension* extension = host->extension();
- // It is possible for an extension to be unloaded before it stops loading.
- if (!extension)
- break;
- std::map<std::string, PostReloadAction>::iterator it =
- post_reload_actions_.find(extension->id());
- if (it == post_reload_actions_.end())
- break;
-
- switch (it->second.action_type) {
- case LAUNCH:
- LaunchPlatformApp(profile_, extension);
- break;
- case RESTART:
- RestartPlatformApp(profile_, extension);
- break;
- case LAUNCH_WITH_COMMAND_LINE:
- LaunchPlatformAppWithCommandLine(
- profile_, extension, it->second.command_line,
- it->second.current_dir);
- break;
- default:
- NOTREACHED();
- }
-
- post_reload_actions_.erase(it);
+ DCHECK_EQ(type, extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING);
+ extensions::ExtensionHost* host =
+ content::Details<extensions::ExtensionHost>(details).ptr();
+ const Extension* extension = host->extension();
+ // It is possible for an extension to be unloaded before it stops loading.
+ if (!extension)
+ return;
+ std::map<std::string, PostReloadAction>::iterator it =
+ post_reload_actions_.find(extension->id());
+ if (it == post_reload_actions_.end())
+ return;
+
+ switch (it->second.action_type) {
+ case LAUNCH:
+ LaunchPlatformApp(profile_, extension);
break;
- }
- case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
- const extensions::UnloadedExtensionInfo* unload_info =
- content::Details<extensions::UnloadedExtensionInfo>(details).ptr();
- if (!unload_info->extension->is_platform_app())
- break;
-
- extensions::ExtensionPrefs* extension_prefs =
- extensions::ExtensionPrefs::Get(profile_);
- if (WasUnloadedForReload(*unload_info) &&
- extension_prefs->IsActive(unload_info->extension->id()) &&
- !HasPostReloadAction(unload_info->extension->id())) {
- post_reload_actions_[unload_info->extension->id()].action_type = LAUNCH;
- }
+ case RESTART:
+ RestartPlatformApp(profile_, extension);
+ break;
+ case LAUNCH_WITH_COMMAND_LINE:
+ LaunchPlatformAppWithCommandLine(
+ profile_, extension, it->second.command_line, it->second.current_dir);
break;
- }
default:
NOTREACHED();
}
+
+ post_reload_actions_.erase(it);
+}
+
+void AppLoadService::OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const extensions::Extension* extension,
+ extensions::UnloadedExtensionInfo::Reason reason) {
+ if (!extension->is_platform_app())
+ return;
+
+ extensions::ExtensionPrefs* extension_prefs =
+ extensions::ExtensionPrefs::Get(browser_context);
+ if (WasUnloadedForReload(extension->id(), reason) &&
+ extension_prefs->IsActive(extension->id()) &&
+ !HasPostReloadAction(extension->id())) {
+ post_reload_actions_[extension->id()].action_type = LAUNCH;
+ }
}
bool AppLoadService::WasUnloadedForReload(
- const extensions::UnloadedExtensionInfo& unload_info) {
- if (unload_info.reason == extensions::UnloadedExtensionInfo::REASON_DISABLE) {
+ const extensions::ExtensionId& extension_id,
+ const extensions::UnloadedExtensionInfo::Reason reason) {
+ if (reason == extensions::UnloadedExtensionInfo::REASON_DISABLE) {
ExtensionPrefs* prefs = ExtensionPrefs::Get(profile_);
- return (prefs->GetDisableReasons(unload_info.extension->id()) &
- Extension::DISABLE_RELOAD) != 0;
+ return (prefs->GetDisableReasons(extension_id) &
+ Extension::DISABLE_RELOAD) != 0;
}
return false;
}
« no previous file with comments | « apps/app_load_service.h ('k') | apps/app_load_service_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698