summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 04:56:35 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-18 04:56:35 +0000
commitaa4e5ad48feb5b400e29e9260fbc041f70c011ba (patch)
tree6c3bae51965add0b8519cd647a867d670fc511a5
parentc9308e87368d7c6e3db1cf4aa3e7fb92050652a4 (diff)
downloadchromium_src-aa4e5ad48feb5b400e29e9260fbc041f70c011ba.zip
chromium_src-aa4e5ad48feb5b400e29e9260fbc041f70c011ba.tar.gz
chromium_src-aa4e5ad48feb5b400e29e9260fbc041f70c011ba.tar.bz2
Fix a couple of crashes related to app-crashed balloon.
Close the crash-notification balloon if background contents is restarted for an app. And check for valid values when loading background contents. BUG=82492, 82505 TEST=manually Review URL: http://codereview.chromium.org/7012031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85724 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/background_contents_service.cc20
1 files changed, 15 insertions, 5 deletions
diff --git a/chrome/browser/background_contents_service.cc b/chrome/browser/background_contents_service.cc
index 1c22b51..d6de00f 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