Commit c7c0c92c authored by koz@chromium.org's avatar koz@chromium.org

Revert 241162 "Make clicking the restart bubble for crashed apps..."

This CL had the unintended side effect that Simulate Browser Restart no longer
works. Also, experimentation suggests that the original bug it was intended to
fix works without this change now.

> Make clicking the restart bubble for crashed apps work.
> 
> Previously AppLoadService listened for
> NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING before dispatching the
> onRestarted() event after a reload, but in the case of packaged apps, which use
> non-persistent background pages, that notification will never get fired. This
> is because reloading an app doesn't cause its background page to get loaded -
> only a relevant event causes the page to be woken up.
> 
> This patch fixes the issue by listening for NOTIFICATION_EXTENSION_LOADED
> instead, which is always fired after a reload. It also determines whether an
> extension is listening to an event by checking which events it has registered
> for, not which ones it currently has a listener for,
> NOTIFICATION_EXTENSION_LOADED is the notification that listeners get created
> on, and so to avoid raciness we check registered events (ie: the persisted
> list of events that an extension is interested in).
> 
> BUG=327964
> 
> Review URL: https://codereview.chromium.org/93593003

TBR=koz@chromium.org

Review URL: https://codereview.chromium.org/127843005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@243703 0039d316-1c4b-4281-b951-d872f2087c98
parent 84511467
......@@ -33,7 +33,7 @@ AppLoadService::PostReloadAction::PostReloadAction()
AppLoadService::AppLoadService(Profile* profile)
: profile_(profile) {
registrar_.Add(
this, chrome::NOTIFICATION_EXTENSION_LOADED,
this, chrome::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING,
content::NotificationService::AllSources());
registrar_.Add(
this, chrome::NOTIFICATION_EXTENSION_UNLOADED,
......@@ -78,8 +78,13 @@ void AppLoadService::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
switch (type) {
case chrome::NOTIFICATION_EXTENSION_LOADED: {
Extension* extension = content::Details<Extension>(details).ptr();
case chrome::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())
......
......@@ -380,12 +380,9 @@ void RestartPlatformApp(Profile* profile, const Extension* extension) {
#endif
extensions::EventRouter* event_router =
ExtensionSystem::Get(profile)->event_router();
// We check for registered events, rather than listeners, because listeners
// may not be instantiated for the events yet.
std::set<std::string> events =
event_router->GetRegisteredEvents(extension->id());
bool listening_to_restart =
events.count(app_runtime::OnRestarted::kEventName) > 0;
bool listening_to_restart = event_router->
ExtensionHasEventListener(extension->id(),
app_runtime::OnRestarted::kEventName);
if (listening_to_restart) {
extensions::AppEventRouter::DispatchOnRestartedEvent(profile, extension);
......@@ -396,8 +393,9 @@ void RestartPlatformApp(Profile* profile, const Extension* extension) {
extension_service()->extension_prefs();
bool had_windows = extension_prefs->IsActive(extension->id());
extension_prefs->SetIsActive(extension->id(), false);
bool listening_to_launch =
events.count(app_runtime::OnLaunched::kEventName) > 0;
bool listening_to_launch = event_router->
ExtensionHasEventListener(extension->id(),
app_runtime::OnLaunched::kEventName);
if (listening_to_launch && had_windows)
LaunchPlatformAppWithNoData(profile, extension);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment