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

Unified Diff: chrome/browser/background_contents_service.cc

Issue 7012031: Fix a couple of crashes related to app-crashed balloon. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix test Created 9 years, 7 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/background_contents_service.cc
diff --git a/chrome/browser/background_contents_service.cc b/chrome/browser/background_contents_service.cc
index 1c22b5195572e004c465980f2c6ab9ea23c160f3..d6de00f7a15c5d643a0375c7327abf38f04ddb33 100644
--- a/chrome/browser/background_contents_service.cc
+++ b/chrome/browser/background_contents_service.cc
@@ -41,6 +41,8 @@ void CloseBalloon(const std::string id) {
}
void ScheduleCloseBalloon(const std::string& extension_id) {
+ if (!MessageLoop::current()) // For unit_tests
+ return;
MessageLoop::current()->PostTask(FROM_HERE,
NewRunnableFunction(&CloseBalloon,
kNotificationPrefix + extension_id));
@@ -65,8 +67,13 @@ class CrashNotificationDelegate : public NotificationDelegate {
void Click() {
if (is_hosted_app_) {
- BackgroundContentsServiceFactory::GetForProfile(profile_)->
- LoadBackgroundContentsForExtension(profile_, extension_id_);
+ // There can be a race here: user clicks the balloon, and simultaneously
+ // reloads the sad tab for the app. So we check here to be safe before
+ // loading the background page.
+ BackgroundContentsService* service =
+ BackgroundContentsServiceFactory::GetForProfile(profile_);
+ if (!service->GetAppBackgroundContents(ASCIIToUTF16(extension_id_)))
+ service->LoadBackgroundContentsForExtension(profile_, extension_id_);
} else {
profile_->GetExtensionService()->ReloadExtension(extension_id_);
}
@@ -229,7 +236,7 @@ void BackgroundContentsService::Observe(NotificationType type,
if (extension && extension->background_url().is_valid())
break;
}
- RegisterBackgroundContents(Details<BackgroundContents>(details).ptr());
+ RegisterBackgroundContents(bgcontents);
break;
}
case NotificationType::EXTENSION_LOADED: {
@@ -387,9 +394,10 @@ void BackgroundContentsService::LoadBackgroundContentsFromDictionary(
DCHECK(extensions_service);
DictionaryValue* dict;
- contents->GetDictionaryWithoutPathExpansion(extension_id, &dict);
- if (dict == NULL)
+ if (!contents->GetDictionaryWithoutPathExpansion(extension_id, &dict) ||
+ dict == NULL)
return;
+
string16 frame_name;
std::string url;
dict->GetString(kUrlKey, &url);
@@ -518,6 +526,8 @@ void BackgroundContentsService::BackgroundContentsOpened(
DCHECK(!details->application_id.empty());
contents_map_[details->application_id].contents = details->contents;
contents_map_[details->application_id].frame_name = details->frame_name;
+
+ ScheduleCloseBalloon(UTF16ToASCII(details->application_id));
}
// Used by test code and debug checks to verify whether a given
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698